Add stx-fm-subagent docker image

This change reorganizes the source directories of the stx-fm-subagent
container to be reused by both CentOS and Debian Dockerfiles in order
to build the images having the corresponding OS-specic base.

The files Dockerfile.debian for stx-snmp and stx-fm-trap-subagent have
been added with no content in order to work on them on different
reviews.

Test plan:

PASS: Debian - Build Debian docker image and upload/apply snmp-app changing
the stx-fm-subagent references to point to the new image. Verified
that the app is applied, and the container is created.
PASS: Verified common snmp scenarios:
 - test snmpwalk for 2c and 3 snmp version
 - test snmpget for 2c and 3 snmp version
 - verified traps are working as expected.

PASS: CentOS - Same tests have been done building a CentOS container.

Story: 2009831
Task: 45730

Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com>
Change-Id: Idfb46224429061f11493c111588b542cf809b79f
This commit is contained in:
Enzo Candotti 2022-07-27 18:36:20 -03:00
parent fabbdda698
commit 90a317189a
31 changed files with 73 additions and 13 deletions

View File

@ -0,0 +1 @@
stx-snmp-helm

View File

@ -1,3 +1,4 @@
BUILDER=docker
LABEL=stx-fm-subagent
DOCKER_CONTEXT=docker/stx-fm-subagent
DOCKER_CONTEXT=../docker/stx-fm-subagent
DOCKER_FILE=../docker/stx-fm-subagent/Dockerfile.centos

View File

@ -1,3 +1,4 @@
BUILDER=docker
LABEL=stx-fm-trap-subagent
DOCKER_CONTEXT=docker/stx-fm-trap-subagent
DOCKER_CONTEXT=../docker/stx-fm-trap-subagent
DOCKER_FILE=../docker/stx-fm-trap-subagent/Dockerfile.centos

View File

@ -1,3 +1,4 @@
BUILDER=docker
LABEL=stx-snmp
DOCKER_CONTEXT=docker/stx-snmp
DOCKER_CONTEXT=../docker/stx-snmp
DOCKER_FILE=../docker/stx-snmp/Dockerfile.centos

View File

@ -0,0 +1,4 @@
BUILDER=docker
LABEL=stx-fm-subagent
DOCKER_CONTEXT=../docker/stx-fm-subagent
DOCKER_FILE=../docker/stx-fm-subagent/Dockerfile.debian

View File

@ -0,0 +1,4 @@
BUILDER=docker
LABEL=stx-fm-trap-subagent
DOCKER_CONTEXT=../docker/stx-fm-trap-subagent
DOCKER_FILE=../docker/stx-fm-trap-subagent/Dockerfile.debian

View File

@ -0,0 +1,4 @@
BUILDER=docker
LABEL=stx-snmp
DOCKER_CONTEXT=../docker/stx-snmp
DOCKER_FILE=../docker/stx-snmp/Dockerfile.debian

View File

@ -33,6 +33,7 @@ COPY Makefile .
COPY ./src/* ./src/
COPY --from=stx /usr/include/fmDbAPI.h /usr/include/
COPY --from=stx /usr/include/fmAPI.h /usr/include/
ENV LIB_DIR=/usr/lib64/
RUN make

View File

@ -0,0 +1,41 @@
ARG BASE
FROM ${BASE} AS stx
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -y update
RUN apt-get -y install\
fm-common \
fm-common-dev
FROM debian AS base
RUN apt-get -y update
RUN apt-get -y install\
snmp snmpd snmptrapd \
libpython2.7 \
python3 python3-dev python3-setuptools python-is-python3 \
postgresql-13 \
libsnmp-dev \
libjson-c-dev \
gcc \
make \
uuid-dev
WORKDIR /home/sub-agent
COPY --from=stx /usr/lib/libfmcommon.so.1.0 /usr/lib/
RUN ln -s /usr/lib/libfmcommon.so.1.0 /usr/lib/libfmcommon.so
RUN ln -s /usr/lib/libfmcommon.so.1.0 /usr/lib/libfmcommon.so.1
RUN ln -s /usr/lib/libuuid.so.1.3.0 /usr/lib/libuuid.so
COPY Makefile .
COPY ./src/* ./src/
COPY --from=stx /usr/include/fmDbAPI.h /usr/include/
COPY --from=stx /usr/include/fmAPI.h /usr/include/
ENV LIB_DIR=/usr/lib/
RUN make
FROM base AS deployment-env
COPY --from=base /home/sub-agent/snmpSubAgent .
COPY bootstrap.sh .
RUN chmod 755 bootstrap.sh
ENTRYPOINT ["./bootstrap.sh"]

View File

@ -10,13 +10,15 @@ MIBVER ?= 2.0
CC=gcc
DEST_DIR ?= /
DATA_DIR ?= /usr/share
LIB_DIR ?= /usr/lib64
# LIB_DIR = /usr/lib for Debian
# LIB_DIR = /usr/lib64 for CentOS
BIN=./bin
SOURCE=./src
SRCS = $(SOURCE)/snmpSubAgent.c $(SOURCE)/snmpActiveAlarms.c $(SOURCE)/snmpAgentPlugin.c $(SOURCE)/snmpEventLogs.c
OBJS = $(SRCS:.c=.o)
LDLIBS = -L/lib/x86_64-linux-gnu/ -L/usr/lib64 -lfmcommon -lnetsnmp
LDLIBS = -L/lib/x86_64-linux-gnu/ -L$(LIB_DIR) -lfmcommon -lnetsnmp
LDLIBS += -lnetsnmpagent -luuid -lnetsnmpmibs -lnetsnmphelpers
INCLUDES += -I./ -I/include/net-snmp -I$(SOURCE) -I/usr/include/

View File

@ -17,11 +17,11 @@
#include <fmDbAPI.h>
#include "snmpAgentPlugin.h"
netsnmp_feature_require(date_n_time)
#define MINLOADFREQ 1 /* min reload frequency in seconds */
netsnmp_feature_require(date_n_time);
static long Active_Alarm_Count = 0;
static struct activealarm *alarm_list;
static struct activealarm *alarmaddr, savealarm, *savealarmaddr;

View File

@ -17,11 +17,11 @@
#include <fmDbAPI.h>
#include "snmpAgentPlugin.h"
netsnmp_feature_require(date_n_time)
#define MINLOADFREQ 2 /* min reload frequency in seconds */
netsnmp_feature_require(date_n_time);
static long Event_Log_Count = 0;
static struct activealarm *alarm_list;
static struct activealarm *alarmaddr, savealarm, *savealarmaddr;

View File

@ -24,8 +24,8 @@
* --with-features="agent_check_and_process enable_stderrlog" to your
* configure line.
*/
netsnmp_feature_require(agent_check_and_process)
netsnmp_feature_require(enable_stderrlog)
netsnmp_feature_require(agent_check_and_process);
netsnmp_feature_require(enable_stderrlog);
static int keep_running;