SNMP/LLDP Containers: Sonic V2 Support (#41)

* Adding support for V2 in SNMP/LLDP (-sv2 postfix)
* Fixes for V1 containers: logging
* Fixes for V1 LLDP: limit LLDP to Front-panel or MGMT interfaces.
This commit is contained in:
thomasbo 2016-10-25 18:52:13 -07:00 committed by Shuotian Cheng
parent 23542f3e02
commit 135ba232ca
8 changed files with 128 additions and 23 deletions

View File

@ -0,0 +1,22 @@
FROM docker-base
COPY deps/sswsdk*.whl deps/sonic_d*.whl deps/lldpsyncd_*.deb deps/lldpd_*.deb /deps/
## Pre-install the fundamental packages
## Install Python SSWSDK (lldpsyncd dependency)
## Install LLDP Sync Daemon
## Note: dpkg_apt function has the benefit to detect missing .deb file
## Clean up
RUN apt-get update && \
dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } && \
dpkg_apt /deps/lldpd_*.deb && \
apt-get install -y python-pip supervisor && \
pip install /deps/sswsdk*.whl && \
pip install /deps/sonic_d*.whl && \
apt-get remove -y python-pip && \
apt-get purge -y && apt-get autoclean -y && apt-get autoremove -y && \
rm -rf /deps ~/.cache
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ENTRYPOINT ["/usr/bin/supervisord"]

View File

@ -0,0 +1,19 @@
[supervisord]
nodaemon=true
[program:lldpd]
# https://github.com/vincentbernat/lldpd/commit/9856f2792c301116cc4a3fcfba91b9672ee5db1f
# - `-d` means to stay in foreground, log to syslog
# - `-dd` means to stay in foreground, log warnings to console
# - `-ddd` means to stay in foreground, log warnings and info to console
# - `-dddd` means to stay in foreground, log all to console
command=/usr/sbin/lldpd -d -I Ethernet*,eth*
priority=100
[program:lldp-syncd]
command=/usr/bin/env python2 -m lldp_syncd
priority=200
[program:rsyslogd]
command=/usr/sbin/rsyslogd -n
priority=1

View File

