Refactor patches for net-snmp package

Use net-snmp-config package to package script and service file for
net-snmp package.
Removed servcie/config/script related patches and let net-snmp-config
package be responsible for it.
Keep another meta patch for build configuration related changes.

Deployment test and ping test between VMs pass
Config,serivce and script files check pass.

Story: 2003768
Task: 27586
Depends-on: https://review.openstack.org/#/c/616097

Change-Id: Ic64543447d04543fdf9eafdc3d9ae4e2521c10df
Signed-off-by: zhipengl <zhipengs.liu@intel.com>
This commit is contained in:
zhipengl 2018-11-07 23:47:34 +08:00 committed by zhipeng liu
parent 984cb5932f
commit 2fa06f04f9
6 changed files with 187 additions and 0 deletions

View File

@ -0,0 +1,2 @@
SRC_DIR="files"
TIS_PATCH_VER=0

View File

@ -0,0 +1,48 @@
Summary: net-snmp-config
Name: net-snmp-config
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: StarlingX
URL: unknown
BuildArch: noarch
Source: %name-%version.tar.gz
Requires: net-snmp
Summary: package StarlingX configuration files of net-snmp to system folder.
%description
package StarlingX configuration files of net-snmp to system folder.
%prep
%setup
%build
%install
%{__install} -d %{buildroot}%{_datadir}/starlingx
%{__install} -d %{buildroot}%{_datadir}/snmp
%{__install} -d %{buildroot}%{_initrddir}
%{__install} -d %{buildroot}%{_sysconfdir}/systemd/system
%{__install} -m 644 stx.snmpd.conf %{buildroot}%{_datadir}/starlingx/stx.snmpd.conf
%{__install} -m 755 stx.snmpd %{buildroot}%{_initddir}/snmpd
%{__install} -m 660 stx.snmp.conf %{buildroot}%{_datadir}/snmp/snmp.conf
%{__install} -m 644 snmpd.service %{buildroot}%{_sysconfdir}/systemd/system/snmpd.service
%post
if [ $1 -eq 1 ] ; then
# Initial installation
cp -f %{_datadir}/starlingx/stx.snmpd.conf %{_sysconfdir}/snmp/snmpd.conf
chmod 640 %{_sysconfdir}/snmp/snmpd.conf
chmod 640 %{_sysconfdir}/snmp/snmptrapd.conf
fi
%{_bindir}/systemctl disable snmpd.service
%files
%{_datadir}/starlingx/stx.snmpd.conf
%{_initddir}/snmpd
%config(noreplace) %attr(0660,snmpd,snmpd) %{_datadir}/snmp/snmp.conf
%{_sysconfdir}/systemd/system/snmpd.service

View File

@ -0,0 +1,14 @@
[Unit]
Description=Simple Network Management Protocol (SNMP) Daemon.
After=syslog.target network.target
[Service]
Type=notify
Environment=OPTIONS="oamcontroller -u snmpd -Lsd -Lf /dev/null -p /var/run/snmpd.pid"
EnvironmentFile=-/etc/sysconfig/snmpd
ExecStart=/etc/init.d/snmpd start
ExecStop=/etc/init.d/snmpd stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,4 @@
# Configuration file for the Net-SNMP applications
# Specifies the source address to be used by snmptrap application when sending SNMP traps
clientaddr oamcontroller

View File

@ -0,0 +1,95 @@
#! /bin/sh
# /etc/init.d/snmpd: start snmp daemon.
. /etc/init.d/functions
# Linux Standard Base (LSB) Error Codes
RETVAL=0
GENERIC_ERROR=1
INVALID_ARGS=2
NOT_RUNNING=3
NOT_INSTALLED=5
#set environment variables
export SNMPCONFPATH=/etc/snmp
export MIBDIRS=/usr/share/snmp/mibs
SNMPDOPTS='oamcontroller -u snmpd -LS6d -Lf /dev/null -p /var/run/snmpd.pid'
PIDFILE=/var/run/snmpd.pid
SNMPTRAPDCONFIG=${SNMPCONFPATH}/snmpdtrapd.conf
SNMPDCONFIG=${SNMPCONFPATH}/snmpd.conf
SNMPDNAME=snmpd
SNMPD="/usr/sbin/${SNMPDNAME}"
test -x ${SNMPD} || exit ${NOT_INSTALLED}
# Reads config file (will override defaults above)
[ -r /etc/default/snmpd ] && . /etc/default/snmpd
case "$1" in
start)
echo -n "Starting network management services: "
status ${SNMPD} >/dev/null
if [ $? -eq 0 ]; then
echo -n "is already running "
RETVAL=0
elif [ -f ${SNMPDCONFIG} ]; then
start-stop-daemon -o --start --quiet --name ${SNMPDNAME} --pidfile "$PIDFILE" \
--exec ${SNMPD} -- ${SNMPDOPTS}
RETVAL=$?
else
logger "${SNMPDCONFIG} is missing"
RETVAL=${GENERIC_ERROR}
fi
if [ ${RETVAL} -eq 0 ] ; then
pid=`pidof ${SNMPDNAME}`
echo "OK"
logger "${SNMPDNAME} (${pid})"
else
echo "FAIL"
RETVAL=${GENERIC_ERROR}
fi
;;
stop)
status ${SNMPD} >/dev/null
if [ $? -ne 0 ]; then
echo "$SNMPDNAME is not running"
RETVAL=0
else
echo -n "Stopping network management services "
killproc ${SNMPDNAME}
if [ -n "`pidof ${SNMPDNAME}`" ] ; then
logger "Going to SIGKILL ${SNMPDNAME}"
killproc -KILL ${SNMPDNAME}
fi
/bin/rm -rf $PIDFILE
status ${SNMPD} >/dev/null
if [ $? -ne 0 ]; then
echo "Stopped"
RETVAL=0
else
echo "Failed"
RETVAL=${GENERIC_ERROR}
fi
fi
;;
status)
status ${SNMPD} >/dev/null
RETVAL=$?
if [ ! ${RETVAL} -eq 0 ] ; then
RETVAL=${NOT_RUNNING}
fi
;;
restart|reload|force-reload)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: /etc/init.d/snmpd {start|stop|status|restart|reload|force-reload}"
exit ${GENERIC_ERROR}
esac
exit $RETVAL

View File

@ -0,0 +1,24 @@
###########################################################################
#
# snmpd.conf
#
# - created by the snmpconf configuration program
#
###########################################################################
# incl/excl subtree mask
view all included .1 80
sysDescr ?
sysObjectID 1.3.6.1.4.1.731.3
sysContact ?
sysName ?
sysLocation ?
sysServices 72
[snmp] clientaddr oamcontroller
dlmod cgtsAgentPlugin /usr/lib64/libcgtsAgentPlugin.so.1
dlmod snmpAuditPlugin /usr/lib64/libsnmpAuditPlugin.so.1
# Insert the snmpAudit hander into specific sections of the mib tree
injectHandler snmpAudit null
injectHandler snmpAudit bulk_to_next