From dd2ac56af89161233780a4a2f1f2547544a3feb7 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 7 Mar 2022 10:56:54 +0100 Subject: [PATCH] Module state upgrade: RFC7895 to RFC 8525 Changes to clixon-config: * Added option: 'CLICON_YANG_LIBRARY` * Changed default value: `CLICON_MODULE_LIBRARY_RFC7895` to false Datastore modstate is backward compatible Tests upgraded to RFC8525 --- CHANGELOG.md | 23 +- apps/backend/backend_get.c | 2 +- example/main/example.xml.in | 2 +- lib/clixon/clixon_yang_module.h | 6 +- lib/src/clixon_data.c | 2 - lib/src/clixon_datastore_read.c | 57 ++- lib/src/clixon_yang_module.c | 39 ++- test/test_augment.sh | 2 +- test/test_augment_state.sh | 2 +- test/test_augment_trans.sh | 2 +- test/test_autocli_extension.sh | 2 +- test/test_autocli_listkey_compress.sh | 2 +- test/test_autocli_strict_expand.sh | 2 +- test/test_autocli_sub.sh | 2 +- test/test_autocli_treeref.sh | 2 +- test/test_feature.sh | 21 +- test/test_helloworld.sh | 2 +- test/test_leafref_state.sh | 2 +- test/test_leafref_uses_augment.sh | 2 +- test/test_nacm_ext.sh | 2 +- test/test_nacm_module_write.sh | 2 +- test/test_nacm_recovery.sh | 2 +- test/test_netconf.sh | 3 +- test/test_netconf_hello.sh | 2 +- test/test_netconf_notifications.sh | 1 - test/test_openconfig.sh | 1 - test/test_openconfig_interfaces.sh | 1 - test/test_openconfig_network_instance.sh | 1 - test/test_openconfig_system.sh | 1 - test/test_pattern.sh | 1 - test/test_restconf.sh | 7 +- test/test_restconf_basic_auth.sh | 2 - test/test_restconf_http_upgrade.sh | 1 - test/test_restconf_internal.sh | 2 +- test/test_restconf_internal_usecases.sh | 2 +- test/test_restconf_jukebox.sh | 3 +- test/test_restconf_listkey.sh | 2 +- test/test_restconf_netns.sh | 2 - test/test_restconf_nmap.sh | 1 - test/test_restconf_notifications.sh | 1 - test/test_restconf_ssl_certs.sh | 1 - test/test_sock.sh | 2 +- test/test_submodule.sh | 6 +- test/test_upgrade_auto.sh | 30 +- test/test_upgrade_checkold.sh | 3 +- test/test_upgrade_failsafe.sh | 94 ++--- test/test_upgrade_interfaces.sh | 29 +- test/test_upgrade_interfaces_rfc7895.sh | 406 ++++++++++++++++++++++ test/test_upgrade_module.sh | 36 +- test/test_upgrade_quit.sh | 20 +- test/test_upgrade_repair.sh | 9 +- test/test_upgrade_simple.sh | 2 +- test/test_xpath_functions.sh | 2 +- test/test_yang.sh | 5 +- test/test_yang_anydata.sh | 2 +- test/test_yang_bind.sh | 1 - test/test_yang_deviation.sh | 1 - test/test_yang_extension.sh | 2 +- test/test_yang_namespace.sh | 1 - test/test_yang_when.sh | 2 +- yang/clixon/clixon-config@2022-02-11.yang | 40 ++- 61 files changed, 710 insertions(+), 198 deletions(-) create mode 100755 test/test_upgrade_interfaces_rfc7895.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index e340a326..cd7fdf9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,8 +36,14 @@ ## 5.6.0 Expected: March 2022 +In Clixon 5.6 the dependency of libevhtp for native RESTCONF is +removed. Also module-state has been upgraded to RFC8525. A lot of bugs +have been fixed, thanks to the community for all feedback. + ### New features +* Yang library upgraded from RFC78795 to RFC 8525 + * See API changes for more info * HTTP/1 native parser as part of the RESTCONF client * Replaced libevhtp/libevent2 with internal http1 parser * Replace configure option `--disable-evhtp` with `--disable-http1` for disabling HTTP/1 whihc is on by default @@ -46,10 +52,23 @@ Expected: March 2022 Users may have to change how they access the system +* Module state upgrade: RFC7895 to RFC 8525: + * To upgrade to RFC8525: + * You need to change `CLICON_YANG_LIBRARY` to `true` and `CLICON_MODULE_LIBRARY_RFC7895` to `false` + * To keep RFC7895: + * Set both `CLICON_YANG_LIBRARY` and `CLICON_MODULE_LIBRARY_RFC7895` to `true` + * This upgrade means that the state-data returned using GET is changed: + * preamble changed from: `...` to: `...` + * `module-state-id` changed to `content-id` + * `conformance-type` removed + * Note that the datastore feature `CLICON_XMLDB_MODSTATE` is backward compatible with RFC8525. * New `clixon-config@2022-02-11.yang` revision * Added option: * `CLICON_LOG_STRING_LIMIT` - * Removed (previosly marked) obsolete options: + * 'CLICON_YANG_LIBRARY` + * Changed default value: + * `CLICON_MODULE_LIBRARY_RFC7895` to false + * Removed (previosly marked) obsolete options: * `CLICON_RESTCONF_PATH` * `CLICON_RESTCONF_PRETTY` * `CLICON_CLI_GENMODEL` @@ -84,7 +103,7 @@ Users may have to change how they access the system ### Corrected Bugs * Fixed: [Validate error when appending module B grouping to module A item use augment statement #308](https://github.com/clicon/clixon/issues/308) -* Fixed: [ Restconf PATCH method request failed on item defined by submodule #306](https://github.com/clicon/clixon/issues/306) +* Fixed: [Restconf PATCH method request failed on item defined by submodule #306](https://github.com/clicon/clixon/issues/306) * Fixed: [restconf GET json response does not encode top level node with namespace as per rfc #303](https://github.com/clicon/clixon/issues/303) * Fixed: [statement: require-instance should be true if not present according to rfc7950 Sec 9.9.3](https://github.com/clicon/clixon/issues/302) * See also API changes diff --git a/apps/backend/backend_get.c b/apps/backend/backend_get.c index 84c6525b..962d0973 100644 --- a/apps/backend/backend_get.c +++ b/apps/backend/backend_get.c @@ -250,7 +250,7 @@ get_client_statedata(clicon_handle h, if ((ret = client_get_capabilities(h, yspec, xpath, xret)) < 0) goto done; } - if (clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895")){ + if (clicon_option_bool(h, "CLICON_YANG_LIBRARY")){ if ((ret = yang_modules_state_get(h, yspec, xpath, nsc, 0, xret)) < 0) goto done; if (ret == 0) diff --git a/example/main/example.xml.in b/example/main/example.xml.in index 9154262c..e03d82f1 100644 --- a/example/main/example.xml.in +++ b/example/main/example.xml.in @@ -20,7 +20,7 @@ init disabled true - false + false true none diff --git a/lib/clixon/clixon_yang_module.h b/lib/clixon/clixon_yang_module.h index ad5d8b78..95276fc6 100644 --- a/lib/clixon/clixon_yang_module.h +++ b/lib/clixon/clixon_yang_module.h @@ -53,9 +53,9 @@ * is the one loaded by the server by its YANG files. */ typedef struct { - int md_status; /* 0 if no module-state in a datastore, 1 if there is */ - char *md_set_id; /* server-specific identifier */ - cxobj *md_diff; /* yang module state containing revisions and XML_FLAG_ADD|DEL|CHANGE */ + int md_status; /* 0 if no module-state in a datastore, 1 if there is */ + char *md_content_id; /* server-specific identifier (previously md_set_id) */ + cxobj *md_diff; /* yang module state containing revisions and XML_FLAG_ADD|DEL|CHANGE */ } modstate_diff_t; /* diff --git a/lib/src/clixon_data.c b/lib/src/clixon_data.c index 41522a1e..2b530549 100644 --- a/lib/src/clixon_data.c +++ b/lib/src/clixon_data.c @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -658,7 +657,6 @@ clicon_modst_cache_set(clicon_handle h, xml_free(x); if (xms == NULL) goto ok; - assert(strcmp(xml_name(xms),"modules-state")==0); if ((x = xml_dup(xms)) == NULL) return -1; if (clicon_hash_add(cdat, brief?"modst_brief":"modst_full", &x, sizeof(x))==NULL) diff --git a/lib/src/clixon_datastore_read.c b/lib/src/clixon_datastore_read.c index 1034f769..9371a4ed 100644 --- a/lib/src/clixon_datastore_read.c +++ b/lib/src/clixon_datastore_read.c @@ -276,6 +276,8 @@ text_read_modstate(clicon_handle h, { int retval = -1; cxobj *xmodfile = NULL; /* modstate of system (loaded yang modules in runtime) */ + cxobj *xyanglib = NULL; + cxobj *xmodcache; cxobj *xmodsystem = NULL; /* modstate of file, eg startup */ cxobj *xf = NULL; /* xml modstate in file */ cxobj *xf2; /* copy */ @@ -284,30 +286,45 @@ text_read_modstate(clicon_handle h, char *name; /* module name */ char *frev; /* file revision */ char *srev; /* system revision */ + int rfc7895=0; /* backward-compatible: old version */ /* Read module-state as computed at startup, see startup_module_state() */ - xmodsystem = clicon_modst_cache_get(h, 1); - if ((xmodfile = xml_find_type(xt, NULL, "modules-state", CX_ELMNT)) == NULL){ - /* 1) There is no modules-state info in the file */ - } - else if (xmodsystem && msdiff){ + if ((xmodcache = clicon_modst_cache_get(h, 1)) != NULL) + xmodsystem = xml_find_type(xmodcache, NULL, "module-set", CX_ELMNT); + + xyanglib = xml_find_type(xt, NULL, "yang-library", CX_ELMNT); + if ((xmodfile = xpath_first(xt, NULL, "yang-library/module-set")) != NULL) + ; + else if ((xmodfile = xml_find_type(xt, NULL, "modules-state", CX_ELMNT)) != NULL) + rfc7895++; + if (xmodfile && xmodsystem && msdiff){ msdiff->md_status = 1; /* There is module state in the file */ /* Create modstate tree for this file */ - if (clixon_xml_parse_string("", + if (clixon_xml_parse_string("", YB_MODULE, yspec, &msdiff->md_diff, NULL) < 0) goto done; if (xml_rootchild(msdiff->md_diff, 0, &msdiff->md_diff) < 0) goto done; - /* 3) For each module state m in the file */ - xf = NULL; - while ((xf = xml_child_each(xmodfile, xf, CX_ELMNT)) != NULL) { - if (strcmp(xml_name(xf), "module-set-id") == 0){ - if (xml_body(xf) && (msdiff->md_set_id = strdup(xml_body(xf))) == NULL){ + if (!rfc7895){ + if ((xf = xpath_first(xt, NULL, "yang-library/content-id")) != NULL){ + if (xml_body(xf) && (msdiff->md_content_id = strdup(xml_body(xf))) == NULL){ clicon_err(OE_UNIX, errno, "strdup"); goto done; } - continue; + } + } + /* 3) For each module state m in the file */ + xf = NULL; + while ((xf = xml_child_each(xmodfile, xf, CX_ELMNT)) != NULL) { + if (rfc7895){ + if (strcmp(xml_name(xf), "module-set-id") == 0){ + if (xml_body(xf) && (msdiff->md_content_id = strdup(xml_body(xf))) == NULL){ + clicon_err(OE_UNIX, errno, "strdup"); + goto done; + } + continue; + } } if (strcmp(xml_name(xf), "module")) continue; /* ignore other tags, such as module-set-id */ @@ -358,10 +375,15 @@ text_read_modstate(clicon_handle h, * in all cases, whether CLICON_XMLDB_MODSTATE is on or not. * Clixon systems with CLICON_XMLDB_MODSTATE disabled ignores it */ - if (xmodfile){ - if (xml_purge(xmodfile) < 0) - goto done; + if (rfc7895){ + if (xmodfile){ + if (xml_purge(xmodfile) < 0) + goto done; + } } + else if (xyanglib) + if (xml_purge(xyanglib) < 0) + goto done; retval = 0; done: return retval; @@ -516,9 +538,12 @@ xmldb_readfile(clicon_handle h, if (clicon_option_bool(h, "CLICON_XMLDB_MODSTATE")) if ((msdiff = modstate_diff_new()) == NULL) goto done; - if ((x = xml_find_type(x0, NULL, "modules-state", CX_ELMNT)) != NULL) + /* First try RFC8525, but also backward compatible RFC7895 */ + if ((x = xpath_first(x0, NULL, "yang-library/module-set")) != NULL || + (x = xml_find_type(x0, NULL, "modules-state", CX_ELMNT)) != NULL){ if ((xmodfile = xml_dup(x)) == NULL) goto done; + } /* Datastore files may contain module-state defining * which modules are used in the file. * Strip module-state, analyze it with CHANGE/ADD/RM and return msdiff diff --git a/lib/src/clixon_yang_module.c b/lib/src/clixon_yang_module.c index b65a6242..358f5396 100644 --- a/lib/src/clixon_yang_module.c +++ b/lib/src/clixon_yang_module.c @@ -100,8 +100,8 @@ modstate_diff_free(modstate_diff_t *md) { if (md == NULL) return 0; - if (md->md_set_id) - free(md->md_set_id); + if (md->md_content_id) + free(md->md_content_id); if (md->md_diff) xml_free(md->md_diff); free(md); @@ -121,11 +121,11 @@ yang_modules_init(clicon_handle h) yang_stmt *yspec; yspec = clicon_dbspec_yang(h); - if (!clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895")) + if (!clicon_option_bool(h, "CLICON_YANG_LIBRARY")) goto ok; /* Ensure module-set-id is set */ if (!clicon_option_exists(h, "CLICON_MODULE_SET_ID")){ - clicon_err(OE_CFG, ENOENT, "CLICON_MODULE_SET_ID must be defined when CLICON_MODULE_LIBRARY_RFC7895 is enabled"); + clicon_err(OE_CFG, ENOENT, "CLICON_MODULE_SET_ID must be defined when CLICON_YANG_LIBRARY is enabled"); goto done; } /* Ensure revision exists is set */ @@ -165,8 +165,11 @@ yang_modules_revision(clicon_handle h) return revision; } -/*! Actually build the yang modules state XML tree - * @see RFC7895 +/*! Actually build the yang modules state XML tree according to RFC8525 + * + * This assumes CLICON_YANG_LIBRARY is enabled + * If also CLICON_MODULE_LIBRARY_RFC7895 is set, module-state is built according to RFC7895 instead + * @see RFC8525 */ static int yms_build(clicon_handle h, @@ -196,9 +199,15 @@ yms_build(clicon_handle h, goto done; } - cprintf(cb,"", yang_argument_get(yns)); - cprintf(cb,"%s", msid); - + if (clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895")){ + cprintf(cb,"", yang_argument_get(yns)); + cprintf(cb,"%s", msid); + } + else { /* RFC 8525 */ + cprintf(cb,"", yang_argument_get(yns)); + cprintf(cb,"%s", msid); + cprintf(cb,"default"); + } ymod = NULL; while ((ymod = yn_each(yspec, ymod)) != NULL) { if (yang_keyword_get(ymod) != Y_MODULE) @@ -230,7 +239,8 @@ yms_build(clicon_handle h, break; } } - cprintf(cb, "implement"); + if (clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895")) + cprintf(cb, "implement"); } yinc = NULL; while ((yinc = yn_each(ymod, yinc)) != NULL) { @@ -249,7 +259,12 @@ yms_build(clicon_handle h, } cprintf(cb,""); } - cprintf(cb,""); + if (clicon_option_bool(h, "CLICON_MODULE_LIBRARY_RFC7895")){ + cprintf(cb,""); + } + else{ + cprintf(cb,""); + } retval = 0; done: return retval; @@ -302,7 +317,7 @@ yang_modules_state_get(clicon_handle h, size_t xlen; int i; - msid = clicon_option_str(h, "CLICON_MODULE_SET_ID"); + msid = clicon_option_str(h, "CLICON_MODULE_SET_ID"); /* In RFC 8525 changed to "content-id" */ if ((xc = clicon_modst_cache_get(h, brief)) != NULL){ cxobj *xw; /* tmp top wrap object */ /* xc is here: ... diff --git a/test/test_augment.sh b/test/test_augment.sh index bacd95f1..ed808cd6 100755 --- a/test/test_augment.sh +++ b/test/test_augment.sh @@ -40,7 +40,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true + true $RESTCONFIG EOF diff --git a/test/test_augment_state.sh b/test/test_augment_state.sh index 93ed9ced..00f1c73b 100755 --- a/test/test_augment_state.sh +++ b/test/test_augment_state.sh @@ -26,7 +26,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME - false + false EOF diff --git a/test/test_augment_trans.sh b/test/test_augment_trans.sh index f0d0bb89..75699a87 100755 --- a/test/test_augment_trans.sh +++ b/test/test_augment_trans.sh @@ -29,7 +29,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME - false + false EOF diff --git a/test/test_autocli_extension.sh b/test/test_autocli_extension.sh index 0cb7a75b..3dee8756 100755 --- a/test/test_autocli_extension.sh +++ b/test/test_autocli_extension.sh @@ -38,7 +38,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - false + false ${AUTOCLI} EOF diff --git a/test/test_autocli_listkey_compress.sh b/test/test_autocli_listkey_compress.sh index 12ae83b4..2805476e 100755 --- a/test/test_autocli_listkey_compress.sh +++ b/test/test_autocli_listkey_compress.sh @@ -211,7 +211,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - false + false false ${listkw} diff --git a/test/test_autocli_strict_expand.sh b/test/test_autocli_strict_expand.sh index a43a1d90..e239d489 100755 --- a/test/test_autocli_strict_expand.sh +++ b/test/test_autocli_strict_expand.sh @@ -36,7 +36,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - false + false ${AUTOCLI} EOF diff --git a/test/test_autocli_sub.sh b/test/test_autocli_sub.sh index 947ac166..952d0865 100755 --- a/test/test_autocli_sub.sh +++ b/test/test_autocli_sub.sh @@ -36,7 +36,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - false + false ${AUTOCLI} EOF diff --git a/test/test_autocli_treeref.sh b/test/test_autocli_treeref.sh index ec497b23..b4660d78 100755 --- a/test/test_autocli_treeref.sh +++ b/test/test_autocli_treeref.sh @@ -36,7 +36,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - false + false ${AUTOCLI} EOF diff --git a/test/test_feature.sh b/test/test_feature.sh index db021ab8..e6e28f8e 100755 --- a/test/test_feature.sh +++ b/test/test_feature.sh @@ -41,7 +41,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true EOF @@ -192,20 +191,20 @@ testrun m8 false # reply since the modules change so often new "netconf schema resource, RFC 7895" ret=$($clixon_netconf -qf $cfg<]]>]]> +$DEFAULTHELLO]]>]]> EOF ) #echo $ret -new "netconf modules-state header" -expect="^" +new "netconf yang-library header" +expect="^default" match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi new "netconf module A" -expect="exampleurn:example:clixonAA1implement" +expect="exampleurn:example:clixonAA1" match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" @@ -221,14 +220,14 @@ fi fi # false new "netconf module ietf-inet-types" -expect="ietf-inet-types2021-02-22urn:ietf:params:xml:ns:yang:ietf-inet-typesimplement" +expect="ietf-inet-types2021-02-22urn:ietf:params:xml:ns:yang:ietf-inet-types" match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi new "netconf module ietf-interfaces" -expect="ietf-interfaces2018-02-20urn:ietf:params:xml:ns:yang:ietf-interfacesimplement" +expect="ietf-interfaces2018-02-20urn:ietf:params:xml:ns:yang:ietf-interfaces" match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" @@ -236,26 +235,26 @@ fi # Note order of features in ietf-netconf yang is alphabetically: candidate, startup, validate, xpath new "netconf module ietf-netconf" -expect="ietf-netconf2011-06-01urn:ietf:params:xml:ns:netconf:base:1.0candidatevalidatexpathimplement" +expect="ietf-netconf2011-06-01urn:ietf:params:xml:ns:netconf:base:1.0candidatevalidatexpath" match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi new "netconf module ietf-routing" -expect="ietf-routing2018-03-13urn:ietf:params:xml:ns:yang:ietf-routingrouter-idimplement" +expect="ietf-routing2018-03-13urn:ietf:params:xml:ns:yang:ietf-routingrouter-id" match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi -expect="ietf-yang-library2019-01-04urn:ietf:params:xml:ns:yang:ietf-yang-libraryimplement" +expect="ietf-yang-library2019-01-04urn:ietf:params:xml:ns:yang:ietf-yang-library" match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" fi new "netconf module ietf-yang_types" -expect="ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-typesimplement" +expect="ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-types" match=`echo "$ret" | grep --null -Go "$expect"` if [ -z "$match" ]; then err "$expect" "$ret" diff --git a/test/test_helloworld.sh b/test/test_helloworld.sh index cb224c06..805281c4 100755 --- a/test/test_helloworld.sh +++ b/test/test_helloworld.sh @@ -30,7 +30,7 @@ cat < $cfg /var/run/helloworld.pid $dir init - false + false clicon www-data drop_perm diff --git a/test/test_leafref_state.sh b/test/test_leafref_state.sh index fecb2bf3..f586bad1 100755 --- a/test/test_leafref_state.sh +++ b/test/test_leafref_state.sh @@ -36,7 +36,7 @@ cat < $cfg /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock - false + false /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME true diff --git a/test/test_leafref_uses_augment.sh b/test/test_leafref_uses_augment.sh index df36f0ba..bc11b24f 100755 --- a/test/test_leafref_uses_augment.sh +++ b/test/test_leafref_uses_augment.sh @@ -29,7 +29,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME - false + false ${AUTOCLI} EOF diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh index f4b0d5c4..470b8a2f 100755 --- a/test/test_nacm_ext.sh +++ b/test/test_nacm_ext.sh @@ -32,7 +32,7 @@ cat < $cfg /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock - false + false /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME external diff --git a/test/test_nacm_module_write.sh b/test/test_nacm_module_write.sh index bf994072..90f96335 100755 --- a/test/test_nacm_module_write.sh +++ b/test/test_nacm_module_write.sh @@ -45,7 +45,7 @@ cat < $cfg /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock - false + false /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME diff --git a/test/test_nacm_recovery.sh b/test/test_nacm_recovery.sh index 8e9d6ccb..80e0fe1c 100755 --- a/test/test_nacm_recovery.sh +++ b/test/test_nacm_recovery.sh @@ -79,7 +79,7 @@ cat < $cfg /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - false + false $recovery internal $cred diff --git a/test/test_netconf.sh b/test/test_netconf.sh index e8e895a9..f2a35afa 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -33,7 +33,6 @@ cat < $cfg $dir/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true EOF @@ -72,7 +71,7 @@ new "Frame without message-id attribute" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^rpcmissing-attributemessage-iderrorIncoming rpc]]>]]>$" new "netconf rcv hello, disable RFC7895/ietf-yang-library" -expecteof "$clixon_netconf -f $cfg -o CLICON_MODULE_LIBRARY_RFC7895=0" 0 "$DEFAULTHELLO]]>]]>" "^urn:ietf:params:netconf:base:1.1urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:capability:candidate:1.0urn:ietf:params:netconf:capability:validate:1.1urn:ietf:params:netconf:capability:startup:1.0urn:ietf:params:netconf:capability:xpath:1.0urn:ietf:params:netconf:capability:notification:1.0[0-9]*]]>]]>]]>]]>$" +expecteof "$clixon_netconf -f $cfg -o CLICON_YANG_LIBRARY=0" 0 "$DEFAULTHELLO]]>]]>" "^urn:ietf:params:netconf:base:1.1urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:capability:candidate:1.0urn:ietf:params:netconf:capability:validate:1.1urn:ietf:params:netconf:capability:startup:1.0urn:ietf:params:netconf:capability:xpath:1.0urn:ietf:params:netconf:capability:notification:1.0[0-9]*]]>]]>]]>]]>$" new "netconf get-config nc prefix" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" diff --git a/test/test_netconf_hello.sh b/test/test_netconf_hello.sh index fcff3b82..61fe3174 100755 --- a/test/test_netconf_hello.sh +++ b/test/test_netconf_hello.sh @@ -32,7 +32,7 @@ cat < $cfg $dir/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true + true EOF diff --git a/test/test_netconf_notifications.sh b/test/test_netconf_notifications.sh index 68994855..d5406485 100755 --- a/test/test_netconf_notifications.sh +++ b/test/test_netconf_notifications.sh @@ -39,7 +39,6 @@ cat < $cfg /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME - true true streams 60 diff --git a/test/test_openconfig.sh b/test/test_openconfig.sh index 05939bc1..b4d7a503 100755 --- a/test/test_openconfig.sh +++ b/test/test_openconfig.sh @@ -71,7 +71,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true ${AUTOCLI} EOF diff --git a/test/test_openconfig_interfaces.sh b/test/test_openconfig_interfaces.sh index 3bec643d..907a81e1 100755 --- a/test/test_openconfig_interfaces.sh +++ b/test/test_openconfig_interfaces.sh @@ -37,7 +37,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true ${AUTOCLI} EOF diff --git a/test/test_openconfig_network_instance.sh b/test/test_openconfig_network_instance.sh index 303c5dd7..d9095729 100755 --- a/test/test_openconfig_network_instance.sh +++ b/test/test_openconfig_network_instance.sh @@ -34,7 +34,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true false kw-nokey diff --git a/test/test_openconfig_system.sh b/test/test_openconfig_system.sh index 092a835b..01ef7636 100755 --- a/test/test_openconfig_system.sh +++ b/test/test_openconfig_system.sh @@ -39,7 +39,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true ${AUTOCLI} EOF diff --git a/test/test_pattern.sh b/test/test_pattern.sh index d1d9f398..accecb4d 100755 --- a/test/test_pattern.sh +++ b/test/test_pattern.sh @@ -43,7 +43,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true EOF diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 8ab6d680..89bf7268 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -110,7 +110,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true false $RESTCONFIG @@ -337,11 +336,11 @@ function testrun() err "$expect" "$ret" fi - new "restconf schema resource, RFC 8040 sec 3.7 according to RFC 7895 (explicit resource)" - expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $proto://$addr/restconf/data/ietf-yang-library:modules-state/module=ietf-interfaces,2018-02-20)" 0 "HTTP/$HVER 200" '{"ietf-yang-library:module":\[{"name":"ietf-interfaces","revision":"2018-02-20","namespace":"urn:ietf:params:xml:ns:yang:ietf-interfaces","conformance-type":"implement"}\]}' + new "restconf schema resource, RFC 8040 sec 3.7 according to RFC 8525 (explicit resource)" + expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $proto://$addr/restconf/data/ietf-yang-library:yang-library/module-set=default/module=ietf-interfaces)" 0 "HTTP/$HVER 200" '{"ietf-yang-library:module":\[{"name":"ietf-interfaces","revision":"2018-02-20","namespace":"urn:ietf:params:xml:ns:yang:ietf-interfaces"}\]}' new "restconf schema resource, mod-state top-level" - expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $proto://$addr/restconf/data/ietf-yang-library:modules-state)" 0 "HTTP/$HVER 200" "{\"ietf-yang-library:modules-state\":{\"module-set-id\":\"0\",\"module\":\[{\"name\":\"clixon-autocli\",\"revision\":\"${CLIXON_AUTOCLI_REV}\",\"namespace\":\"http://clicon.org/autocli\",\"conformance-type\":\"implement\"},{\"name\":\"clixon-example\",\"revision\":\"${CLIXON_EXAMPLE_REV}\",\"namespace\":\"urn:example:clixon\",\"conformance-type\":\"implement\"},{\"name\":\"clixon-lib\",\"revision\":\"${CLIXON_LIB_REV}\",\"" + expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $proto://$addr/restconf/data/ietf-yang-library:yang-library/module-set=default)" 0 "HTTP/$HVER 200" "{\"ietf-yang-library:module-set\":\[{\"name\":\"default\",\"module\":\[{\"name\":\"clixon-autocli\",\"revision\":\"${CLIXON_AUTOCLI_REV}\",\"namespace\":\"http://clicon.org/autocli\"},{\"name\":\"clixon-example\",\"revision\":\"${CLIXON_EXAMPLE_REV}\",\"namespace\":\"urn:example:clixon\"},{\"name\":\"clixon-lib\",\"revision\":\"${CLIXON_LIB_REV}\",\"" new "restconf options. RFC 8040 4.1" expectpart "$(curl $CURLOPTS -X OPTIONS $proto://$addr/restconf/data)" 0 "HTTP/$HVER 200" "Allow: OPTIONS,HEAD,GET,POST,PUT,PATCH,DELETE" diff --git a/test/test_restconf_basic_auth.sh b/test/test_restconf_basic_auth.sh index 428fc1d3..10394892 100755 --- a/test/test_restconf_basic_auth.sh +++ b/test/test_restconf_basic_auth.sh @@ -54,7 +54,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile $dir true - true internal $anonymous @@ -197,7 +196,6 @@ function testrun() /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true internal $anonymous $RESTCONFIG diff --git a/test/test_restconf_http_upgrade.sh b/test/test_restconf_http_upgrade.sh index 82246af8..bb6d7904 100755 --- a/test/test_restconf_http_upgrade.sh +++ b/test/test_restconf_http_upgrade.sh @@ -44,7 +44,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true false true $RESTCONFIG diff --git a/test/test_restconf_internal.sh b/test/test_restconf_internal.sh index 44eb9921..908090a1 100755 --- a/test/test_restconf_internal.sh +++ b/test/test_restconf_internal.sh @@ -63,7 +63,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true + true /usr/local/sbin true diff --git a/test/test_restconf_internal_usecases.sh b/test/test_restconf_internal_usecases.sh index 7a733751..75bc396e 100755 --- a/test/test_restconf_internal_usecases.sh +++ b/test/test_restconf_internal_usecases.sh @@ -77,7 +77,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true + true /usr/local/sbin true diff --git a/test/test_restconf_jukebox.sh b/test/test_restconf_jukebox.sh index 8447fe1e..4fef4b51 100755 --- a/test/test_restconf_jukebox.sh +++ b/test/test_restconf_jukebox.sh @@ -39,6 +39,7 @@ cat < $cfg /usr/local/var/$APPNAME true clixon-restconf:fcgi + true $RESTCONFIG EOF @@ -105,7 +106,7 @@ expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPR # This just catches the header and the jukebox module, the RFC has foo and bar which # seems wrong to recreate new "B.1.2. Retrieve the Server Module Information" -expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $RCPROTO://localhost/restconf/data/ietf-yang-library:modules-state)" 0 "HTTP/$HVER 200" 'Cache-Control: no-cache' "Content-Type: application/yang-data+json" "{\"ietf-yang-library:modules-state\":{\"module-set-id\":\"0\",\"module\":\[{\"name\":\"clixon-lib\",\"revision\":\"${CLIXON_LIB_REV}\",\"namespace\":\"http://clicon.org/lib\",\"conformance-type\":\"implement\"}" '{"name":"example-events","revision":"","namespace":"urn:example:events","conformance-type":"implement"}' '{"name":"example-jukebox","revision":"2016-08-15","namespace":"http://example.com/ns/example-jukebox","conformance-type":"implement"}' '{"name":"example-system","revision":"","namespace":"http://example.com/ns/example-system","conformance-type":"implement"}' +expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+json' $RCPROTO://localhost/restconf/data/ietf-yang-library:yang-library)" 0 "HTTP/$HVER 200" 'Cache-Control: no-cache' "Content-Type: application/yang-data+json" "{\"ietf-yang-library:yang-library\":{\"module-set\":\[{\"name\":\"default\",\"module\":\[{\"name\":\"clixon-lib\",\"revision\":\"${CLIXON_LIB_REV}\",\"namespace\":\"http://clicon.org/lib\"}" '{"name":"example-events","revision":"","namespace":"urn:example:events"' '{"name":"example-jukebox","revision":"2016-08-15","namespace":"http://example.com/ns/example-jukebox"}' '{"name":"example-system","revision":"","namespace":"http://example.com/ns/example-system"}' new "B.1.3. Retrieve the Server Capability Information" expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data/ietf-restconf-monitoring:restconf-state/capabilities)" 0 "HTTP/$HVER 200" "Content-Type: application/yang-data+xml" 'Cache-Control: no-cache' 'urn:ietf:params:restconf:capability:defaults:1.0?basic-mode=expliciturn:ietf:params:restconf:capability:depth diff --git a/test/test_restconf_listkey.sh b/test/test_restconf_listkey.sh index c5806aab..9ab440a7 100755 --- a/test/test_restconf_listkey.sh +++ b/test/test_restconf_listkey.sh @@ -24,7 +24,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock $dir/restconf.pidfile /usr/local/var/$APPNAME - false + false $RESTCONFIG EOF diff --git a/test/test_restconf_netns.sh b/test/test_restconf_netns.sh index 93613527..48eb61b3 100755 --- a/test/test_restconf_netns.sh +++ b/test/test_restconf_netns.sh @@ -108,7 +108,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true $RESTCONFIG EOF @@ -283,7 +282,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true $RESTCONFIG EOF diff --git a/test/test_restconf_nmap.sh b/test/test_restconf_nmap.sh index c5c05b0a..7f94c237 100755 --- a/test/test_restconf_nmap.sh +++ b/test/test_restconf_nmap.sh @@ -96,7 +96,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true false $RESTCONFIG diff --git a/test/test_restconf_notifications.sh b/test/test_restconf_notifications.sh index 8a68b965..ef27c40a 100755 --- a/test/test_restconf_notifications.sh +++ b/test/test_restconf_notifications.sh @@ -60,7 +60,6 @@ cat < $cfg /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME - true true true streams diff --git a/test/test_restconf_ssl_certs.sh b/test/test_restconf_ssl_certs.sh index 9774ebaa..0131c033 100755 --- a/test/test_restconf_ssl_certs.sh +++ b/test/test_restconf_ssl_certs.sh @@ -203,7 +203,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile $dir true - true internal true diff --git a/test/test_sock.sh b/test/test_sock.sh index 0c7ebaa4..fb1bdd74 100755 --- a/test/test_sock.sh +++ b/test/test_sock.sh @@ -50,7 +50,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME init - false + false EOF diff --git a/test/test_submodule.sh b/test/test_submodule.sh index 83aa6fa6..c9ee7647 100755 --- a/test/test_submodule.sh +++ b/test/test_submodule.sh @@ -46,7 +46,7 @@ cat < $cfg example_backend.so$ /usr/local/lib/$APPNAME/restconf /usr/local/var/$APPNAME - true + true $RESTCONFIG EOF @@ -263,10 +263,10 @@ new "restconf edit augment 2" expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/main:sub2 -d '{"main:aug2":"foo"}')" 0 "HTTP/$HVER 201" new "NETCONF get module state" -expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO]]>]]>" "main2021-03-08urn:example:clixonAimplementsub1" +expecteof "$clixon_netconf -qf $cfg -D $DBG" 0 "$DEFAULTHELLO]]>]]>" "defaultmain2021-03-08urn:example:clixonsub1A" new "RESTCONF get module state" -expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data/ietf-yang-library:modules-state/module=main,2021-03-08?config=nonconfig)" 0 "HTTP/$HVER 200" "main2021-03-08urn:example:clixonAimplementsub1" +expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/data/ietf-yang-library:yang-library/module-set=default/module=main?config=nonconfig)" 0 "HTTP/$HVER 200" "main2021-03-08urn:example:clixonsub1A" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_upgrade_auto.sh b/test/test_upgrade_auto.sh index bd906cec..1256ccaa 100755 --- a/test/test_upgrade_auto.sh +++ b/test/test_upgrade_auto.sh @@ -137,19 +137,22 @@ EOF # this should be automatically upgraded to 2017-12-20 cat < $dir/startup_db <${DATASTORE_TOP}> - - 42 - - example-a - 2017-12-01 - urn:example:a - - - example-b - 2017-12-01 - urn:example:b - - + + 42 + + default + + example-a + 2017-12-01 + urn:example:a + + + example-b + 2017-12-01 + urn:example:b + + + dont change me rename me @@ -168,7 +171,6 @@ EOF # Wanted new XML XML='dont change merename mei am modifiedcreatedmove me' - # Create configuration cat < $cfg diff --git a/test/test_upgrade_checkold.sh b/test/test_upgrade_checkold.sh index 7cd58f92..197e6f4e 100755 --- a/test/test_upgrade_checkold.sh +++ b/test/test_upgrade_checkold.sh @@ -106,7 +106,8 @@ EOF fi for modstate in true false; do if $modstate; then - modstatestr="42A2016-01-01urn:example:a" + modstatestr="default42A2016-01-01urn:example:a" +# modstatestr="42A2016-01-01urn:example:a" else modstatestr="" fi diff --git a/test/test_upgrade_failsafe.sh b/test/test_upgrade_failsafe.sh index 3f765ea1..95758ff4 100755 --- a/test/test_upgrade_failsafe.sh +++ b/test/test_upgrade_failsafe.sh @@ -3,7 +3,7 @@ # It is a test of handling modstate, identifying invalid startups # and entering failsafe # No active upgrading of an outdated db is made -# This relies on storing RFC7895 YANG Module Library modules-state info +# This relies on storing RFC8525 YANG Module Library yang-library/module-set info # in the datastore (or XML files?) # The test is made with three Yang models A, B and C as follows: # Yang module A has revisions "0814-01-28" and "2019-01-01" @@ -106,6 +106,7 @@ cat < $cfg $dir true false + false /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME @@ -123,19 +124,22 @@ EOF # startup config XML with following cat < $dir/compat-valid.xml <${DATASTORE_TOP}> - - 42 - - A - 2019-01-01 - urn:example:a - - - B - 2019-01-01 - urn:example:b - - + + 42 + + default + + A + 2019-01-01 + urn:example:a + + + B + 2019-01-01 + urn:example:b + + + always work other text @@ -145,19 +149,22 @@ EOF # startup config XML with following cat < $dir/compat-invalid.xml <${DATASTORE_TOP}> - - 42 - - A - 2019-01-01 - urn:example:a - - - B - 2019-01-01 - urn:example:b - - + + 42 + + default + + A + 2019-01-01 + urn:example:a + + + B + 2019-01-01 + urn:example:b + + + old version always work other text @@ -171,8 +178,10 @@ EOF # But XML is OK cat < $dir/non-compat-valid.xml <${DATASTORE_TOP}> - - 42 + + 42 + + default A 0814-01-28 @@ -188,7 +197,8 @@ cat < $dir/non-compat-valid.xml 2019-01-01 urn:example:c - + + always work other text @@ -198,8 +208,10 @@ EOF # startup config XML with following (A obsolete, B OK, C lacking) cat < $dir/non-compat-invalid.xml <${DATASTORE_TOP}> - - 42 + + 42 + + default A 0814-01-28 @@ -215,7 +227,8 @@ cat < $dir/non-compat-invalid.xml 2019-01-01 urn:example:c - + + old version always work other text @@ -226,8 +239,10 @@ EOF # Compatible startup with syntax errors cat < $dir/compat-err.xml <${DATASTORE_TOP}> - - 42 + + 42 + + default A 2019-01-01 @@ -238,7 +253,8 @@ cat < $dir/compat-err.xml 2019-01-01 urn:example:b - + + <always work other text @@ -304,7 +320,7 @@ new "1. Run without CLICON_XMLDB_MODSTATE ensure no modstate in datastore" runtest false startup 'always workother text' 'always workother text' new "Verify no modstate in running" -expect="modules-state" +expect="" ret=$(sudo grep $expect $dir/running_db) if [ -n "$ret" ]; then err "did not expect $expect" "$ret" @@ -317,7 +333,7 @@ new "2. Load compatible valid startup (all OK)" runtest true startup 'always workother text' 'always workother text' new "Verify modstate in running" -expect="modules-state" +expect="" ret=$(sudo grep $expect $dir/running_db) if [ -z "$ret" ]; then err "Expected $expect" "$ret" @@ -361,7 +377,7 @@ if [ $valgrindtest -ne 2 ]; then new "8. Load non-compat startup. Syntax fail, enter failsafe, startup invalid" (cd $dir; rm -f tmp_db candidate_db running_db startup_db) # remove databases (cd $dir; cp compat-err.xml startup_db) -runtest true startup 'always work' 'applicationoperation-failederrorGet startup datastore: xml_parse: line 14: syntax error: at or before: <' +runtest true startup 'always work' 'applicationoperation-failederrorGet startup datastore: xml_parse: line 17: syntax error: at or before: <' fi # valgrindtest rm -rf $dir diff --git a/test/test_upgrade_interfaces.sh b/test/test_upgrade_interfaces.sh index 75000b48..950628fb 100755 --- a/test/test_upgrade_interfaces.sh +++ b/test/test_upgrade_interfaces.sh @@ -18,7 +18,7 @@ # Rename /interfaces/interface/description to /interfaces/interface/descr (2016) # Wrap /interfaces/interface/descr to /interfaces/interface/docs/descr (2018) # Change type /interfaces/interface/statistics/in-octets to decimal64 and divide all values with 1000 (2018) -# +# See also test_upgrade_interfaces_rfc7895.sh for RFC7895 backward compatible # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi @@ -210,14 +210,17 @@ EOF # This is 2014 syntax cat < $dir/startup_db <${DATASTORE_TOP}> - - 42 + + 42 + + default interfaces 2014-05-08 urn:example:interfaces - + + e0 @@ -294,14 +297,17 @@ testrun "$XML" # This is "2016" syntax cat < $dir/startup_db <${DATASTORE_TOP}> - - 42 + + 42 + + default interfaces 2016-01-01 urn:example:interfaces - + + e0 @@ -347,14 +353,17 @@ testrun "$XML" # Again 2014 syntax cat < $dir/startup_db <${DATASTORE_TOP}> - - 42 + + 42 + + default interfaces 2014-05-08 urn:example:interfaces - + + e0 diff --git a/test/test_upgrade_interfaces_rfc7895.sh b/test/test_upgrade_interfaces_rfc7895.sh new file mode 100755 index 00000000..c36f7da2 --- /dev/null +++ b/test/test_upgrade_interfaces_rfc7895.sh @@ -0,0 +1,406 @@ +#!/usr/bin/env bash +# Upgrade a module by registering a manually programmed callback +# The usecase is inspired by the ietf-interfaces upgrade from +# 2014-05-08 to 2016-01-01 to 2018-02-20. +# That includes moving parts from interfaces-state to interfaces and then +# deprecating the whole /interfaces-state tree. +# A preliminary change list is in Appendix A of +# draft-wang-netmod-module-revision-management-01 +# The example here is simplified and also extended. +# For exampe admin and stats field are non-config in the original, not here +# It has also been broken up into two parts to test a series of upgrades. +# These are the operations (authentic move/delete are from ietf-interfaces): +# Move /if:interfaces-state/if:interface/if:admin-status to (2016) +# /if:interfaces/if:interface/ +# Move /if:interfaces-state/if:interface/if:statistics to (2016) +# if:interfaces/if:interface/ +# Delete /if:interfaces-state (2018) +# Rename /interfaces/interface/description to /interfaces/interface/descr (2016) +# Wrap /interfaces/interface/descr to /interfaces/interface/docs/descr (2018) +# Change type /interfaces/interface/statistics/in-octets to decimal64 and divide all values with 1000 (2018) +# This is backwrd compatible RFC7895, see also test_upgrade_interfaces.sh for RFC8525 + +# 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.xml +if2014=$dir/interfaces@2014-05-08.yang +if2018=$dir/interfaces@2018-02-20.yang + +# Create configuration +cat < $cfg + + $cfg + ietf-netconf:startup + ${YANG_INSTALLDIR} + interfaces:if-mib + $dir + $dir + /usr/local/var/$APPNAME/$APPNAME.sock + /usr/local/lib/example/backend + /usr/local/var/$APPNAME/$APPNAME.pidfile + $dir + true + false + false + /usr/local/lib/$APPNAME/clispec + /usr/local/lib/$APPNAME/cli + $APPNAME + +EOF + +# Original simplified version - note all is config to allow for storing in +# datastore +cat < $if2014 +module interfaces{ + yang-version 1.1; + namespace "urn:example:interfaces"; + prefix "if"; + + import ietf-yang-types { + prefix yang; + } + revision 2014-05-08 { + description + "Initial revision."; + reference + "RFC 7223: A YANG Data Model for Interface Management"; + } + feature if-mib { + description + "This feature indicates that the device implements + the IF-MIB."; + reference + "RFC 2863: The Interfaces Group MIB"; + } + container interfaces { + description + "Interface configuration parameters."; + + list interface { + key "name"; + leaf name { + type string; + } + leaf description { + type string; + } + leaf type { + type string; + mandatory true; + } + leaf link-up-down-trap-enable { + if-feature if-mib; + type enumeration { + enum enabled; + enum disabled; + } + } + } + } + container interfaces-state { + list interface { + key "name"; + leaf name { + type string; + } + leaf admin-status { + if-feature if-mib; + type enumeration { + enum up; + enum down; + enum testing; + } + mandatory true; + } + container statistics { + leaf in-octets { + type yang:counter64; + } + leaf in-unicast-pkts { + type yang:counter64; + } + } + } + } +} +EOF + +cat < $if2018 +module interfaces{ + yang-version 1.1; + namespace "urn:example:interfaces"; + prefix "if"; + + import ietf-yang-types { + prefix yang; + } + revision 2018-02-20 { + description + "Updated to support NMDA."; + reference + "RFC 8343: A YANG Data Model for Interface Management"; + } + revision 2014-05-08 { + description + "Initial revision."; + reference + "RFC 7223: A YANG Data Model for Interface Management"; + } + feature if-mib { + description + "This feature indicates that the device implements + the IF-MIB."; + reference + "RFC 2863: The Interfaces Group MIB"; + } + container interfaces { + description + "Interface configuration parameters."; + + list interface { + key "name"; + leaf name { + type string; + } + container docs{ + description "Original description is wrapped and renamed"; + leaf descr { + type string; + } + } + leaf type { + type string; + mandatory true; + } + leaf link-up-down-trap-enable { + if-feature if-mib; + type enumeration { + enum enabled; + enum disabled; + } + } + leaf admin-status { + if-feature if-mib; + type enumeration { + enum up; + enum down; + enum testing; + } + mandatory true; + } + container statistics { + leaf in-octets { + type decimal64{ + fraction-digits 3; + } + } + leaf in-unicast-pkts { + type yang:counter64; + } + } + } + } +} +EOF + +# Create startup db revision from 2014-05-08 to be upgraded to 2018-02-20 +# This is 2014 syntax +cat < $dir/startup_db +<${DATASTORE_TOP}> + + 42 + + interfaces + 2014-05-08 + urn:example:interfaces + + + + + e0 + eth + First interface + + + e1 + eth + + + + + e0 + up + + 54326432 + 8458765 + + + + e1 + down + + + e2 + testing + + + +EOF + +# Start from startup and upgrade, check running +function testrun(){ + runxml=$1 + + # -u means trigger example upgrade + new "test params: -s startup -f $cfg -- -u" + # Bring your own backend + if [ $BE -ne 0 ]; then + # kill old backend (if any) + new "kill old backend" + sudo clixon_backend -zf $cfg + if [ $? -ne 0 ]; then + err + fi + new "start backend -s startup -f $cfg -- -u" + start_backend -s startup -f $cfg -- -u + fi + + new "waiting" + wait_backend + + new "Check running db content" + expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$runxml]]>]]>$" + + 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 +} + +XML='e0First interfaceethup54326.4328458765e1ethdown' + +new "1. Upgrade from 2014 to 2018-02-20" +testrun "$XML" + +# This is "2016" syntax +cat < $dir/startup_db +<${DATASTORE_TOP}> + + 42 + + interfaces + 2016-01-01 + urn:example:interfaces + + + + + e0 + up + eth + First interface + + 54326432 + 8458765 + + + + e1 + eth + down + + + + + e0 + down + + 946743234 + 218347 + + + + e1 + up + + + e2 + testing + + + +EOF + +# 2. Upgrade from intermediate 2016-01-01 to 2018-02-20 +new "2. Upgrade from intermediate 2016-01-01 to 2018-02-20" +testrun "$XML" + +# Again 2014 syntax +cat < $dir/startup_db +<${DATASTORE_TOP}> + + 42 + + interfaces + 2014-05-08 + urn:example:interfaces + + + + + e0 + eth + First interface + + + e1 + eth + + + + + e0 + up + + 54326432 + 8458765 + + + + e1 + down + + + e2 + testing + + + + +EOF +rm $if2018 +# Original XML +XML='e0First interfaceethe1ethe0up543264328458765e1downe2testing' + +new "3. No 2018 (upgrade) model -> dont trigger upgrade" +testrun "$XML" + +#rm $if2014 +#new "4. No model at all" +#testrun "$XML" + +rm -rf $dir + +new "endtest" +endtest + + diff --git a/test/test_upgrade_module.sh b/test/test_upgrade_module.sh index d45c9458..19f970a0 100755 --- a/test/test_upgrade_module.sh +++ b/test/test_upgrade_module.sh @@ -91,9 +91,12 @@ EOF # - : there is modstate but module is not present (2) cat < $dir/startup2.xml <${DATASTORE_TOP}> - - 42 - + + 42 + + default + + $payload EOF @@ -102,14 +105,17 @@ EOF # $dir/startup3.xml <${DATASTORE_TOP}> - - 42 + + 42 + + default A 0814-01-28 urn:example:interfaces - + + $payload EOF @@ -118,14 +124,17 @@ EOF # =Y : there is modstate and revision is exactly Y (4) cat < $dir/startup4.xml <${DATASTORE_TOP}> - - 42 + + 42 + + default A 2016-01-01 urn:example:interfaces - + + $payload EOF @@ -134,14 +143,17 @@ EOF # >Y : there is modstate and revision is exactly Y (5) cat < $dir/startup5.xml <${DATASTORE_TOP}> - - 42 + + 42 + + default A 2018-01-01 urn:example:interfaces - + + $payload EOF diff --git a/test/test_upgrade_quit.sh b/test/test_upgrade_quit.sh index 3779ea1e..178e1dbd 100755 --- a/test/test_upgrade_quit.sh +++ b/test/test_upgrade_quit.sh @@ -218,14 +218,17 @@ EOF # This is 2014 syntax cat < $dir/startup_db <${DATASTORE_TOP}> - - 42 + + 42 + + default interfaces 2014-05-08 urn:example:interfaces - + + e0 @@ -263,14 +266,17 @@ EOF # This is 2014 syntax cat < $dir/startup_db <${DATASTORE_TOP}> - - 42 + + 42 + + default interfaces 2014-05-08 urn:example:interfaces - + + e0 @@ -303,7 +309,7 @@ cat < $dir/startup_db EOF -MODSTATE1="0clixon-lib${CLIXON_LIB_REV}http://clicon.org/lib" +MODSTATE1="defaultclixon-lib${CLIXON_LIB_REV}http://clicon.org/lib" MODSTATE2='interfaces2018-02-20urn:example:interfaces' diff --git a/test/test_upgrade_repair.sh b/test/test_upgrade_repair.sh index 6febe54d..c297dfa6 100755 --- a/test/test_upgrade_repair.sh +++ b/test/test_upgrade_repair.sh @@ -83,14 +83,17 @@ EOF # startup config XML with following (A obsolete, B OK, C lacking) cat < $dir/non-compat-invalid.xml <${DATASTORE_TOP}> - - 42 + + 42 + + default A 0814-01-28 urn:example:a - + + $OLDXML $SAMEXML diff --git a/test/test_upgrade_simple.sh b/test/test_upgrade_simple.sh index a8ad42e9..2a0bc14f 100755 --- a/test/test_upgrade_simple.sh +++ b/test/test_upgrade_simple.sh @@ -27,7 +27,7 @@ cat < $cfg true false init - false + false EOF diff --git a/test/test_xpath_functions.sh b/test/test_xpath_functions.sh index 79733f01..06da8ae0 100755 --- a/test/test_xpath_functions.sh +++ b/test/test_xpath_functions.sh @@ -27,7 +27,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - false + false EOF diff --git a/test/test_yang.sh b/test/test_yang.sh index d35e31cc..d9d6ce8e 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -23,7 +23,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true EOF @@ -176,8 +175,8 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-typesimplement" +new "netconf schema resource, RFC 8525" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "ietf-yang-types2013-07-15urn:ietf:params:xml:ns:yang:ietf-yang-types" new "netconf edit config" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO125one]]>]]>" "^]]>]]>$" diff --git a/test/test_yang_anydata.sh b/test/test_yang_anydata.sh index a54d9f39..f0c3d292 100755 --- a/test/test_yang_anydata.sh +++ b/test/test_yang_anydata.sh @@ -143,7 +143,7 @@ function testrun() /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - false + false $unknown $F $RESTCONFIG diff --git a/test/test_yang_bind.sh b/test/test_yang_bind.sh index b6307038..140dfa0d 100755 --- a/test/test_yang_bind.sh +++ b/test/test_yang_bind.sh @@ -37,7 +37,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - true EOF diff --git a/test/test_yang_deviation.sh b/test/test_yang_deviation.sh index eecb5a8e..4b4cd6a8 100755 --- a/test/test_yang_deviation.sh +++ b/test/test_yang_deviation.sh @@ -27,7 +27,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true EOF diff --git a/test/test_yang_extension.sh b/test/test_yang_extension.sh index d696ca42..9e911579 100755 --- a/test/test_yang_extension.sh +++ b/test/test_yang_extension.sh @@ -39,7 +39,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true + true EOF diff --git a/test/test_yang_namespace.sh b/test/test_yang_namespace.sh index 6f65857c..0ff9d1a1 100755 --- a/test/test_yang_namespace.sh +++ b/test/test_yang_namespace.sh @@ -28,7 +28,6 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME - true $RESTCONFIG EOF diff --git a/test/test_yang_when.sh b/test/test_yang_when.sh index 58ab7c29..a449d068 100755 --- a/test/test_yang_when.sh +++ b/test/test_yang_when.sh @@ -37,7 +37,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/var/$APPNAME/$APPNAME.pidfile $dir - false + false ${AUTOCLI} EOF diff --git a/yang/clixon/clixon-config@2022-02-11.yang b/yang/clixon/clixon-config@2022-02-11.yang index 77223600..a29e5be1 100644 --- a/yang/clixon/clixon-config@2022-02-11.yang +++ b/yang/clixon/clixon-config@2022-02-11.yang @@ -50,6 +50,9 @@ module clixon-config { description "Added option: CLICON_LOG_STRING_LIMIT + CLICON_YANG_LIBRARY + Changed default value: + CLICON_MODULE_LIBRARY_RFC7895 to false Removed (previosly marked) obsolete options: CLICON_RESTCONF_PATH CLICON_RESTCONF_PRETTY @@ -981,24 +984,41 @@ module clixon-config { If this option is set, Clixon disables NACM if a datastore does NOT contain a NACM config on load."; } - leaf CLICON_MODULE_LIBRARY_RFC7895 { + leaf CLICON_YANG_LIBRARY { type boolean; default true; description - "Enable RFC 7895 YANG Module library support as state data. If - enabled, module info will appear when doing netconf get or + "Enable YANG library support as state data according to RFC8525. + If enabled, module info will appear when doing netconf get or restconf GET. - See also CLICON_XMLDB_MODSTATE"; + The module state data is on the form: + ... + If CLICON_MODULE_LIBRARY_RFC7895 is set (as well), the module state uses RFC7895 + instead where the modile state is on the form: + ... + See also CLICON_XMLDB_MODSTATE where the module state info is used to tag datastores + with module information."; + } + leaf CLICON_MODULE_LIBRARY_RFC7895 { + type boolean; + default false; + description + "Enable RFC 7895 YANG Module library support as state data, instead of RFC8525. + Note CLICON_YANG_LIBRARY must be enabled for this to have effect. + See also CLICON_YANG_LIBRARY and CLICON_MODULE_SET_ID"; + status obsolete; } leaf CLICON_MODULE_SET_ID { type string; default "0"; - description "If RFC 7895 YANG Module library enabled: - Contains a server-specific identifier representing - the current set of modules and submodules. The - server MUST change the value of this leaf if the - information represented by the 'module' list instances - has changed."; + description + "Only if CLICON_YANG_LIBRARY enabled. + Contains a server-specific identifier representing the current set of modules + and submodules. The server MUST change the value of this leaf if the + information represented by the 'module' list instances has changed. + The /yang-library/content-id state-data leaf is set with this value + If CLICON_MODULE_LIBRARY_RFC7895 is enabled, it sets the modules-state/module-set-id + instead"; } leaf CLICON_STREAM_DISCOVERY_RFC5277 { type boolean;