* Instead of always loading it, load it to datastore YANGs only if `CLICON_BACKEND_RESTCONF_PROCESS` is `true`
*
This commit is contained in:
Olof hagsand 2022-03-29 17:24:03 +02:00
parent 8ce1917020
commit 3d648bc08f
8 changed files with 18 additions and 26 deletions

View file

@ -64,8 +64,10 @@ Users may have to change how they access the system
### Minor features ### Minor features
* [prevent clixon-restconf@2021-05-20.yang module from loading](https://github.com/clicon/clixon/issues/318)
* Instead of always loading it, load it to datastore YANGs only if `CLICON_BACKEND_RESTCONF_PROCESS` is `true`
* YANG unique: added single descendant node ids as special case * YANG unique: added single descendant node ids as special case
c * This means that two variants are supported: * This means that two variants are supported:
* unique "a b c", ie multiple direct children * unique "a b c", ie multiple direct children
* unique "a/b/c", ie single descendants * unique "a/b/c", ie single descendants
* RFC 7950 Sec 7.8.3 is somewhat unclear * RFC 7950 Sec 7.8.3 is somewhat unclear

View file

@ -52,7 +52,7 @@
*/ */
#define CLIXON_CONF_NS "http://clicon.org/config" #define CLIXON_CONF_NS "http://clicon.org/config"
#define CLIXON_LIB_NS "http://clicon.org/lib" #define CLIXON_LIB_NS "http://clicon.org/lib"
#define CLIXON_AUTOCLI_NS "http://clicon.org/autocli" #define CLIXON_AUTOCLI_NS "http://clicon.org/autocli"
#define CLIXON_RESTCONF_NS "http://clicon.org/restconf" #define CLIXON_RESTCONF_NS "http://clicon.org/restconf"
/* /*

View file

@ -1483,7 +1483,6 @@ netconf_module_features(clicon_handle h)
return retval; return retval;
} }
/*! Load generic yang specs, ie ietf netconf yang module and set enabled features /*! Load generic yang specs, ie ietf netconf yang module and set enabled features
* @param[in] h Clixon handle * @param[in] h Clixon handle
* @retval 0 OK * @retval 0 OK
@ -1512,9 +1511,10 @@ netconf_module_load(clicon_handle h)
if (clicon_option_bool(h, "CLICON_XML_CHANGELOG")) if (clicon_option_bool(h, "CLICON_XML_CHANGELOG"))
if (yang_spec_parse_module(h, "clixon-xml-changelog", NULL, yspec)< 0) if (yang_spec_parse_module(h, "clixon-xml-changelog", NULL, yspec)< 0)
goto done; goto done;
/* Load restconf yang. Note this is also a part of clixon-config */ /* Load restconf yang to data. Note clixon-restconf.yang is always part of clixon-config */
if (yang_spec_parse_module(h, "clixon-restconf", NULL, yspec)< 0) if (clicon_option_bool(h, "CLICON_BACKEND_RESTCONF_PROCESS"))
goto done; if (yang_spec_parse_module(h, "clixon-restconf", NULL, yspec)< 0)
goto done;
/* XXX: Both the following settings are because clicon-handle is not part of all API /* XXX: Both the following settings are because clicon-handle is not part of all API
* functions * functions
* Treat unknown XML as anydata */ * Treat unknown XML as anydata */

View file

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Turn on debug on backend/cli/restconf/netconf # Turn on debug on backend/cli/netconf
# Note, restconf debug used to be tested but is no longer tested here,
# maybe in test_restconf_internal?
# Magic line must be first in script (see README.md) # Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
@ -79,30 +81,15 @@ wait_restconf
new "Set backend debug using netconf" new "Set backend debug using netconf"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><debug $LIBNS><level>1</level></debug></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><debug $LIBNS><level>1</level></debug></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "Set backend debug using restconf"
expectpart "$(curl $CURLOPTS -X POST -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/operations/clixon-lib:debug -d '{"clixon-lib:input":{"level":1}}')" 0 "HTTP/$HVER 204"
new "Set restconf debug using netconf"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><restconf $RESTCONFNS><debug>1</debug></restconf></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf commit"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><commit/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "Set restconf debug using restconf"
expectpart "$(curl $CURLOPTS -X PUT -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/clixon-restconf:restconf/debug -d '{"clixon-restconf:debug":1}')" 0 "HTTP/$HVER 204"
new "Set cli debug using cli" new "Set cli debug using cli"
expectpart "$($clixon_cli -1 -f $cfg -l o debug cli 1)" 0 "^$" expectpart "$($clixon_cli -1 -f $cfg -l o debug cli 1)" 0 "^$"
new "Set backend debug using cli" new "Set backend debug using cli"
expectpart "$($clixon_cli -1 -f $cfg -l o debug backend 1)" 0 "^$" expectpart "$($clixon_cli -1 -f $cfg -l o debug backend 1)" 0 "^$"
new "Set restconf debug using cli"
expectpart "$($clixon_cli -1 -f $cfg -l o debug restconf 1)" 0 "^$"
# Exercise debug code # Exercise debug code
new "get and put config using restconf" new "get and put config using restconf"
expectpart "$(curl $CURLOPTS -H "Accept: application/yang-data+xml" -X GET $RCPROTO://localhost/restconf/data?content=config --next $CURLOPTS -H "Content-Type: application/yang-data+json" -X POST $RCPROTO://localhost/restconf/data -d '{"example:table":{"parameter":{"name":"local0","value":"foo"}}}')" 0 "HTTP/$HVER 200" '<data>' "HTTP/$HVER 201" expectpart "$(curl $CURLOPTS -H "Accept: application/yang-data+xml" -X GET $RCPROTO://localhost/restconf/data?content=config --next $CURLOPTS -H "Content-Type: application/yang-data+json" -X POST $RCPROTO://localhost/restconf/data -d '{"example:table":{"parameter":{"name":"local0","value":"foo"}}}')" 0 "HTTP/$HVER 200" '<data/>' "HTTP/$HVER 201"
# In freebsd, backend dies in stop_restconf below unless sleep # In freebsd, backend dies in stop_restconf below unless sleep
sleep $DEMSLEEP sleep $DEMSLEEP

View file

@ -110,7 +110,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK> <CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE> <CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_BACKEND_RESTCONF_PROCESS>false</CLICON_BACKEND_RESTCONF_PROCESS>
$RESTCONFIG <!-- only fcgi --> $RESTCONFIG <!-- only fcgi -->
</clixon-config> </clixon-config>
EOF EOF

View file

@ -44,7 +44,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK> <CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE> <CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_BACKEND_RESTCONF_PROCESS>false</CLICON_BACKEND_RESTCONF_PROCESS>
<CLICON_RESTCONF_HTTP2_PLAIN>true</CLICON_RESTCONF_HTTP2_PLAIN> <CLICON_RESTCONF_HTTP2_PLAIN>true</CLICON_RESTCONF_HTTP2_PLAIN>
$RESTCONFIG <!-- only fcgi --> $RESTCONFIG <!-- only fcgi -->
</clixon-config> </clixon-config>

View file

@ -217,6 +217,12 @@ wait_restconf
new "try restconf rpc status" new "try restconf rpc status"
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/operations/clixon-lib:process-control -d '{"clixon-lib:input":{"name":"restconf","operation":"status"}}')" 0 "HTTP/$HVER 200" '{"clixon-lib:output":' '"active":' '"pid":' expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/operations/clixon-lib:process-control -d '{"clixon-lib:input":{"name":"restconf","operation":"status"}}')" 0 "HTTP/$HVER 200" '{"clixon-lib:output":' '"active":' '"pid":'
new "Set backend debug using restconf"
expectpart "$(curl $CURLOPTS -X POST -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/operations/clixon-lib:debug -d '{"clixon-lib:input":{"level":1}}')" 0 "HTTP/$HVER 204"
new "Set restconf debug using netconf"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><restconf $RESTCONFNS><debug>1</debug></restconf></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "2. Get status" new "2. Get status"
rpcstatus true running rpcstatus true running
pid1=$pid pid1=$pid

View file

@ -96,7 +96,6 @@ cat <<EOF > $cfg
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK> <CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE> <CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_BACKEND_RESTCONF_PROCESS>false</CLICON_BACKEND_RESTCONF_PROCESS>
$RESTCONFIG $RESTCONFIG
</clixon-config> </clixon-config>
EOF EOF