Merge branch 'snmp'

This commit is contained in:
Olof hagsand 2022-07-15 15:54:44 +02:00
commit 1d78241115
47 changed files with 8494 additions and 46 deletions

View file

@ -39,6 +39,9 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
# For clixon and cligen
RUN apk add --update git make build-base gcc flex bison curl-dev
# For netsnmp
RUN apk add --update net-snmp net-snmp-dev
WORKDIR /usr/local/share
# Checkout standard YANG models for tests (note >1G for full repo)
@ -76,7 +79,7 @@ WORKDIR /clixon/clixon
COPY clixon .
# Configure, build and install clixon
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --without-restconf --with-yang-standard-dir=/usr/local/share/yang/standard
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --without-restconf --with-yang-standard-dir=/usr/local/share/yang/standard --enable-netsnmp --with-mib-generated-yang-dir=/usr/local/share/mib-yangs/
RUN make
RUN make install
@ -103,6 +106,9 @@ WORKDIR /clixon
COPY startsystem.sh startsystem.sh
RUN install startsystem.sh /clixon/build/bin/
# Add our generated YANG files
RUN git clone https://github.com/clicon/mib-yangs.git /usr/local/share/mib-yangs
#
# Stage 2
# The second step skips the development environment and builds a runtime system
@ -112,6 +118,16 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
# For clixon and cligen
RUN apk add --update flex bison fcgi-dev
# For SNMP
RUN apk add --update net-snmp net-snmp-tools
# Some custom configuration for SNMP
RUN echo "master agentx" > /etc/snmp/snmpd.conf
RUN echo "agentaddress 127.0.0.1" >> /etc/snmp/snmpd.conf
RUN echo "rwcommunity public localhost" >> /etc/snmp/snmpd.conf
RUN echo "agentXSocket unix:/var/run/snmp.sock" >> /etc/snmp/snmpd.conf
RUN echo "agentxperms 777 777" >> /etc/snmp/snmpd.conf
# Test-specific (for test scripts)
RUN apk add --update sudo curl procps grep make bash expect
@ -120,6 +136,7 @@ RUN adduser -D -H clicon
COPY --from=0 /clixon/build/ /usr/local/
COPY --from=0 /usr/local/share/yang/* /usr/local/share/yang/standard/
COPY --from=0 /usr/local/share/mib-yangs/* /usr/local/share/mib-yangs/
# Log to stderr.
CMD /usr/local/bin/startsystem.sh

View file

@ -38,6 +38,9 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
# For clixon and cligen
RUN apk add --update git make build-base gcc flex bison fcgi-dev curl-dev
# For netsnmp
RUN apk add --update net-snmp net-snmp-dev
# Checkut standard YANG models for tests (note >1G for full repo)
WORKDIR /usr/local/share
RUN mkdir yang
@ -77,7 +80,7 @@ RUN adduser -D -H -G www-data www-data
RUN apk add --update nginx
# Configure, build and install clixon
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-restconf=fcgi --with-yang-standard-dir=/usr/local/share/yang/standard
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-restconf=fcgi --with-yang-standard-dir=/usr/local/share/yang/standard --enable-netsnmp --with-mib-generated-yang-dir=/usr/local/share/mib-yangs/
RUN make
RUN make install
@ -104,6 +107,9 @@ WORKDIR /clixon
COPY startsystem_fcgi.sh startsystem.sh
RUN install startsystem.sh /clixon/build/bin/
# Add our generated YANG files
RUN git clone https://github.com/clicon/mib-yangs.git /usr/local/share/mib-yangs
#
# Stage 2
# The second step skips the development environment and builds a runtime system
@ -113,6 +119,16 @@ MAINTAINER Olof Hagsand <olof@hagsand.se>
# For clixon and cligen
RUN apk add --update flex bison fcgi-dev
# For SNMP
RUN apk add --update net-snmp net-snmp-tools
# Some custom configuration for SNMP
RUN echo "master agentx" > /etc/snmp/snmpd.conf
RUN echo "agentaddress 127.0.0.1" >> /etc/snmp/snmpd.conf
RUN echo "rwcommunity public localhost" >> /etc/snmp/snmpd.conf
RUN echo "agentXSocket unix:/var/run/snmp.sock" >> /etc/snmp/snmpd.conf
RUN echo "agentxperms 777 777" >> /etc/snmp/snmpd.conf
# Need to add www user manually, but group www-data already exists on Alpine
RUN adduser -D -H -G www-data www-data
# nginx adds group www-data
@ -131,6 +147,7 @@ RUN adduser www-data clicon
COPY --from=0 /clixon/build/ /usr/local/
COPY --from=0 /usr/local/share/yang/* /usr/local/share/yang/standard/
COPY --from=0 /usr/local/share/mib-yangs/* /usr/local/share/mib-yangs/
# Manually created
RUN mkdir /www-data

View file

@ -41,6 +41,9 @@ RUN apk add --update git make build-base gcc flex bison curl-dev
# nghttp2 dependencies
RUN apk add --update nghttp2
# For netsnmp
RUN apk add --update net-snmp net-snmp-dev
# Checkut models
WORKDIR /usr/local/share/
@ -88,7 +91,7 @@ WORKDIR /clixon/clixon
COPY clixon .
# Configure, build and install clixon
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-restconf=native --enable-nghttp2 --enable-http1 --with-yang-standard-dir=/usr/local/share/yang/standard
RUN ./configure --prefix=/clixon/build --with-cligen=/clixon/build --with-restconf=native --enable-nghttp2 --enable-http1 --with-yang-standard-dir=/usr/local/share/yang/standard --enable-netsnmp --with-mib-generated-yang-dir=/usr/local/share/mib-yangs/
RUN make
RUN make install
@ -111,11 +114,17 @@ RUN install *.sh /clixon/build/bin/test
RUN install *.exp /clixon/build/bin/test
RUN install clixon.png /clixon/build/bin/test
RUN install -d /clixon/build/mibs
RUN install mibs/* /clixon/build/mibs
# Copy startscript
WORKDIR /clixon
COPY startsystem_native.sh startsystem.sh
RUN install startsystem.sh /clixon/build/bin/
# Add our generated YANG files
RUN git clone https://github.com/clicon/mib-yangs.git /usr/local/share/mib-yangs
#
# Stage 2
# The second step skips the development environment and builds a runtime system
@ -136,6 +145,16 @@ RUN apk add --update nghttp2
# Test-specific (for test scripts)
RUN apk add --update sudo curl procps grep make bash expect
# For SNMP
RUN apk add --update net-snmp net-snmp-tools
# Some custom configuration for SNMP
RUN echo "master agentx" > /etc/snmp/snmpd.conf
RUN echo "agentaddress 127.0.0.1" >> /etc/snmp/snmpd.conf
RUN echo "rwcommunity public localhost" >> /etc/snmp/snmpd.conf
RUN echo "agentXSocket unix:/var/run/snmp.sock" >> /etc/snmp/snmpd.conf
RUN echo "agentxperms 777 777" >> /etc/snmp/snmpd.conf
# Expose https port for restconf
EXPOSE 80/tcp
EXPOSE 443/tcp
@ -147,6 +166,8 @@ COPY --from=0 /clixon/build/ /usr/local/
COPY --from=0 /usr/local/share/yang/* /usr/local/share/yang/standard/
COPY --from=0 /usr/local/share/yang/* /usr/local/share/yang/experimental/
COPY --from=0 /usr/local/share/openconfig/* /usr/local/share/openconfig/
COPY --from=0 /usr/local/share/mib-yangs/* /usr/local/share/mib-yangs/
COPY --from=0 /clixon/build/mibs/* /usr/share/snmp/mibs/
# Start the backend and restconf deamons
CMD /usr/local/bin/startsystem.sh

View file

@ -82,6 +82,10 @@ chmod 775 /usr/local/bin/test/site.sh
/usr/local/sbin/clixon_backend -D $DBG -s running -l e # logs on docker logs
>&2 echo "clixon_backend started"
# Start snmpd, we need this for the SNMP tests and the app clixon_snmp. Log to stdout, then we can
# use Docker logs to see what's happening.
snmpd -Lo -p /var/run/snmpd.pid -I -ifXTable -I -ifTable -I -system_mib -I -sysORTable -I -snmpNotifyFilterTable -I -snmpNotifyTable -I -snmpNotifyFilterProfileTable
# Alt: let backend be in foreground, but test scripts may
# want to restart backend
/bin/sleep 100000000

View file

@ -130,6 +130,10 @@ chmod g+w /www-data/fastcgi_restconf.sock
/usr/local/sbin/clixon_backend -D $DBG -s running -l e # logs on docker logs
>&2 echo "clixon_backend started"
# Start snmpd, we need this for the SNMP tests and the app clixon_snmp. Log to stdout, then we can
# use Docker logs to see what's happening.
snmpd -Lo -p /var/run/snmpd.pid -I -ifXTable -I -ifTable -I -system_mib -I -sysORTable -I -snmpNotifyFilterTable -I -snmpNotifyTable -I -snmpNotifyFilterProfileTable
# Alt: let backend be in foreground, but test scripts may
# want to restart backend
/bin/sleep 100000000

View file

@ -125,6 +125,12 @@ openssl req -x509 -config ./ca.cnf -nodes -newkey rsa:4096 -keyout /etc/ssl/priv
/usr/local/sbin/clixon_backend -D $DBG -s running -l e # logs on docker logs
>&2 echo "clixon_backend started"
# Start snmpd, we need this for the SNMP tests and the app clixon_snmp. Log to stdout, then we can
# use Docker logs to see what's happening.
snmpd -Lo -p /var/run/snmpd.pid -I -ifXTable -I -ifTable -I -system_mib -I -sysORTable -I -snmpNotifyFilterTable -I -snmpNotifyTable -I -snmpNotifyFilterProfileTable
sleep 3
# Alt: let backend be in foreground, but test scripts may
# want to restart backend
/bin/sleep 100000000