SNMP MIB->YANG translation file handling.
Added configure option --with-mib-generated-yang-dir=DIR with default value /usr/share/mibyang where generated YANGs from MIBs should be placed so that SNMP tests know where to find the YANGs.
This commit is contained in:
parent
2699393c4a
commit
f112580546
7 changed files with 58 additions and 1 deletions
|
|
@ -43,6 +43,9 @@
|
||||||
* YANG `clixon-config@2022-03-21.yang` changes:
|
* YANG `clixon-config@2022-03-21.yang` changes:
|
||||||
* Added option:
|
* Added option:
|
||||||
* `CLICON_SNMP_AGENT_SOCK`
|
* `CLICON_SNMP_AGENT_SOCK`
|
||||||
|
* New configure options:
|
||||||
|
* `--enable-netsnmp`
|
||||||
|
* `--with-mib-generated-yang-dir=DIR`
|
||||||
* Thanks Siklu for sponshoring
|
* Thanks Siklu for sponshoring
|
||||||
|
|
||||||
## 5.8.0
|
## 5.8.0
|
||||||
|
|
|
||||||
24
configure
vendored
24
configure
vendored
|
|
@ -632,6 +632,7 @@ ac_ct_CXX
|
||||||
CXXFLAGS
|
CXXFLAGS
|
||||||
CXX
|
CXX
|
||||||
CPP
|
CPP
|
||||||
|
MIB_GENERATED_YANG_DIR
|
||||||
YANG_STANDARD_DIR
|
YANG_STANDARD_DIR
|
||||||
YANG_INSTALLDIR
|
YANG_INSTALLDIR
|
||||||
CLIXON_YANG_PATCH
|
CLIXON_YANG_PATCH
|
||||||
|
|
@ -724,6 +725,7 @@ with_restconf
|
||||||
enable_http1
|
enable_http1
|
||||||
enable_nghttp2
|
enable_nghttp2
|
||||||
enable_netsnmp
|
enable_netsnmp
|
||||||
|
with_mib_generated_yang_dir
|
||||||
with_configfile
|
with_configfile
|
||||||
with_libxml2
|
with_libxml2
|
||||||
with_sigaction
|
with_sigaction
|
||||||
|
|
@ -1387,6 +1389,9 @@ Optional Packages:
|
||||||
--with-restconf=fcgi FCGI interface for stand-alone web rev-proxy eg
|
--with-restconf=fcgi FCGI interface for stand-alone web rev-proxy eg
|
||||||
nginx
|
nginx
|
||||||
--without-restconf Disable restconf altogether
|
--without-restconf Disable restconf altogether
|
||||||
|
--with-mib-generated-yang-dir=DIR
|
||||||
|
Directory of generated YANG specs (default:
|
||||||
|
$prefix/share/mibyang)
|
||||||
--with-configfile=FILE Set default path to config file
|
--with-configfile=FILE Set default path to config file
|
||||||
--with-libxml2 Use gnome/libxml2 regex engine
|
--with-libxml2 Use gnome/libxml2 regex engine
|
||||||
--without-sigaction Don't use sigaction
|
--without-sigaction Don't use sigaction
|
||||||
|
|
@ -3400,6 +3405,8 @@ HAVE_HTTP1=false
|
||||||
|
|
||||||
# Examples require standard IETF YANGs. You need to provide these for example and tests
|
# Examples require standard IETF YANGs. You need to provide these for example and tests
|
||||||
|
|
||||||
|
# SNMP tests require generated YANGs from MIBs
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
ac_ext=c
|
ac_ext=c
|
||||||
|
|
@ -5429,6 +5436,23 @@ fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# MIB_GENERATED_YANG_DIR is where clixon assumes generated YANGs from MIBs are stored
|
||||||
|
# This is NOT installed by Clixon and is not needed for core system
|
||||||
|
# However, it is required by SNMP tests.
|
||||||
|
# To generate: for i in /usr/share/snmp/mibs/*; do smidump -f yang $i > `basename -s .txt $i`.yang; done
|
||||||
|
|
||||||
|
# Check whether --with-mib-generated-yang-dir was given.
|
||||||
|
if test "${with_mib_generated_yang_dir+set}" = set; then :
|
||||||
|
withval=$with_mib_generated_yang_dir; MIB_GENERATED_YANG_DIR="$withval"
|
||||||
|
else
|
||||||
|
MIB_GENERATED_YANG_DIR="${prefix}/share/mibyang"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Generated YANGs from MIB files are expected to be in ${MIB_GENERATED_YANG_DIR}" >&5
|
||||||
|
$as_echo "Generated YANGs from MIB files are expected to be in ${MIB_GENERATED_YANG_DIR}" >&6; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set default config file location
|
# Set default config file location
|
||||||
|
|
|
||||||
14
configure.ac
14
configure.ac
|
|
@ -124,6 +124,8 @@ AC_SUBST(CLIXON_YANG_PATCH)
|
||||||
AC_SUBST(YANG_INSTALLDIR)
|
AC_SUBST(YANG_INSTALLDIR)
|
||||||
# Examples require standard IETF YANGs. You need to provide these for example and tests
|
# Examples require standard IETF YANGs. You need to provide these for example and tests
|
||||||
AC_SUBST(YANG_STANDARD_DIR)
|
AC_SUBST(YANG_STANDARD_DIR)
|
||||||
|
# SNMP tests require generated YANGs from MIBs
|
||||||
|
AC_SUBST(MIB_GENERATED_YANG_DIR)
|
||||||
|
|
||||||
#
|
#
|
||||||
AC_PROG_CC()
|
AC_PROG_CC()
|
||||||
|
|
@ -293,6 +295,18 @@ if test "$enable_netsnmp" = "yes"; then
|
||||||
AC_CHECK_LIB(netsnmp, init_snmp)
|
AC_CHECK_LIB(netsnmp, init_snmp)
|
||||||
AC_CHECK_LIB(netsnmpagent, init_agent)
|
AC_CHECK_LIB(netsnmpagent, init_agent)
|
||||||
AC_CHECK_HEADERS(net-snmp/net-snmp-config.h,[], AC_MSG_ERROR([snmp is missing]))
|
AC_CHECK_HEADERS(net-snmp/net-snmp-config.h,[], AC_MSG_ERROR([snmp is missing]))
|
||||||
|
|
||||||
|
|
||||||
|
# MIB_GENERATED_YANG_DIR is where clixon assumes generated YANGs from MIBs are stored
|
||||||
|
# This is NOT installed by Clixon and is not needed for core system
|
||||||
|
# However, it is required by SNMP tests.
|
||||||
|
# To generate: for i in /usr/share/snmp/mibs/*; do smidump -f yang $i > `basename -s .txt $i`.yang; done
|
||||||
|
AC_ARG_WITH(mib-generated-yang-dir,
|
||||||
|
[AS_HELP_STRING([--with-mib-generated-yang-dir=DIR],[Directory of generated YANG specs (default: $prefix/share/mibyang)])],
|
||||||
|
[MIB_GENERATED_YANG_DIR="$withval"],
|
||||||
|
[MIB_GENERATED_YANG_DIR="${prefix}/share/mibyang"]
|
||||||
|
)
|
||||||
|
AC_MSG_RESULT(Generated YANGs from MIB files are expected to be in ${MIB_GENERATED_YANG_DIR})
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set default config file location
|
# Set default config file location
|
||||||
|
|
|
||||||
|
|
@ -790,7 +790,10 @@ yang_parse_str(char *str,
|
||||||
if (yang_scan_exit(&yy) < 0)
|
if (yang_scan_exit(&yy) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
ymod = yy.yy_module;
|
if ((ymod = yy.yy_module) == NULL){
|
||||||
|
clicon_err(OE_YANG, 0, "No module in YANG %s", name);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/* Add filename for debugging and errors, see also ys_linenum on (each symbol?) */
|
/* Add filename for debugging and errors, see also ys_linenum on (each symbol?) */
|
||||||
if (yang_filename_set(ymod, name) < 0)
|
if (yang_filename_set(ymod, name) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -95,3 +95,4 @@ YANG_STANDARD_DIR=@YANG_STANDARD_DIR@
|
||||||
|
|
||||||
YANG_INSTALLDIR=@YANG_INSTALLDIR@
|
YANG_INSTALLDIR=@YANG_INSTALLDIR@
|
||||||
|
|
||||||
|
MIB_GENERATED_YANG_DIR=@MIB_GENERATED_YANG_DIR@
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ cat <<EOF > $cfg
|
||||||
<clixon-config xmlns="http://clicon.org/config">
|
<clixon-config xmlns="http://clicon.org/config">
|
||||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||||
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>${YANG_STANDARD_DIR}</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>${MIB_GENERATED_YANG_DIR}</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||||
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
|
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
|
||||||
<CLICON_BACKEND_PIDFILE>/var/tmp/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
<CLICON_BACKEND_PIDFILE>/var/tmp/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||||
|
|
@ -37,6 +39,9 @@ module clixon-example{
|
||||||
yang-version 1.1;
|
yang-version 1.1;
|
||||||
namespace "urn:example:clixon";
|
namespace "urn:example:clixon";
|
||||||
prefix ex;
|
prefix ex;
|
||||||
|
import NET-SNMP-EXAMPLES-MIB {
|
||||||
|
prefix "net-snmp-examples";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
@ -59,6 +64,7 @@ function testinit(){
|
||||||
err "Failed to start snmpd"
|
err "Failed to start snmpd"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
new "test params: -f $cfg"
|
||||||
# Kill old backend and start a new one
|
# Kill old backend and start a new one
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
sudo clixon_backend -zf $cfg
|
sudo clixon_backend -zf $cfg
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ cat <<EOF > $cfg
|
||||||
<clixon-config xmlns="http://clicon.org/config">
|
<clixon-config xmlns="http://clicon.org/config">
|
||||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||||
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>${YANG_STANDARD_DIR}</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>${MIB_GENERATED_YANG_DIR}</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||||
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
|
<CLICON_SOCK>$dir/$APPNAME.sock</CLICON_SOCK>
|
||||||
<CLICON_BACKEND_PIDFILE>/var/tmp/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
<CLICON_BACKEND_PIDFILE>/var/tmp/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||||
|
|
@ -47,6 +49,9 @@ module clixon-example{
|
||||||
yang-version 1.1;
|
yang-version 1.1;
|
||||||
namespace "urn:example:clixon";
|
namespace "urn:example:clixon";
|
||||||
prefix ex;
|
prefix ex;
|
||||||
|
import NET-SNMP-EXAMPLES-MIB {
|
||||||
|
prefix "net-snmp-examples";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
@ -69,6 +74,7 @@ function testinit(){
|
||||||
err "Failed to start snmpd"
|
err "Failed to start snmpd"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
new "test params: -f $cfg"
|
||||||
# Kill old backend and start a new one
|
# Kill old backend and start a new one
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
sudo clixon_backend -zf $cfg
|
sudo clixon_backend -zf $cfg
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue