-
Notifications
You must be signed in to change notification settings - Fork 1.5k
sonic-cfggen with sonicv2 dockers #190
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
Changes from 6 commits
d2585ac
2825c2e
d18efc6
5c6b080
ed904f7
504268b
3945c78
c963146
e3bea6c
1df26ef
ca72ace
56f0fd8
dc361cf
4fa19f2
6f41f3e
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ FROM docker-base | |
|
||
RUN apt-get update | ||
|
||
RUN apt-get install -y libdbus-1-3 libdaemon0 libjansson4 | ||
RUN apt-get install -y libdbus-1-3 libdaemon0 libjansson4 python-lxml python-jinja2 python-netaddr python-ipaddr python-yaml | ||
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.
Add a line break and some comment why they are needed. #Closed 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, make it more clear why we need these packages. #Closed |
||
|
||
COPY debs/ debs | ||
|
||
|
@@ -15,7 +15,9 @@ debs/{{ deb }}{{' '}} | |
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y | ||
RUN rm -rf /debs | ||
|
||
COPY ["start.sh", "/usr/bin/"] | ||
COPY ["*.j2", "/etc/swss/bgp/"] | ||
COPY ["start.sh", "config.sh", "/usr/bin/"] | ||
|
||
ENTRYPOINT /usr/bin/start.sh \ | ||
ENTRYPOINT /usr/bin/config.sh \ | ||
&& /usr/bin/start.sh \ | ||
&& /bin/bash |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
! | ||
{% block banner %} | ||
! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== | ||
! generated by templates/quagga/bgpd.conf.j2 using minigraph_facts.py | ||
! file: bgpd.conf | ||
! | ||
{% 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,13 @@ | ||
#!/bin/bash | ||
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.
Replace this shell script by a makefile, so it will not update after reboot. #Pending 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. Will consider performance issue in later stage. #Closed 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. this maybe a good idea, currently it is not clear when the configuration in the docker should be updated and what should happen in the docker. #Closed |
||
|
||
sonic-cfggen -m /etc/sonic/minigraph.xml -t /etc/swss/bgp/bgpd.conf.j2 >/etc/quagga/bgpd.conf | ||
sonic-cfggen -m /etc/sonic/minigraph.xml -t /etc/swss/bgp/zebra.conf.j2 >/etc/quagga/zebra.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. add -e? 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. I think python will return none-zero value itself upon exceptions? 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. yes, but if return non zero, what will your config.sh do? goes on? -e allows you Automatic exit from bash shell script on error In reply to: 96070348 [](ancestors = 96070348) |
||
sonic-cfggen -m /etc/sonic/minigraph.xml -t /etc/swss/bgp/isolate.j2 >/usr/sbin/bgp-isolate | ||
chown root:root /usr/sbin/bgp-isolate | ||
chmod 0755 /usr/sbin/bgp-isolate | ||
|
||
sonic-cfggen -m /etc/sonic/minigraph.xml -t /etc/swss/bgp/unisolate.j2 >/usr/sbin/bgp-unisolate | ||
chown root:root /usr/sbin/bgp-unisolate | ||
chmod 0755 /usr/sbin/bgp-unisolate | ||
|
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 %} |
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 %} | ||
no 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 %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
! | ||
{% block banner %} | ||
! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== | ||
! generated by templates/quagga/zebra.conf.j2 using minigraph_facts.py | ||
! file: zebra.conf | ||
! | ||
{% endblock banner %} | ||
! | ||
{% block sys_init %} | ||
hostname {{ inventory_hostname }} | ||
password zebra | ||
enable password zebra | ||
{% endblock sys_init %} | ||
! | ||
{% block interfaces %} | ||
! Enable link-detect (default disabled) | ||
{% for interface in minigraph_interfaces %} | ||
interface {{ interface['alias'] }} | ||
link-detect | ||
! | ||
{% endfor %} | ||
{% endblock interfaces %} | ||
! | ||
{% block default_route %} | ||
! set static default route to mgmt gateway as a backup to learned default | ||
ip route 0.0.0.0/0 {{ minigraph_mgmt_interface['gwaddr'] }} 200 | ||
{% endblock default_route %} | ||
! | ||
{% block source_loopback %} | ||
! Set ip source to loopback for bgp learned routes | ||
route-map RM_SET_SRC permit 10 | ||
set src {{ minigraph_lo_interfaces[0]['addr'] }} | ||
! | ||
{% set lo_ipv6_addrs = [] %} | ||
{% if minigraph_lo_interfaces is defined %} | ||
{% for interface in minigraph_lo_interfaces %} | ||
{% if interface['addr'] is defined and interface['addr']|ipv6 %} | ||
{% if lo_ipv6_addrs.append(interface['addr']) %} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
{% if lo_ipv6_addrs|length > 0 %} | ||
route-map RM_SET_SRC6 permit 10 | ||
set src {{ lo_ipv6_addrs[0] }} | ||
! | ||
{% endif %} | ||
ip protocol bgp route-map RM_SET_SRC | ||
! | ||
{% if lo_ipv6_addrs|length > 0 %} | ||
ipv6 protocol bgp route-map RM_SET_SRC6 | ||
! | ||
{% endif %} | ||
{% endblock source_loopback %} | ||
! | ||
{% block logging %} | ||
log syslog informational | ||
log facility local4 | ||
{% endblock logging %} | ||
! | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
/bin/cp -rf /etc/swss/lldp/lldpd /etc/default/lldpd | ||
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.
If lldp is static file, let's move it into Dockerfile. #Closed |
||
|
||
sonic-cfggen -m /etc/sonic/minigraph.xml -t /etc/swss/lldp/lldpd.conf.j2 >/etc/lldpd.conf | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
############################################################################### | ||
# Managed by sonic-cfggen | ||
############################################################################### | ||
|
||
# Uncomment to start SNMP subagent and enable CDP, SONMP and EDP protocol | ||
DAEMON_ARGS="" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% for member in alias_map %} | ||
configure ports {{member['sonic']}} lldp portidsubtype local {{member['origin']}} | ||
{% endfor %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
hwsku=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku` | ||
/bin/cp -rf /usr/share/sonic/$hwsku/sensors.conf /etc/sensors.d/ | ||
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.
Move to Dockerfile? #Closed 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. run-time determined variable in source path, thus Dockerfile won't work #Closed |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
if dpkg-query -W --showformat='${Version}' snmp |grep -q "5.7.2"; then | ||
snmp_user=snmp | ||
else | ||
snmp_uesr=Debian-snmp | ||
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.
snmp_user |
||
fi | ||
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. I think we do not need this "if" as the snmp version is embedded in the buildimage, we know which snmp version we are using. just use snmp_user=snmp |
||
|
||
#TODO: check with sasha whether this file will be generated by base image or in container | ||
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.
Do you mean var.yml? |
||
sonic-cfggen -m /etc/sonic/minigraph.xml -v /etc/sonic/var/yml -t /etc/swss/snmp/sysDescription.j2 >/etc/ssw/sysDescription | ||
|
||
sonic-cfggen -a '{"snmp_user":"'$snmp_user'"}' -t /etc/swss/snmp/snmpd.j2 >/etc/default/snmpd | ||
|
||
sonic-cfggen -m /etc/sonic/minigraph.xml -v /etc/sonic/var.yml -t /etc/swss/snmp/snmpd.conf.j2 >/etc/snmp/snmpd.conf | ||
|
||
hwsku=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku` | ||
/bin/cp -rf /usr/share/sonic/$hwsku/alias_map.json /etc/snmp/ | ||
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.
you do not need -r here. #Resolved |
||
|
||
|
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.
why not put this into base image?
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.
I vote to keep dev packages out of base image. In concept, they are part of our deliverable and expected updating/adding/remove frequently then a base image.
In reply to: 96108784 [](ancestors = 96108784)
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.
In this version let's keep python dependencies out of base image. Let's discuss later and make changes if needed in a seperated PR. #Resolved