Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions dockers/docker-fpm/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ 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

# Dependencies for sonic-cfggen
RUN apt-get install -y python-lxml python-jinja2 python-netaddr python-ipaddr python-yaml

COPY \
{% for deb in docker_fpm_debs.split(' ') -%}
Expand All @@ -19,7 +22,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
63 changes: 63 additions & 0 deletions dockers/docker-fpm/bgpd.conf.j2
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 }}
!
14 changes: 14 additions & 0 deletions dockers/docker-fpm/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Jan 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bash [](start = 7, length = 4)

Replace this shell script by a makefile, so it will not update after reboot. #Pending

Copy link
Copy Markdown
Contributor Author

@taoyl-ms taoyl-ms Jan 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will consider performance issue in later stage. #Closed

Copy link
Copy Markdown
Collaborator

@lguohan lguohan Jan 20, 2017

Choose a reason for hiding this comment

The 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


mkdir -p /etc/quagga
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add -e?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think python will return none-zero value itself upon exceptions?

Copy link
Copy Markdown
Collaborator

@lguohan lguohan Jan 14, 2017

Choose a reason for hiding this comment

The 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

20 changes: 20 additions & 0 deletions dockers/docker-fpm/isolate.j2
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 %}
20 changes: 20 additions & 0 deletions dockers/docker-fpm/unisolate.j2
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 %}
61 changes: 61 additions & 0 deletions dockers/docker-fpm/zebra.conf.j2
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 %}
!

10 changes: 8 additions & 2 deletions dockers/docker-lldp-sv2/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ debs/

COPY python-wheels /python-wheels

RUN apt-get update && apt-get install -y python-pip supervisor libbsd0 libevent-2.0-5 libjansson4 libwrap0 libxml2 libpci3 libperl5.20
RUN apt-get update && apt-get install -y python-pip supervisor libbsd0 libevent-2.0-5 libjansson4 libwrap0 libxml2 libpci3 libperl5.20

# Dependencies for sonic-cfggen
RUN apt-get install -y python-lxml python-jinja2 python-netaddr python-ipaddr python-yaml

## Pre-install the fundamental packages
## Install Python SSWSDK
Expand All @@ -27,5 +30,8 @@ RUN pip install /python-wheels/sswsdk-2.0.1-py2-none-any.whl && \

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY reconfigure.sh /opt/reconfigure.sh
COPY ["config.sh", "/usr/bin/"]
COPY ["lldpd.conf.j2", "/etc/swss/lldp/"]
COPY ["lldpd", "/etc/default/"]

ENTRYPOINT ["/usr/bin/supervisord"]
ENTRYPOINT /usr/bin/config.sh && /usr/bin/supervisord
4 changes: 4 additions & 0 deletions dockers/docker-lldp-sv2/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

sonic-cfggen -m /etc/sonic/minigraph.xml -t /etc/swss/lldp/lldpd.conf.j2 >/etc/lldpd.conf

6 changes: 6 additions & 0 deletions dockers/docker-lldp-sv2/lldpd
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=""
3 changes: 3 additions & 0 deletions dockers/docker-lldp-sv2/lldpd.conf.j2
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 %}
16 changes: 0 additions & 16 deletions dockers/docker-platform-monitor/Dockerfile

This file was deleted.

28 changes: 28 additions & 0 deletions dockers/docker-platform-monitor/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM docker-base

RUN apt-get update

RUN apt-get install -y smartmontools sensord

# Dependencies for sonic-cfggen
RUN apt-get install -y python-lxml python-jinja2 python-netaddr python-ipaddr python-yaml

COPY debs/ debs

RUN dpkg -i \
{% for deb in docker_fpm_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
{%- endfor %}

## Clean up
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs

COPY ["config.sh", "/usr/bin/"]

ENTRYPOINT /usr/bin/config.sh \
&& service rsyslog start \
&& service lm-sensors start \
&& service smartmontools start \
&& service sensord start \
&& /bin/bash
7 changes: 7 additions & 0 deletions dockers/docker-platform-monitor/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

mkdir -p /etc/sensors.d

hwsku=`sonic-cfggen -m /etc/sonic/minigraph.xml -v minigraph_hwsku`
/bin/cp -rf /usr/share/sonic/$hwsku/sensors.conf /etc/sensors.d/
Copy link
Copy Markdown
Collaborator

@qiluo-msft qiluo-msft Jan 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sensors [](start = 36, length = 7)

Move to Dockerfile? #Closed

Copy link
Copy Markdown
Contributor Author

@taoyl-ms taoyl-ms Jan 19, 2017

Choose a reason for hiding this comment

The 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


8 changes: 7 additions & 1 deletion dockers/docker-snmp-sv2/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ ENV PYTHONOPTIMIZE 1
## Clean up
RUN apt-get update && apt-get install -y libmysqlclient-dev libmysqld-dev libperl-dev libpci-dev libpci3 libsensors4 libsensors4-dev libwrap0-dev

# Dependencies for sonic-cfggen
RUN apt-get install -y python-lxml python-jinja2 python-netaddr python-ipaddr python-yaml

RUN dpkg -i \
{% for deb in docker_snmp_sv2_debs.split(' ') -%}
debs/{{ deb }}{{' '}}
Expand Down Expand Up @@ -44,8 +47,11 @@ RUN apt-get -y install build-essential wget libssl-dev openssl supervisor && \
rm -rf ~/.cache

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY ["*.j2", "/etc/swss/snmp/"]
COPY ["snmpd", "/etc/default/"]
COPY ["config.sh", "/usr/bin/"]

## Although exposing ports is not need for host net mode, keep it for possible bridge mode
EXPOSE 161/udp 162/udp

ENTRYPOINT ["/usr/bin/supervisord"]
ENTRYPOINT /usr/bin/config.sh && /usr/bin/supervisord
13 changes: 13 additions & 0 deletions dockers/docker-snmp-sv2/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

#sysDescription is currently mounted, uncomment this line and provide version.yml instead if use copying instead of mounting
#sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/version.yml -t /etc/swss/snmp/sysDescription.j2 >/etc/ssw/sysDescription

mkdir -p /etc/snmp

sonic-cfggen -m /etc/sonic/minigraph.xml -y /etc/sonic/snmp.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/
Copy link
Copy Markdown
Collaborator

@lguohan lguohan Jan 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r [](start = 9, length = 1)

you do not need -r here. #Resolved



11 changes: 11 additions & 0 deletions dockers/docker-snmp-sv2/snmpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file controls the activity of snmpd

# Don't load any MIBs by default.
# You might comment this lines once you have the MIBs downloaded.
export MIBS=

# snmpd control (yes means start daemon).
SNMPDRUN=yes

# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-LS4d -Lf /dev/null -u snmp -g snmp -I -smux,mteTrigger,mteTriggerConf,ifTable,ifXTable -p /run/snmpd.pid'
Loading