-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let bgp docker generate configuration by itself #173
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,15 @@ FROM docker-base | |
COPY deps/quagga_*.deb /deps/ | ||
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } && \ | ||
dpkg_apt /deps/quagga_*.deb && \ | ||
apt-get update && \ | ||
apt-get -y install -f python-jinja2 python-netaddr python-ipaddr python-lxml && \ | ||
apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y && \ | ||
rm -rf /deps | ||
|
||
COPY daemons /etc/quagga/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
where is this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's already there. somebody add it in a previous version. |
||
COPY ["*.j2", "config.sh", "template_list", "*.py", "/etc/swss/"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
/etc is not a good place for scripts. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we embed the mountpoint here, e.g., VOLUME ['/etc/sonic'] Then, in the base image, we can put minigraph in the /etc/sonic/, also, the VOLUME is in baseimage as it is shared by all dockers. |
||
ENTRYPOINT service rsyslog start \ | ||
&& /etc/swss/config.sh \ | ||
&& service quagga start \ | ||
&& /bin/bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
! | ||
{% block banner %} | ||
! =========== Managed by Ansible DO NOT EDIT! ======================== | ||
! generated by templates/quagga/bgpd.conf.j2 using minigraph_facts.py | ||
! file: bgpd.conf | ||
! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not true |
||
{% endblock banner %} | ||
! | ||
{% block system_init %} | ||
hostname {{ inventory_hostname }} | ||
password zebra | ||
log syslog informational | ||
log facility local4 | ||
! enable password {# {{ en_passwd }} TODO: param needed #} | ||
{% endblock system_init %} | ||
! | ||
{% block bgp_init %} | ||
! | ||
! bgp multiple-instance | ||
! | ||
router bgp {{ minigraph_bgp_asn }} | ||
bgp log-neighbor-changes | ||
bgp bestpath as-path multipath-relax | ||
{# TODO: use lo[0] for backward compatibility, will revisit the case with multiple lo interfaces #} | ||
bgp router-id {{ minigraph_lo_interfaces[0]['addr'] }} | ||
{# advertise loopback #} | ||
{% for lo in minigraph_lo_interfaces %} | ||
{% if lo['addr'] | ipv4 %} | ||
network {{ lo['addr'] }}/32 | ||
{% elif lo['addr'] | ipv6 %} | ||
address-family ipv6 | ||
network {{ lo['addr'] }}/128 | ||
exit-address-family | ||
{% endif %} | ||
{% endfor %} | ||
{% endblock bgp_init %} | ||
{% block vlan_advertisement %} | ||
{% for interface in minigraph_interfaces %} | ||
{% if interface['name'].startswith('Vlan') %} | ||
network {{ interface['subnet'] }} | ||
{% endif %} | ||
{% endfor %} | ||
{% endblock vlan_advertisement %} | ||
{% block bgp_sessions %} | ||
{% for bgp_session in minigraph_bgp %} | ||
{% if bgp_session['asn'] != 0 %} | ||
neighbor {{ bgp_session['addr'] }} remote-as {{ bgp_session['asn'] }} | ||
neighbor {{ bgp_session['addr'] }} description {{ bgp_session['name'] }} | ||
{% if bgp_session['addr'] | ipv6 %} | ||
address-family ipv6 | ||
neighbor {{ bgp_session['addr'] }} activate | ||
maximum-paths 64 | ||
exit-address-family | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endblock bgp_sessions %} | ||
! | ||
maximum-paths 64 | ||
! | ||
route-map ISOLATE permit 10 | ||
set as-path prepend {{ minigraph_bgp_asn }} | ||
! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
cd /etc/swss | ||
|
||
awk '{system("python render_config.py -m /etc/swss/minigraph.xml "$1 ">"$2" && chown "$3" "$2" && chmod "$4" "$2)}' template_list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this command too complex to read? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree, use variable name would make it more readable. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
## vtysh only accepts script in stdin, so cannot be directly used in shebang | ||
## Cut the tail of this script and feed vtysh stdin | ||
sed -n -e '9,$p' < "$0" | vtysh "$@" | ||
## Exit with vtysh return code | ||
exit $? | ||
|
||
## vtysh script start from next line, which line number MUST eqaul in 'sed' command above | ||
|
||
configure terminal | ||
router bgp {{ minigraph_bgp_asn }} | ||
{% for bgp_session in minigraph_bgp %} | ||
neighbor {{ bgp_session['addr'] }} route-map ISOLATE out | ||
{% endfor %} | ||
exit | ||
exit | ||
|
||
{% for bgp_session in minigraph_bgp %} | ||
clear ip bgp {{ bgp_session['addr'] }} soft out | ||
{% endfor %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move them to docker base as all the docker are going to use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with @lguohan @taoyl-ms, not to move to docker-base. Instead, package it and install in all the related docker images.