@ -1,20 +1,21 @@
FROM docker-base
COPY deps/*py2*.whl deps/lldpsyncd_*.deb deps/lldpd_*.deb /deps/
COPY deps/sswsdk*.whl deps/lldpsyncd_*.deb deps/lldpd_*.deb /deps/
## Pre-install the fundamental packages
## Install Python SSWSDK (lldpsyncd dependancy)
## Install Python SSWSDK (lldpsyncd dependency)
## Install LLDP Sync Daemon
## Note: dpkg_apt function has the benefit to detect missing .deb file
## Clean up
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } && \
dpkg_apt /deps/lldpd_*.deb && \
dpkg_apt /deps/lldpsyncd_*.deb && \
RUN apt-get update && \
dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } && \
dpkg_apt /deps/lldpd_*.deb && \
dpkg_apt /deps/lldpsyncd_*.deb && \
apt-get install -y python-pip supervisor && \
pip install /deps/*.whl && \
pip install /deps/sswsdk*.whl && \
apt-get remove -y python-pip && \
apt-get purge -y && apt-get autoclean -y && apt-get autoremove -y && \
rm -rf /deps
apt-get purge -y && apt-get autoclean -y && apt-get autoremove -y && \
rm -rf /deps ~/.cache
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

View File

@ -2,15 +2,18 @@
nodaemon=true
[program:lldpd]
## -d: Do not daemonize. If this option is specified, lldpd will run in
## the foreground and log to stderr. This option can be specified
## many times to increase verbosity
command=/usr/sbin/lldpd -dd
## route stderr to the syslog service instead of being saved to files
stderr_logfile=syslog
# https://github.com/vincentbernat/lldpd/commit/9856f2792c301116cc4a3fcfba91b9672ee5db1f
# - `-d` means to stay in foreground, log to syslog
# - `-dd` means to stay in foreground, log warnings to console
# - `-ddd` means to stay in foreground, log warnings and info to console
# - `-dddd` means to stay in foreground, log all to console
command=/usr/sbin/lldpd -d -I Ethernet*,eth*
priority=100
[program:lldpsyncd]
command=/usr/sbin/lldpsyncd
priority=200
[program:rsyslogd]
command=/usr/sbin/rsyslogd -n
priority=1

View File

@ -0,0 +1,46 @@
FROM docker-base
COPY deps/snmp_*.deb deps/snmpd_*.deb deps/libsnmp-base_*.deb deps/libsnmp30_*.deb /deps/
COPY deps/python3/*.whl /python3/
# enable -O for all Python calls
ENV PYTHONOPTIMIZE 1
## Pre-install the fundamental packages
## Install Python SSWSDK (SNMP subagent dependency)
## Install SNMP subagent
## Note: dpkg_apt function has the benefit to detect missing .deb file
## Clean up
RUN apt-get update && \
dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } && \
dpkg_apt /deps/libsnmp-base_*.deb && \
dpkg_apt /deps/libsnmp30_*.deb && \
dpkg_apt /deps/snmp_*.deb && \
dpkg_apt /deps/snmpd_*.deb && \
rm -rf /deps
# install subagent
RUN apt-get -y install build-essential wget libssl-dev openssl supervisor && \
rm -rf /var/lib/apt/lists/* && \
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz && \
tar xvf Python-3.5.2.tgz && cd Python-3.5.2 && \
./configure --without-doc-strings --prefix=/usr --without-pymalloc --enable-shared && \
make && make install && \
ldconfig && \
cd .. && rm -rf Python-3.5.2 && rm Python-3.5.2.tgz && \
pip3 install --no-cache-dir /python3/*py3*.whl hiredis && \
rm -rf /python3 && \
python3 -m sonic_ax_impl install && \
python3 -m pip uninstall -y pip setuptools && \
/bin/bash -c "rm -rf /usr/lib/python3.5/{unittest,lib2to3,tkinter,idlelib,email,test}" && \
apt-get -y purge build-essential wget libssl-dev openssl && \
apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y && \
find / | grep -E "__pycache__" | xargs rm -rf && \
rm -rf ~/.cache
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
## 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"]

View File

@ -0,0 +1,14 @@
[supervisord]
nodaemon=true
[program:snmpd]
command=/usr/sbin/snmpd -f -LS4d -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf,ifTable,ifXTable -p /run/snmpd.pid
priority=100
[program:snmp-subagent]
command=/usr/bin/env python3 -m sonic_ax_impl
priority=200
[program:rsyslogd]
command=/usr/sbin/rsyslogd -n
priority=1

View File

@ -7,15 +7,16 @@ COPY deps/python3/*.whl /python3/
ENV PYTHONOPTIMIZE 1
## Pre-install the fundamental packages
## Install Python SSWSDK (SNMP subagent dependancy)
## Install Python SSWSDK (SNMP subagent dependency)
## Install SNMP subagent
## Note: dpkg_apt function has the benefit to detect missing .deb file
## Clean up
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } && \
RUN apt-get update && \
dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } && \
dpkg_apt /deps/libsnmp-base_*.deb && \
dpkg_apt /deps/libsnmp30_*.deb && \
dpkg_apt /deps/snmp_*.deb && \
dpkg_apt /deps/snmpd_*.deb && \
dpkg_apt /deps/snmpd_*.deb && \
rm -rf /deps
# install subagent
@ -29,13 +30,9 @@ RUN apt-get -y install build-essential wget libssl-dev openssl supervisor && \
cd .. && rm -rf Python-3.5.2 && rm Python-3.5.2.tgz && \
pip3 install --no-cache-dir /python3/*py3*.whl hiredis && \
rm -rf /python3 && \
python3 -m acs_ax_impl install && \
python3 -m pip uninstall -y pip setuptools && \
rm -rf /usr/lib/python3.5/unittest && \
rm -rf /usr/lib/python3.5/lib2to3 && \
rm -rf /usr/lib/python3.5/tkinter && \
rm -rf /usr/lib/python3.5/idlelib && \
rm -rf /usr/lib/python3.5/email && \
rm -rf /usr/lib/python3.5/test && \
/bin/bash -c "rm -rf /usr/lib/python3.5/{unittest,lib2to3,tkinter,idlelib,email,test}" && \
apt-get -y purge build-essential wget libssl-dev openssl && \
apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y && \
find / | grep -E "__pycache__" | xargs rm -rf && \

View File

@ -3,9 +3,12 @@ nodaemon=true
[program:snmpd]
command=/usr/sbin/snmpd -f -LS4d -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf,ifTable,ifXTable -p /run/snmpd.pid
priority=100
[program:acs-snmp-subagent]
command=/usr/bin/env python3 -m acs_ax_impl
priority=200
[program:rsyslogd]
command=/usr/sbin/rsyslogd -n
priority=1