Added: CLICON_CLI_AUTOCLI_EXCLUDE
Added openconfig interfaces tests
This commit is contained in:
parent
1f5e71512a
commit
f536b1dc67
11 changed files with 220 additions and 64 deletions
|
|
@ -42,6 +42,7 @@ Expected: April
|
||||||
* Changed: RPC process-control output to choice with status fields
|
* Changed: RPC process-control output to choice with status fields
|
||||||
* New clixon-config@2020-03-08.yang revision
|
* New clixon-config@2020-03-08.yang revision
|
||||||
* Added: `CLICON_NETCONF_HELLO_OPTIONAL`
|
* Added: `CLICON_NETCONF_HELLO_OPTIONAL`
|
||||||
|
* Added: `CLICON_CLI_AUTOCLI_EXCLUDE`
|
||||||
|
|
||||||
### C/CLI-API changes on existing features
|
### C/CLI-API changes on existing features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1014,11 +1014,20 @@ yang2cli(clicon_handle h,
|
||||||
yang_stmt *yc;
|
yang_stmt *yc;
|
||||||
cvec *globals; /* global variables from syntax */
|
cvec *globals; /* global variables from syntax */
|
||||||
genmodel_type gt;
|
genmodel_type gt;
|
||||||
|
char *excludelist;
|
||||||
|
char **exvec = NULL;
|
||||||
|
int nexvec = 0;
|
||||||
|
int e;
|
||||||
|
|
||||||
if (pt == NULL){
|
if (pt == NULL){
|
||||||
clicon_err(OE_YANG, EINVAL, "pt is NULL");
|
clicon_err(OE_YANG, EINVAL, "pt is NULL");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
/* List of modules that should not generate autocli */
|
||||||
|
if ((excludelist = clicon_option_str(h, "CLICON_CLI_AUTOCLI_EXCLUDE")) != NULL){
|
||||||
|
if ((exvec = clicon_strsep(excludelist, " \t", &nexvec)) == NULL)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
gt = clicon_cli_genmodel_type(h);
|
gt = clicon_cli_genmodel_type(h);
|
||||||
if ((cb = cbuf_new()) == NULL){
|
if ((cb = cbuf_new()) == NULL){
|
||||||
clicon_err(OE_XML, errno, "cbuf_new");
|
clicon_err(OE_XML, errno, "cbuf_new");
|
||||||
|
|
@ -1026,9 +1035,17 @@ yang2cli(clicon_handle h,
|
||||||
}
|
}
|
||||||
/* Traverse YANG, loop through all modules and generate CLI */
|
/* Traverse YANG, loop through all modules and generate CLI */
|
||||||
yc = NULL;
|
yc = NULL;
|
||||||
while ((yc = yn_each(yn, yc)) != NULL)
|
while ((yc = yn_each(yn, yc)) != NULL){
|
||||||
|
/* Check if module is in exclude list */
|
||||||
|
for (e = 0; e < nexvec; e++){
|
||||||
|
if (strcmp(yang_argument_get(yc), exvec[e]) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (e < nexvec)
|
||||||
|
continue;
|
||||||
if (yang2cli_stmt(h, yc, gt, 0, state, show_tree, cb) < 0)
|
if (yang2cli_stmt(h, yc, gt, 0, state, show_tree, cb) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
if (printgen)
|
if (printgen)
|
||||||
clicon_log(LOG_NOTICE, "%s: Generated CLI spec:\n%s", __FUNCTION__, cbuf_get(cb));
|
clicon_log(LOG_NOTICE, "%s: Generated CLI spec:\n%s", __FUNCTION__, cbuf_get(cb));
|
||||||
else
|
else
|
||||||
|
|
@ -1050,6 +1067,8 @@ yang2cli(clicon_handle h,
|
||||||
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
if (exvec)
|
||||||
|
free(exvec);
|
||||||
if (cb)
|
if (cb)
|
||||||
cbuf_free(cb);
|
cbuf_free(cb);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ module clixon-example {
|
||||||
namespace "urn:example:clixon";
|
namespace "urn:example:clixon";
|
||||||
prefix ex;
|
prefix ex;
|
||||||
import ietf-interfaces {
|
import ietf-interfaces {
|
||||||
|
/* is in yang/optional which means clixon must be installed using --opt-yang-installdir */
|
||||||
prefix if;
|
prefix if;
|
||||||
}
|
}
|
||||||
import ietf-ip {
|
import ietf-ip {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
<CLICON_BACKEND_PIDFILE>/usr/local/var/example/example.pidfile</CLICON_BACKEND_PIDFILE>
|
<CLICON_BACKEND_PIDFILE>/usr/local/var/example/example.pidfile</CLICON_BACKEND_PIDFILE>
|
||||||
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
|
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
|
||||||
<CLICON_CLI_GENMODEL_TYPE>VARS</CLICON_CLI_GENMODEL_TYPE>
|
<CLICON_CLI_GENMODEL_TYPE>VARS</CLICON_CLI_GENMODEL_TYPE>
|
||||||
|
<CLICON_CLI_AUTOCLI_EXCLUDE>clixon-restconf</CLICON_CLI_AUTOCLI_EXCLUDE>
|
||||||
<CLICON_XMLDB_DIR>/usr/local/var/example</CLICON_XMLDB_DIR>
|
<CLICON_XMLDB_DIR>/usr/local/var/example</CLICON_XMLDB_DIR>
|
||||||
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
|
<CLICON_CLI_LINESCROLLING>0</CLICON_CLI_LINESCROLLING>
|
||||||
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
|
<CLICON_STARTUP_MODE>init</CLICON_STARTUP_MODE>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,11 @@ automatically run as part of the all.sh, sum.sh tests etc. The scripts
|
||||||
need to follow some rules to work properly, please look at one or two
|
need to follow some rules to work properly, please look at one or two
|
||||||
to get the idea.
|
to get the idea.
|
||||||
|
|
||||||
|
Note that configure must ensure optional yangs be installed:
|
||||||
|
```
|
||||||
|
./configure --enable-optyangs
|
||||||
|
```
|
||||||
|
|
||||||
See also the [site.sh](#site-sh) for example for skipping tests or setting some site-specific variables.
|
See also the [site.sh](#site-sh) for example for skipping tests or setting some site-specific variables.
|
||||||
|
|
||||||
## Continuous Integration
|
## Continuous Integration
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
APPNAME=example
|
APPNAME=example
|
||||||
|
|
||||||
cfg=$dir/conf_yang.xml
|
cfg=$dir/conf_yang.xml
|
||||||
fyang=$dir/test.yang
|
|
||||||
|
|
||||||
new "openconfig"
|
new "openconfig"
|
||||||
if [ ! -d "$OPENCONFIG" ]; then
|
if [ ! -d "$OPENCONFIG" ]; then
|
||||||
|
|
@ -31,7 +30,6 @@ cat <<EOF > $cfg
|
||||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||||
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||||
<!--CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR-->
|
|
||||||
<CLICON_YANG_DIR>$OCDIR</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>$OCDIR</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_DIR>$OCDIR/acl</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>$OCDIR/acl</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_DIR>$OCDIR/aft</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>$OCDIR/aft</CLICON_YANG_DIR>
|
||||||
|
|
@ -69,7 +67,6 @@ cat <<EOF > $cfg
|
||||||
<CLICON_YANG_DIR>$OCDIR/wifi/mac</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>$OCDIR/wifi/mac</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_DIR>$OCDIR/wifi/phy</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>$OCDIR/wifi/phy</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_DIR>$OCDIR/wifi/types</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>$OCDIR/wifi/types</CLICON_YANG_DIR>
|
||||||
|
|
||||||
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
|
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
|
||||||
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
||||||
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
||||||
|
|
@ -80,7 +77,7 @@ cat <<EOF > $cfg
|
||||||
</clixon-config>
|
</clixon-config>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
files=$(find $OPENCONFIG -name "*.yang")
|
files=$(find $OCDIR -name "*.yang")
|
||||||
# Count nr of modules (exclude submodule) Assume "module" or "submodule"
|
# Count nr of modules (exclude submodule) Assume "module" or "submodule"
|
||||||
# first word on first line
|
# first word on first line
|
||||||
let ms=0; # Nr of modules
|
let ms=0; # Nr of modules
|
||||||
|
|
@ -112,53 +109,6 @@ for f in $files; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if false; then # NYI
|
|
||||||
|
|
||||||
# Example system
|
|
||||||
cat <<EOF > $dir/startup_db
|
|
||||||
<config>
|
|
||||||
<interfaces xmlns="http://openconfig.net/yang/interfaces">
|
|
||||||
<interface>
|
|
||||||
<name>eth0</name>
|
|
||||||
<config2>
|
|
||||||
<type>ianaift:usb</type>
|
|
||||||
</config2>
|
|
||||||
</interface>
|
|
||||||
</interfaces>
|
|
||||||
</config>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
|
||||||
new "kill old backend"
|
|
||||||
sudo clixon_backend -zf $cfg
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
err
|
|
||||||
fi
|
|
||||||
sudo pkill -f clixon_backend # to be sure
|
|
||||||
|
|
||||||
new "start backend -s startup -f $cfg -y openconfig-interfaces -p /usr/local/share/openconfig/public/release/models/interfaces"
|
|
||||||
start_backend -s startup -f $cfg -y /usr/local/share/openconfig/public/release/models/interfaces/openconfig-interfaces.yang
|
|
||||||
|
|
||||||
new "wait backend"
|
|
||||||
wait_backend
|
|
||||||
fi
|
|
||||||
|
|
||||||
new "$clixon_cli -D $DBG -1f $cfg -y $f show version"
|
|
||||||
expectpart "$($clixon_cli -D $DBG -1f $cfg -y $f show version)" 0 "${CLIXON_VERSION}"
|
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
|
||||||
new "Kill backend"
|
|
||||||
# Check if premature kill
|
|
||||||
pid=$(pgrep -u root -f clixon_backend)
|
|
||||||
if [ -z "$pid" ]; then
|
|
||||||
err "backend already dead"
|
|
||||||
fi
|
|
||||||
# kill backend
|
|
||||||
stop_backend -f $cfg
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
new "endtest"
|
new "endtest"
|
||||||
|
|
|
||||||
163
test/test_openconfig_interfaces.sh
Executable file
163
test/test_openconfig_interfaces.sh
Executable file
|
|
@ -0,0 +1,163 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Parse "all" openconfig yangs from https://github.com/openconfig/public
|
||||||
|
# Notes:
|
||||||
|
# Notes:
|
||||||
|
# - A simple smoketest (CLI check) is made, essentially YANG parsing.
|
||||||
|
# - A full system is worked on
|
||||||
|
# - Env-var OPENCONFIG should point to checkout place. (define it in site.sh for example)
|
||||||
|
# - Env variable YANGMODELS should point to checkout place. (define it in site.sh for example)
|
||||||
|
# - Some DIFFs are necessary in yangmodels
|
||||||
|
# release/models/wifi/openconfig-ap-interfaces.yang
|
||||||
|
|
||||||
|
# Magic line must be first in script (see README.md)
|
||||||
|
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
|
|
||||||
|
APPNAME=example
|
||||||
|
|
||||||
|
cfg=$dir/conf_yang.xml
|
||||||
|
fyang=$dir/clixon-example.yang
|
||||||
|
|
||||||
|
new "openconfig"
|
||||||
|
if [ ! -d "$OPENCONFIG" ]; then
|
||||||
|
# err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?"
|
||||||
|
echo "...skipped: OPENCONFIG not set"
|
||||||
|
if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
OCDIR=$OPENCONFIG/release/models
|
||||||
|
|
||||||
|
cat <<EOF > $cfg
|
||||||
|
<clixon-config xmlns="http://clicon.org/config">
|
||||||
|
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||||
|
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
|
||||||
|
<CLICON_YANG_DIR>$OPENCONFIG/third_party/ietf/</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/acl</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/aft</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/bfd</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/bgp</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/catalog</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/interfaces</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/isis</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/lacp</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/lldp</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/local-routing</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/macsec</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/mpls</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/multicast</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/network-instance</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/openflow</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/optical-transport</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/ospf</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/platform</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/policy</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/policy-forwarding</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/probes</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/qos</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/relay-agent</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/rib</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/segment-routing</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/stp</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/system</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/telemetry</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/types</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/vlan</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/wifi</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/wifi/access-points</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/wifi/ap-manager</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/wifi/mac</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/wifi/phy</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$OCDIR/wifi/types</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||||
|
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
|
||||||
|
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
||||||
|
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
||||||
|
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
||||||
|
<!--CLICON_CLI_AUTOCLI_EXCLUDE>clixon-restconf</CLICON_CLI_AUTOCLI_EXCLUDE-->
|
||||||
|
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||||
|
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
|
||||||
|
<CLICON_XMLDB_DIR>$dir</CLICON_XMLDB_DIR>
|
||||||
|
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
|
||||||
|
</clixon-config>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Example yang
|
||||||
|
cat <<EOF > $fyang
|
||||||
|
module clixon-example{
|
||||||
|
yang-version 1.1;
|
||||||
|
namespace "urn:example:example";
|
||||||
|
prefix ex;
|
||||||
|
|
||||||
|
import ietf-interfaces {
|
||||||
|
prefix ietf-if;
|
||||||
|
}
|
||||||
|
import openconfig-interfaces {
|
||||||
|
prefix oc-if;
|
||||||
|
}
|
||||||
|
identity eth { /* Need to create an interface-type identity for leafrefs */
|
||||||
|
base ietf-if:interface-type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Example system
|
||||||
|
cat <<EOF > $dir/startup_db
|
||||||
|
<config>
|
||||||
|
<interfaces xmlns="http://openconfig.net/yang/interfaces">
|
||||||
|
<interface>
|
||||||
|
<name>e</name>
|
||||||
|
<config>
|
||||||
|
<name>e</name>
|
||||||
|
<type>ex:eth</type>
|
||||||
|
<loopback-mode>false</loopback-mode>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</config>
|
||||||
|
<hold-time>
|
||||||
|
<config>
|
||||||
|
<up>0</up>
|
||||||
|
<down>0</down>
|
||||||
|
</config>
|
||||||
|
</hold-time>
|
||||||
|
</interface>
|
||||||
|
</interfaces>
|
||||||
|
</config>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ $BE -ne 0 ]; then
|
||||||
|
new "kill old backend"
|
||||||
|
sudo clixon_backend -zf $cfg
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
err
|
||||||
|
fi
|
||||||
|
sudo pkill -f clixon_backend # to be sure
|
||||||
|
|
||||||
|
new "start backend -s startup -f $cfg"
|
||||||
|
start_backend -s startup -f $cfg
|
||||||
|
|
||||||
|
new "wait backend"
|
||||||
|
wait_backend
|
||||||
|
fi
|
||||||
|
|
||||||
|
new "$clixon_cli -D $DBG -1f $cfg -y $f show version"
|
||||||
|
expectpart "$($clixon_cli -D $DBG -1f $cfg show version)" 0 "${CLIXON_VERSION}"
|
||||||
|
|
||||||
|
new "$clixon_netconf -qf $cfg"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><interfaces xmlns=\"http://openconfig.net/yang/interfaces\"><interface><name>e</name><config><name>e</name><type>ex:eth</type><loopback-mode>false</loopback-mode><enabled>true</enabled></config><hold-time><config><up>0</up><down>0</down></config></hold-time></interface></interfaces></data></rpc-reply>]]>]]>"
|
||||||
|
|
||||||
|
if [ $BE -ne 0 ]; then
|
||||||
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
@ -81,10 +81,10 @@ cat <<EOF > $fyang
|
||||||
module myexample{
|
module myexample{
|
||||||
yang-version 1.1;
|
yang-version 1.1;
|
||||||
namespace "urn:example:auth";
|
namespace "urn:example:auth";
|
||||||
|
prefix ex;
|
||||||
import ietf-netconf-acm {
|
import ietf-netconf-acm {
|
||||||
prefix nacm;
|
prefix nacm;
|
||||||
}
|
}
|
||||||
prefix ex;
|
|
||||||
container top {
|
container top {
|
||||||
leaf anonymous{
|
leaf anonymous{
|
||||||
type string;
|
type string;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
APPNAME=example
|
APPNAME=example
|
||||||
|
|
||||||
cfg=$dir/conf_yang.xml
|
cfg=$dir/conf_yang.xml
|
||||||
fyang=$dir/test.yang
|
|
||||||
|
|
||||||
if [ ! -d "$YANGMODELS" ]; then
|
if [ ! -d "$YANGMODELS" ]; then
|
||||||
# err "Hmm Yangmodels dir does not seem to exist, try git clone https://github.com/YangModels/yang?"
|
# err "Hmm Yangmodels dir does not seem to exist, try git clone https://github.com/YangModels/yang?"
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
APPNAME=example
|
APPNAME=example
|
||||||
|
|
||||||
cfg=$dir/conf_yang.xml
|
cfg=$dir/conf_yang.xml
|
||||||
fyang=$dir/test.yang
|
|
||||||
|
|
||||||
if [ ! -d "$YANGMODELS" ]; then
|
if [ ! -d "$YANGMODELS" ]; then
|
||||||
# err "Hmm Yangmodels dir does not seem to exist, try git clone https://github.com/YangModels/yang?"
|
# err "Hmm Yangmodels dir does not seem to exist, try git clone https://github.com/YangModels/yang?"
|
||||||
|
|
@ -49,6 +48,7 @@ cat <<EOF > $cfg
|
||||||
<CLICON_FEATURE>ietf-access-control-list:match-on-tcp</CLICON_FEATURE>
|
<CLICON_FEATURE>ietf-access-control-list:match-on-tcp</CLICON_FEATURE>
|
||||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/published/802.1</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/published/802.1</CLICON_YANG_DIR>
|
||||||
|
<CLICON_YANG_DIR>$YANGMODELS/standard/ietf/RFC</CLICON_YANG_DIR>
|
||||||
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
|
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
|
||||||
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
|
||||||
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
|
||||||
|
|
@ -59,9 +59,16 @@ cat <<EOF > $cfg
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Standard IETF
|
# Standard IETF
|
||||||
new "yangmodel Standard IETF: $YANGMODELS/standard/ietf/RFC"
|
files=$(find $YANGMODELS/standard/ietf/RFC -name "*.yang")
|
||||||
echo "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version"
|
for f in $files; do
|
||||||
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version)" 0 "${CLIXON_VERSION}"
|
if [ -n "$(head -1 $f|grep '^module')" ]; then
|
||||||
|
# Mask old revision
|
||||||
|
if [ $f != $YANGMODELS/standard/ietf/RFC/ietf-yang-types@2010-09-24.yang ]; then
|
||||||
|
new "$clixon_cli -D $DBG -1f $cfg -y $f show version"
|
||||||
|
expectpart "$($clixon_cli -D $DBG -1f $cfg -y $f show version)" 0 "${CLIXON_VERSION}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ module clixon-config {
|
||||||
revision 2021-03-08 {
|
revision 2021-03-08 {
|
||||||
description
|
description
|
||||||
"Added option:
|
"Added option:
|
||||||
CLICON_NETCONF_HELLO_OPTIONAL";
|
CLICON_NETCONF_HELLO_OPTIONAL;
|
||||||
|
CLICON_CLI_AUTOCLI_EXCLUDE";
|
||||||
}
|
}
|
||||||
revision 2020-12-30 {
|
revision 2020-12-30 {
|
||||||
description
|
description
|
||||||
|
|
@ -202,7 +203,7 @@ module clixon-config {
|
||||||
}
|
}
|
||||||
typedef cli_genmodel_type{
|
typedef cli_genmodel_type{
|
||||||
description
|
description
|
||||||
"How to generate CLI from YANG model,
|
"How to generate auto CLI from YANG model,
|
||||||
eg {container c {list a{ key x; leaf x; leaf y;}}";
|
eg {container c {list a{ key x; leaf x; leaf y;}}";
|
||||||
type enumeration{
|
type enumeration{
|
||||||
enum NONE{
|
enum NONE{
|
||||||
|
|
@ -525,7 +526,7 @@ module clixon-config {
|
||||||
type string;
|
type string;
|
||||||
default "datamodel";
|
default "datamodel";
|
||||||
description
|
description
|
||||||
"If CLICON_CLI_GENMOEL is set, CLI specs can reference the
|
"If CLICON_CLI_GENMODEL is set, CLI specs can reference the
|
||||||
model syntax using a model tree set by this option.
|
model syntax using a model tree set by this option.
|
||||||
Three trees are generated with this name as a base, (assuming base is datamodel):
|
Three trees are generated with this name as a base, (assuming base is datamodel):
|
||||||
- @datamodel - a clispec for navigating in editing a configuration (set/merge/delete)
|
- @datamodel - a clispec for navigating in editing a configuration (set/merge/delete)
|
||||||
|
|
@ -545,7 +546,16 @@ module clixon-config {
|
||||||
leaf CLICON_CLI_GENMODEL_TYPE {
|
leaf CLICON_CLI_GENMODEL_TYPE {
|
||||||
type cli_genmodel_type;
|
type cli_genmodel_type;
|
||||||
default "VARS";
|
default "VARS";
|
||||||
description "How to generate and show CLI syntax: VARS|ALL";
|
description "How to generate and show auto CLI syntax: VARS|ALL|HIDE";
|
||||||
|
}
|
||||||
|
leaf CLICON_CLI_AUTOCLI_EXCLUDE {
|
||||||
|
type string;
|
||||||
|
description
|
||||||
|
"List of module names that should not be generated autocli from
|
||||||
|
Example:
|
||||||
|
<CLICON_CLI_AUTOCLI_EXCLUDE>clixon-restconf</CLICON_CLI_AUTOCLI_EXCLUDE>
|
||||||
|
means generate autocli for all models except clixon-restconf.yang
|
||||||
|
The value can be a list of space separated module names";
|
||||||
}
|
}
|
||||||
leaf CLICON_CLI_VARONLY {
|
leaf CLICON_CLI_VARONLY {
|
||||||
type int32;
|
type int32;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue