From 98fb6eceef12cb7104751a9f7eaaaaf29a7f96fb Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 5 Mar 2019 14:35:49 +0100 Subject: [PATCH] * Clixon configuration file top-level symbols has changed to `clixon-config`and namespace check is enforced. * clixon-config YAML file has new revision: 2019-03-05. * New URN and changed top-level symbol to `clixon-config` * Removed obsolete `_CLICON_XML_NS_STRICT` variable and `CLICON_XML_NS_STRICT` config option. --- CHANGELOG.md | 19 ++++++- apps/backend/backend_client.c | 2 +- apps/netconf/netconf_rpc.c | 4 -- datastore/clixon_xmldb_text.c | 4 -- doc/FAQ.md | 6 ++- example/README.md | 2 +- example/example.xml | 4 +- example/example_backend.c | 4 +- lib/clixon/clixon_xml.h | 8 --- lib/clixon/clixon_xml_map.h | 1 - lib/src/clixon_options.c | 50 +++++++++++++---- lib/src/clixon_stream.c | 1 + lib/src/clixon_xml.c | 10 ---- lib/src/clixon_xml_map.c | 54 ------------------- lib/src/clixon_xml_sort.c | 9 ++-- lib/src/clixon_yang.c | 11 ++-- test/{test_augment.yang => test_augment.sh} | 4 +- test/test_choice.sh | 4 +- test/test_cli.sh | 4 +- test/test_copy_config.sh | 4 +- test/test_feature.sh | 4 +- test/test_identity.sh | 4 +- test/test_json.sh | 2 +- test/test_leafref.sh | 4 +- test/test_list.sh | 4 +- test/test_nacm.sh | 4 +- test/test_nacm_ext.sh | 4 +- test/test_nacm_module_read.sh | 6 +-- test/test_nacm_module_write.sh | 4 +- test/test_nacm_protocol.sh | 4 +- test/test_netconf.sh | 4 +- test/test_openconfig.sh | 4 +- test/test_order.sh | 4 +- test/test_perf.sh | 4 +- test/test_restconf.sh | 4 +- test/test_restconf2.sh | 4 +- test/test_rpc.sh | 4 +- test/test_startup.sh | 4 +- test/test_stream.sh | 16 +++--- test/test_type.sh | 4 +- test/test_union.sh | 4 +- test/test_upgrade.sh | 4 +- test/test_when_must.sh | 4 +- test/test_yang.sh | 4 +- test/test_yang_load.sh | 32 +++++------ test/test_yang_namespace.sh | 5 +- test/test_yangmodels.sh | 4 +- util/clixon_util_datastore.c | 1 - yang/clixon/Makefile.in | 2 +- ...-06.yang => clixon-config@2019-03-05.yang} | 21 +++----- 50 files changed, 167 insertions(+), 211 deletions(-) rename test/{test_augment.yang => test_augment.sh} (98%) rename yang/clixon/{clixon-config@2019-02-06.yang => clixon-config@2019-03-05.yang} (95%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b652624..06ed66a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,13 +21,28 @@ * Note that this adds bytes to your configs ### API changes on existing features (you may need to change your code) -* Strict XML Prefixed namespace check. This means all XML namespaces must always be declared by default or prefixed attribute name. There were some cases where this was not enforced. Example, `y` must be declared: +* Clixon configuration file top-level symbols has changed to `clixon-config`and namespace check is enforced. This means all Clixon configuration files must change from: +``` + + ... + +``` +to: +``` + + ... + +``` +* Strict XML prefixed namespace check. This means all XML namespaces must always be declared by default or prefixed attribute name. There were some cases where this was not enforced. Example, `y` must be declared: ``` --> ``` ### Minor changes -* Removed obsolete `CLICON_CLI_MODEL_TREENAME_PATCH` +* clixon-config YAML file has new revision: 2019-03-05. + * New URN and changed top-level symbol to `clixon-config` +* Removed obsolete `_CLICON_XML_NS_STRICT` variable and `CLICON_XML_NS_STRICT` config option. +* Removed obsolete `CLICON_CLI_MODEL_TREENAME_PATCH` constant * Added specific clixon_suberrno code: XMLPARSE_ERRNO to identify XML parse errors. * Removed all dependency on strverscmp * Added libgen.h for baseline() diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index b08888ef..c6d407ac 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -503,7 +503,7 @@ from_client_edit_config(clicon_handle h, goto ok; } else{ - /* yang spec may be set to anyxmly by ingress yang check,...*/ + /* yang spec may be set to anyxml by ingress yang check,...*/ if (xml_spec(xc) != NULL) xml_spec_set(xc, NULL); /* Populate XML with Yang spec (why not do this in parser?) diff --git a/apps/netconf/netconf_rpc.c b/apps/netconf/netconf_rpc.c index fc034abf..e6aa684d 100644 --- a/apps/netconf/netconf_rpc.c +++ b/apps/netconf/netconf_rpc.c @@ -580,10 +580,6 @@ netconf_application_rpc(clicon_handle h, goto ok; } yrpc = yang_find((yang_node*)ymod, Y_RPC, xml_name(xn)); - if ((yrpc==NULL) && !_CLICON_XML_NS_STRICT){ - if (xml_yang_find_non_strict(xn, yspec, &yrpc) < 0) /* Y_RPC */ - goto done; - } /* Check if found */ if (yrpc != NULL){ /* 1. Check xn arguments with input statement. */ diff --git a/datastore/clixon_xmldb_text.c b/datastore/clixon_xmldb_text.c index 4090c97d..eb430023 100644 --- a/datastore/clixon_xmldb_text.c +++ b/datastore/clixon_xmldb_text.c @@ -1246,10 +1246,6 @@ text_modify_top(struct text_handle *th, goto done; if (ymod != NULL) yc = yang_find_datanode((yang_node*)ymod, x1cname); - if (yc == NULL && !_CLICON_XML_NS_STRICT){ - if (xml_yang_find_non_strict(x1c, yspec, &yc) < 0) - goto done; - } if (yc == NULL){ if (netconf_unknown_element(cbret, "application", x1cname, "Unassigned yang spec") < 0) goto done; diff --git a/doc/FAQ.md b/doc/FAQ.md index 779e605c..c18fb038 100644 --- a/doc/FAQ.md +++ b/doc/FAQ.md @@ -189,6 +189,8 @@ configuration file is /usr/local/etc/clixon.xml. The example configuration file is installed at /usr/local/etc/example.xml. The YANG specification for the configuration file is clixon-config.yang. +See the [example config file](../example/example.xml). + ## How are Clixon configuration files found? Clixon by default finds its configuration file at `/usr/local/etc/clixon.xml`. However, you can modify this location as follows: @@ -308,10 +310,10 @@ clixon_backend ... -s running You may also add a default method in the configuration file: ``` - + ... init + ``` ## Can I use systemd with Clixon? diff --git a/example/README.md b/example/README.md index 30aaa294..38d0f4ee 100644 --- a/example/README.md +++ b/example/README.md @@ -15,7 +15,7 @@ ## Content This directory contains a Clixon example which includes a simple example. It contains the following files: -* `example.xml` The configuration file. See (yang/clixon-config@.yang)[../yang/clixon-config@2018-10-21.yang] for the documentation of all available fields. +* `example.xml` The configuration file. See [yang/clixon-config@.yang](../yang/clixon-config@2018-10-21.yang) for the documentation of all available fields. * `clixon-example@2019-01-13.yang` The yang spec of the example. * `example_cli.cli` CLIgen specification. * `example_cli.c` CLI callback plugin containing functions called in the cli file above: a generic callback (`mycallback`) and an example RPC call (`example_client_rpc`). diff --git a/example/example.xml b/example/example.xml index aaf202b0..3d3cf99b 100644 --- a/example/example.xml +++ b/example/example.xml @@ -1,4 +1,4 @@ - + /usr/local/etc/example.xml *:* /usr/local/share/clixon @@ -18,4 +18,4 @@ 0 init disabled - + diff --git a/example/example_backend.c b/example/example_backend.c index 7d1130c7..9ee40c26 100644 --- a/example/example_backend.c +++ b/example/example_backend.c @@ -95,7 +95,7 @@ transaction_commit(clicon_handle h, return 0; } -/*! Routing example notifcation timer handler. Here is where the periodic action is +/*! Routing example notification timer handler. Here is where the periodic action is */ static int example_stream_timer(int fd, @@ -105,7 +105,7 @@ example_stream_timer(int fd, clicon_handle h = (clicon_handle)arg; /* XXX Change to actual netconf notifications and namespace */ - if (stream_notify(h, "EXAMPLE", "faultEthernet0major") < 0) + if (stream_notify(h, "EXAMPLE", "faultEthernet0major") < 0) goto done; if (example_stream_timer_setup(h) < 0) goto done; diff --git a/lib/clixon/clixon_xml.h b/lib/clixon/clixon_xml.h index 4775f97b..69655697 100644 --- a/lib/clixon/clixon_xml.h +++ b/lib/clixon/clixon_xml.h @@ -86,14 +86,6 @@ typedef int (xml_applyfn_t)(cxobj *x, void *arg); #define XML_FLAG_CHANGE 0x08 /* Node is changed (commits) or child changed rec */ #define XML_FLAG_NONE 0x10 /* Node is added as NONE */ -/* Iterate through modules to find the matching datanode - * or rpc if no xmlns attribute specifies namespace. - * This is lazy non-strict semantics of finding namespaces. - * And it is wrong, but is the way Clixon originally was written." - * @see CLICON_XML_NS_STRICT clixon configure option - */ -extern int _CLICON_XML_NS_STRICT; - /* * Prototypes */ diff --git a/lib/clixon/clixon_xml_map.h b/lib/clixon/clixon_xml_map.h index 2fa2afeb..afc04b3c 100644 --- a/lib/clixon/clixon_xml_map.h +++ b/lib/clixon/clixon_xml_map.h @@ -49,7 +49,6 @@ int xml_yang_validate_rpc(cxobj *xrpc, cbuf *cbret); int xml_yang_validate_add(cxobj *xt, cbuf *cbret); int xml_yang_validate_all(cxobj *xt, cbuf *cbret); int xml_yang_validate_all_top(cxobj *xt, cbuf *cbret); -int xml_yang_find_non_strict(cxobj *x, yang_spec *yspec, yang_stmt **y); int xml2cvec(cxobj *xt, yang_stmt *ys, cvec **cvv0); int cvec2xml_1(cvec *cvv, char *toptag, cxobj *xp, cxobj **xt0); int xml_diff(yang_spec *yspec, cxobj *xt1, cxobj *xt2, diff --git a/lib/src/clixon_options.c b/lib/src/clixon_options.c index 4563b4e4..4253e283 100644 --- a/lib/src/clixon_options.c +++ b/lib/src/clixon_options.c @@ -167,9 +167,26 @@ parse_configfile(clicon_handle h, clicon_err(OE_CFG, 0, "Config file %s: Expected XML but is probably old sh style", filename); goto done; } - if ((xc = xpath_first(xt, "config")) == NULL) { - clicon_err(OE_CFG, 0, "Config file %s: Lacks top-level \"config\" element", filename); - goto done; + /* Hard-coded config for < 3.10 and clixon-config for >= 3.10 */ + if ((xc = xpath_first(xt, "clixon-config")) == NULL){ + /* Backward compatible code to accept "config" as top-level symbol. + This cannot be controlled by config option due to bootstrap */ +#if 0 + if ((xc = xpath_first(xt, "config")) != NULL){ + if (xml_name_set(xc, "clixon-config") < 0) + goto done; + if (xml_apply0(xc, CX_ELMNT, xml_spec_populate, yspec) < 0) + goto done; + if (xml_apply0(xc, CX_ELMNT, xml_sort, NULL) < 0) + goto done; + } + else +#endif + { + clicon_err(OE_CFG, 0, "Config file %s: Lacks top-level \"clixon_config\" element\nClixon config files should begin with: ", filename); + + goto done; + } } if (xml_apply0(xc, CX_ELMNT, xml_default, yspec) < 0) goto done; @@ -286,18 +303,23 @@ clicon_options_main(clicon_handle h, } configfile = hash_value(copt, "CLICON_CONFIGFILE", NULL); clicon_debug(1, "CLICON_CONFIGFILE=%s", configfile); - /* If file ends with .xml, assume it is new format */ + /* File must end with .xml */ if ((suffix = rindex(configfile, '.')) != NULL){ suffix++; xml = strcmp(suffix, "xml") == 0; } if (xml == 0){ - clicon_err(OE_CFG, 0, "%s: suffix %s not recognized (Run ./configure --with-config-compat?)", configfile, suffix); + clicon_err(OE_CFG, 0, "%s: suffix %s not recognized", configfile, suffix); goto done; } - /* XXX Kludge to low-level functions to search for xml in all yang modules */ - _CLICON_XML_NS_STRICT = 0; - /* Read configfile first without yangspec, for bootstrapping */ + /* Read configfile first without yangspec, for bootstrapping, see second + * time below with proper yangspec. + * (You need to read the config-file to get the YANG_DIR to find the + * the clixon yang-spec) + * Difference from parsing with yangspec is: + * - no default values + * - no sanity checks + */ if (parse_configfile(h, configfile, yspec, &xconfig) < 0) goto done; if (xml_rootchild(xconfig, 0, &xconfig) < 0) @@ -308,17 +330,23 @@ clicon_options_main(clicon_handle h, if (yang_spec_parse_module(h, "clixon-config", NULL, yspec) < 0) goto done; clicon_conf_xml_set(h, NULL); - if (xconfig) + if (xconfig){ xml_free(xconfig); + xconfig = NULL; + } /* Read configfile second time now with check yang spec */ if (parse_configfile(h, configfile, yspec, &xconfig) < 0) goto done; if (xml_rootchild(xconfig, 0, &xconfig) < 0) goto done; + if (xml_spec(xconfig) == NULL){ + clicon_err(OE_CFG, 0, "Config file %s: did not find corresponding Yang specification\nHint: File does not begin with: or clixon-config.yang not found?", configfile); + + goto done; + } /* Set clixon_conf pointer to handle */ clicon_conf_xml_set(h, xconfig); - /* XXX Kludge to low-level functions to search for xml in all yang modules */ - _CLICON_XML_NS_STRICT = clicon_option_bool(h, "CLICON_XML_NS_STRICT"); + retval = 0; done: return retval; diff --git a/lib/src/clixon_stream.c b/lib/src/clixon_stream.c index dbc5467a..0dd246ad 100644 --- a/lib/src/clixon_stream.c +++ b/lib/src/clixon_stream.c @@ -579,6 +579,7 @@ stream_notify(clicon_handle h, clicon_err(OE_UNIX, errno, "time2str"); goto done; } + /* From RFC5277 */ cprintf(cb, "%s%s", timestr, str); if (xml_parse_string(cbuf_get(cb), yspec, &xev) < 0) goto done; diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index 3ae3cae0..7b346887 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -135,16 +135,6 @@ struct xml{ /* * Variables */ -/* If set to 1 which is default, strict namespace checking of XML is made. - * If set to 0, "loose" namespace semantics is applied. - * This means: iterate through all yang modules to find matching datanode - * or rpc if no xmlns attribute specifies namespace. - * This is _wrong_, but is the way Clixon originally was written, and some - * code still relies on it. - * This, of course, should change. - * @see CLICON_XML_NS_STRICT clixon configure option - */ -int _CLICON_XML_NS_STRICT = 1; /* Mapping between xml type <--> string */ static const map_str2int xsmap[] = { diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c index 0eb54de4..74400f2d 100644 --- a/lib/src/clixon_xml_map.c +++ b/lib/src/clixon_xml_map.c @@ -835,47 +835,6 @@ xml_yang_validate_all_top(cxobj *xt, return 1; } -/*! Given XML node x, find yang spec in _any_ module matching name - * This is non-struct namespace semantics (not correct) but necessary - * in historic Clixon code. - * Also, add a proper default namespaces statement (xmlns="uri") in x - * @param[in] x XML node (find yang statement on this one) - * @param[in] yspec Top-level yang spec - * @param[out] y Yang stmt associated to x. NULL i not found - * @retval 0 OK - * @see CLICON_XML_NS_STRICT clixon config option - */ -int -xml_yang_find_non_strict(cxobj *x, - yang_spec *yspec, - yang_stmt **yp) -{ - int retval = -1; - char *name; - yang_stmt *ymod; - int i; - yang_stmt *y=NULL; - char *ns; - - name = xml_name(x); - for (i=0; iyp_len; i++){ - ymod = yspec->yp_stmt[i]; - if ((y = yang_find_schemanode((yang_node*)ymod, name)) != NULL) - break; - } - if (y){ - *yp = y; - if ((ns = yang_find_mynamespace(ymod)) != NULL){ - if (xml_find_type_value(x, NULL, "xmlns", CX_ATTR) == NULL) - if (xmlns_set(x, NULL, ns) < 0) - goto done; - } - } - retval = 0; - done: - return retval; -} - /*! Translate a single xml node to a cligen variable vector. Note not recursive * @param[in] xt XML tree containing one top node * @param[in] ys Yang spec containing type specification of top-node of xt @@ -1738,11 +1697,6 @@ xml_spec_populate_rpc(clicon_handle h, yrpc = yang_find((yang_node*)ymod, Y_RPC, xml_name(x)); /* Non-strict semantics: loop through all modules to find the node */ - if (yrpc == NULL && - !clicon_option_bool(h, "CLICON_XML_NS_STRICT")){ - if (xml_yang_find_non_strict(x, yspec, &yrpc) < 0) /* find rpc */ - goto done; - } if (yrpc){ xml_spec_set(x, yrpc); if ((yi = yang_find((yang_node*)yrpc, Y_INPUT, NULL)) != NULL){ @@ -1758,14 +1712,12 @@ xml_spec_populate_rpc(clicon_handle h, return retval; } - /*! Add yang specification backpointer to XML node * @param[in] xt XML tree node * @param[in] arg Yang spec * @note This may be unnecessary if yspec is set on creation * @note For subs to anyxml nodes will not have spec set * @note No validation is done,... XXX - * @note relies on kludge _CLICON_XML_NS_STRICT * @code * xml_apply(xc, CX_ELMNT, xml_spec_populate, yspec) * @endcode @@ -1795,12 +1747,6 @@ xml_spec_populate(cxobj *x, goto done; if (ymod != NULL) y = yang_find_schemanode((yang_node*)ymod, name); - /* Non-strict semantics: loop through all modules to find the node - */ - if (y == NULL && !_CLICON_XML_NS_STRICT){ - if (xml_yang_find_non_strict(x, yspec, &y) < 0) - goto done; - } } if (y) xml_spec_set(x, y); diff --git a/lib/src/clixon_xml_sort.c b/lib/src/clixon_xml_sort.c index 395d6e4a..77adca38 100644 --- a/lib/src/clixon_xml_sort.c +++ b/lib/src/clixon_xml_sort.c @@ -156,7 +156,10 @@ xml_child_spec(cxobj *x, char *name; name = xml_name(x); + if (xp && (yparent = xml_spec(xp)) != NULL){ + /* First case: parent already has an associated yang statement, + * then find matching child of that */ if (yparent->ys_keyword == Y_RPC){ if ((yi = yang_find((yang_node*)yparent, Y_INPUT, NULL)) != NULL) y = yang_find_datanode((yang_node*)yi, name); @@ -165,14 +168,12 @@ xml_child_spec(cxobj *x, y = yang_find_datanode((yang_node*)yparent, name); } else if (yspec){ + /* Second case, this is a "root", need to find yang stmt from spec + */ if (ys_module_by_xml(yspec, xp, &ymod) < 0) goto done; if (ymod != NULL) y = yang_find_schemanode((yang_node*)ymod, name); - if (y == NULL && !_CLICON_XML_NS_STRICT){ - if (xml_yang_find_non_strict(x, yspec, &y) < 0) /* schemanode */ - goto done; - } } else y = NULL; diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index d1869665..168b7926 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -1801,12 +1801,13 @@ yang_expand(yang_node *yn) * Syntax parsing. A string is input and a syntax-tree is returned (or error). * A variable record is also returned containing a list of (global) variable values. * (cloned from cligen) - * @param[in] h CLICON handle - * @param[in] str String of yang statements - * @param[in] name Log string, typically filename - * @param[in] ysp Yang specification. Should ave been created by caller using yspec_new + * @param[in] h CLICON handle + * @param[in] str String of yang statements + * @param[in] name Log string, typically filename + * @param[in] ysp Yang specification. Should ave been created by caller + * using yspec_new * @retval ymod Top-level yang (sub)module - * @retval NULL Error encountered + * @retval NULL Error encountered * Calling order: * yang_parse # Parse top-level yang module. Expand and populate yang tree * yang_parse_recurse # Parse one yang module, go through its (sub)modules, parse them and then recursively parse them diff --git a/test/test_augment.yang b/test/test_augment.sh similarity index 98% rename from test/test_augment.yang rename to test/test_augment.sh index bc2fe89e..e1904a0a 100755 --- a/test/test_augment.yang +++ b/test/test_augment.sh @@ -18,7 +18,7 @@ fyang=$dir/main.yang fyang2=$dir/ietf-interfaces@2019-03-04.yang cat < $cfg - + $cfg a:test $dir @@ -32,7 +32,7 @@ cat < $cfg /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so true - + EOF # Stub ietf-interfaces for test diff --git a/test/test_choice.sh b/test/test_choice.sh index 53d2a4ea..a281cf54 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -15,7 +15,7 @@ cfg=$dir/choice.xml fyang=$dir/type.yang cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -30,7 +30,7 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF cat < $fyang diff --git a/test/test_cli.sh b/test/test_cli.sh index 66f0005c..7a88c740 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -19,7 +19,7 @@ cfg=$dir/conf_yang.xml # Use yang in example cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -33,7 +33,7 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF new "test params: -f $cfg" diff --git a/test/test_copy_config.sh b/test/test_copy_config.sh index a92262bd..3cde38e9 100755 --- a/test/test_copy_config.sh +++ b/test/test_copy_config.sh @@ -31,7 +31,7 @@ cfg=$dir/conf_yang.xml # Use yang in example cat < $cfg - + $cfg 42 /usr/local/share/clixon @@ -49,7 +49,7 @@ cat < $cfg 1 $dir /usr/local/lib/xmldb/text.so - + EOF # Create empty startup diff --git a/test/test_feature.sh b/test/test_feature.sh index 7653f153..7c6622eb 100755 --- a/test/test_feature.sh +++ b/test/test_feature.sh @@ -11,7 +11,7 @@ fyang=$dir/test.yang # Note ietf-routing@2018-03-13 assumed cat < $cfg - + $APPNAME:A ietf-routing:router-id $cfg @@ -27,7 +27,7 @@ cat < $cfg /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so true - + EOF cat < $fyang diff --git a/test/test_identity.sh b/test/test_identity.sh index ea92d00a..0a60d67c 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -10,7 +10,7 @@ cfg=$dir/conf_yang.xml fyang=$dir/example-my-crypto.yang cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -27,7 +27,7 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF # Example from RFC7950 Sec 7.18 and 9.10 diff --git a/test/test_json.sh b/test/test_json.sh index f15b6ca3..7511c002 100755 --- a/test/test_json.sh +++ b/test/test_json.sh @@ -1,6 +1,6 @@ #!/bin/bash # Test: JSON parser tests -# Note that nmbers shouldnot be quoted. See test_restconf2.sh for typed +# Note that members should not be quoted. See test_restconf2.sh for typed #PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_json" # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi diff --git a/test/test_leafref.sh b/test/test_leafref.sh index 7e53f71d..a596a4f7 100755 --- a/test/test_leafref.sh +++ b/test/test_leafref.sh @@ -10,7 +10,7 @@ cfg=$dir/conf_yang.xml fyang=$dir/leafref.yang cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -24,7 +24,7 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF cat < $fyang diff --git a/test/test_list.sh b/test/test_list.sh index ceaf7cb9..b43b4d95 100755 --- a/test/test_list.sh +++ b/test/test_list.sh @@ -10,7 +10,7 @@ cfg=$dir/conf_yang.xml fyang=$dir/test.yang cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -23,7 +23,7 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF cat < $fyang diff --git a/test/test_nacm.sh b/test/test_nacm.sh index caba05e3..6c570e49 100755 --- a/test/test_nacm.sh +++ b/test/test_nacm.sh @@ -15,7 +15,7 @@ cfg=$dir/conf_yang.xml fyang=$dir/nacm-example.yang cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -32,7 +32,7 @@ cat < $cfg /usr/local/lib/xmldb/text.so false internal - + EOF cat < $fyang diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh index 072d0049..db9d7c07 100755 --- a/test/test_nacm_ext.sh +++ b/test/test_nacm_ext.sh @@ -17,7 +17,7 @@ nacmfile=$dir/nacmfile # Note filter out example_backend_nacm.so in CLICON_BACKEND_REGEXP below cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -36,7 +36,7 @@ cat < $cfg false external $nacmfile - + EOF cat < $fyang diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh index b18e3540..008f2aef 100755 --- a/test/test_nacm_module_read.sh +++ b/test/test_nacm_module_read.sh @@ -30,7 +30,7 @@ cfg=$dir/conf_yang.xml fyang=$dir/nacm-example.yang cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -47,7 +47,7 @@ cat < $cfg /usr/local/lib/xmldb/text.so false internal - + EOF cat < $fyang @@ -235,7 +235,7 @@ expecteq "$(curl -u guest:bar -sS -X GET http://localhost/restconf/data)" 0 '{"i #------- RPC operation new "admin rpc ok" -expecteq "$(curl -u andy:bar -s -X POST -d '{"clixon-example:input":{"x":42}}' http://localhost/restconf/operations/clixon-example:example)" 0 '{"clixon-example:output": {"x": "42","y": "42"}} +expecteq "$(curl -u andy:bar -s -X POST -d '{"clixon-example:input":{"x":"78"}}' http://localhost/restconf/operations/clixon-example:example)" 0 '{"clixon-example:output": {"x": "78","y": "42"}} ' new "admin rpc netconf ok" diff --git a/test/test_nacm_module_write.sh b/test/test_nacm_module_write.sh index 53bf1da3..92aa0a01 100755 --- a/test/test_nacm_module_write.sh +++ b/test/test_nacm_module_write.sh @@ -32,7 +32,7 @@ cfg=$dir/conf_yang.xml fyang=$dir/nacm-example.yang cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -49,7 +49,7 @@ cat < $cfg /usr/local/lib/xmldb/text.so false internal - + EOF cat < $fyang diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh index 2a4487f0..2e38f83c 100755 --- a/test/test_nacm_protocol.sh +++ b/test/test_nacm_protocol.sh @@ -35,7 +35,7 @@ cfg=$dir/conf_yang.xml fyang=$dir/nacm-example.yang cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -52,7 +52,7 @@ cat < $cfg /usr/local/lib/xmldb/text.so false internal - + EOF cat < $fyang diff --git a/test/test_netconf.sh b/test/test_netconf.sh index c332fe89..fc8a08f7 100755 --- a/test/test_netconf.sh +++ b/test/test_netconf.sh @@ -12,7 +12,7 @@ tmp=$dir/tmp.x # Use yang in example cat < $cfg - + $cfg 42 /usr/local/share/clixon @@ -30,7 +30,7 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF new "test params: -f $cfg" diff --git a/test/test_openconfig.sh b/test/test_openconfig.sh index e6f1fd9f..387b25c9 100755 --- a/test/test_openconfig.sh +++ b/test/test_openconfig.sh @@ -25,7 +25,7 @@ OCDIR=$OPENCONFIG/release/models cat < $cfg - + $cfg $OCDIR $OCDIR/acl @@ -74,7 +74,7 @@ cat < $cfg /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so true - + EOF files=$(find $OPENCONFIG -name "*.yang") diff --git a/test/test_order.sh b/test/test_order.sh index 3a9fc7ba..623b06c0 100755 --- a/test/test_order.sh +++ b/test/test_order.sh @@ -26,7 +26,7 @@ if [ ! -d $dbdir ]; then fi cat < $cfg - + /tmp/conf_yang.xml /usr/local/share/clixon $IETFRFC @@ -39,7 +39,7 @@ cat < $cfg 1 $dbdir /usr/local/lib/xmldb/text.so - + EOF cat < $fyang diff --git a/test/test_perf.sh b/test/test_perf.sh index 2bb07d15..9e703236 100755 --- a/test/test_perf.sh +++ b/test/test_perf.sh @@ -39,7 +39,7 @@ module scaling{ EOF cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -51,7 +51,7 @@ cat < $cfg /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so false - + EOF new "test params: -f $cfg -y $fyang" diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 84ed9212..2da7c78b 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -12,7 +12,7 @@ cfg=$dir/conf.xml # Use yang in example cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -30,7 +30,7 @@ cat < $cfg /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so true - + EOF # This is a fixed 'state' implemented in routing_backend. It is assumed to be always there diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh index e4e8de20..770c87f4 100755 --- a/test/test_restconf2.sh +++ b/test/test_restconf2.sh @@ -12,7 +12,7 @@ fyang=$dir/restconf.yang # example cat < $cfg - + $cfg /usr/local/var /usr/local/share/clixon @@ -22,7 +22,7 @@ cat < $cfg $dir/restconf.pidfile /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF cat < $fyang diff --git a/test/test_rpc.sh b/test/test_rpc.sh index 084c136e..989c6f9f 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -15,7 +15,7 @@ cfg=$dir/conf.xml # Use yang in example cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -30,7 +30,7 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF new "test params: -f $cfg" diff --git a/test/test_startup.sh b/test/test_startup.sh index 9a37fb0a..03f9d5a8 100755 --- a/test/test_startup.sh +++ b/test/test_startup.sh @@ -15,7 +15,7 @@ APPNAME=example cfg=$dir/conf_startup.xml cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -32,7 +32,7 @@ cat < $cfg /usr/local/lib/xmldb/text.so 0 init - + EOF diff --git a/test/test_stream.sh b/test/test_stream.sh index e04a2041..64f14d76 100755 --- a/test/test_stream.sh +++ b/test/test_stream.sh @@ -35,7 +35,7 @@ xml=$dir/xml.xml # example cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -55,7 +55,7 @@ cat < $cfg streams https://localhost 60 - + EOF # For nchan testing add this line to above config @@ -179,7 +179,7 @@ expectwait 'curl -s -X GET -H "Accept: text/event-stream" -H "Cache-Control: no- # 2a) start subscription 8s - expect 1-2 notifications new "2a) start subscriptions 8s - expect 1-2 notifications" ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 8) -expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" +expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" match=$(echo "$ret" | grep -Eo "$expect") if [ -z "$match" ]; then @@ -195,7 +195,7 @@ sleep 2 # 2b) start subscription 8s - stoptime after 5s - expect 1-2 notifications new "2b) start subscriptions 8s - stoptime after 5s - expect 1-2 notifications" ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 8 -e +10) -expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" +expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" match=$(echo "$ret" | grep -Eo "$expect") if [ -z "$match" ]; then err "$expect" "$ret" @@ -208,7 +208,7 @@ fi # 2c new "2c) start sub 8s - replay from start -8s - expect 3-4 notifications" ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 10 -s -8) -expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" +expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" match=$(echo "$ret" | grep -Eo "$expect") if [ -z "$match" ]; then err "$expect" "$ret" @@ -221,7 +221,7 @@ fi # 2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications new "2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications" ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 10 -s -30 -e +4) -expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" +expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" match=$(echo "$ret" | grep -Eo "$expect") if [ -z "$match" ]; then err "$expect" "$ret" @@ -234,7 +234,7 @@ fi # 2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications new "2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications" ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 10 -s -90 -e +0) -expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" +expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" match=$(echo "$ret" | grep -Eo "$expect") if [ -z "$match" ]; then err "$expect" "$ret" @@ -252,7 +252,7 @@ PID=$! new "Start subscriptions in parallell" ret=$($clixon_util_stream -u http://localhost/streams/EXAMPLE -t 8) -expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" +expect="data: ${DATE}T[0-9:.]*ZfaultEthernet0major" match=$(echo "$ret" | grep -Eo "$expect") if [ -z "$match" ]; then diff --git a/test/test_type.sh b/test/test_type.sh index 9304e565..d766a3ed 100755 --- a/test/test_type.sh +++ b/test/test_type.sh @@ -13,7 +13,7 @@ fyang2=$dir/example2.yang fyang3=$dir/example3.yang cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -27,7 +27,7 @@ cat < $cfg /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so false - + EOF # transitive type, exists in fyang3, referenced from fyang2, but not declared in fyang diff --git a/test/test_union.sh b/test/test_union.sh index a8805d2a..a2d2bf46 100755 --- a/test/test_union.sh +++ b/test/test_union.sh @@ -13,7 +13,7 @@ fyang2=$dir/example2.yang fyang3=$dir/example3.yang cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -26,7 +26,7 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF # transitive type, exists in fyang3, referenced from fyang2, but not declared in fyang diff --git a/test/test_upgrade.sh b/test/test_upgrade.sh index d76cd237..a6f0b84e 100755 --- a/test/test_upgrade.sh +++ b/test/test_upgrade.sh @@ -96,7 +96,7 @@ EOF # Create configuration cat < $cfg - + $cfg /usr/local/share/clixon $dir @@ -109,7 +109,7 @@ cat < $cfg /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME - + EOF # Create failsafe db diff --git a/test/test_when_must.sh b/test/test_when_must.sh index 6b288373..1c65bde3 100755 --- a/test/test_when_must.sh +++ b/test/test_when_must.sh @@ -11,7 +11,7 @@ cfg=$dir/conf_yang.xml fyang=$dir/test.yang cat < $cfg - + $cfg /usr/local/share/clixon $IETFRFC @@ -23,7 +23,7 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF cat < $fyang diff --git a/test/test_yang.sh b/test/test_yang.sh index 764d7589..a4b67cf9 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -12,7 +12,7 @@ fsubmod=$dir/example-types.yang fyangerr=$dir/err.yang cat < $cfg - + $cfg /usr/local/share/clixon $dir @@ -26,7 +26,7 @@ cat < $cfg /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so true - + EOF cat < $fyang diff --git a/test/test_yang_load.sh b/test/test_yang_load.sh index cbf14965..c315e400 100755 --- a/test/test_yang_load.sh +++ b/test/test_yang_load.sh @@ -54,7 +54,7 @@ EOF #--------------------------------- new "1. Load module as file" cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -68,7 +68,7 @@ cat < $cfg /usr/local/lib/$APPNAME/cli $APPNAME 1 - + EOF new "test params: -f $cfg" @@ -111,7 +111,7 @@ sudo pkill -u root -f clixon_backend #-------------------------------------- new "2. Load old module as file" cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -125,7 +125,7 @@ cat < $cfg /usr/local/lib/$APPNAME/cli $APPNAME 1 - + EOF new "start backend -s init -f $cfg" @@ -157,7 +157,7 @@ sudo pkill -u root -f clixon_backend #-------------------------------------- new "3. Load module with no revision" cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -167,7 +167,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF new "start backend -s init -f $cfg" @@ -197,7 +197,7 @@ sudo pkill -u root -f clixon_backend #-------------------------------------- new "4. Load module with old revision" cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -208,7 +208,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF new "start backend -s init -f $cfg" @@ -239,7 +239,7 @@ sudo pkill -u root -f clixon_backend #-------------------------------------- new "5. Load dir" cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -249,7 +249,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF new "start backend -s init -f $cfg" @@ -280,7 +280,7 @@ sudo pkill -u root -f clixon_backend #-------------------------------------- new "6. Load dir override with file" cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -291,7 +291,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF new "start backend -s init -f $cfg" @@ -323,7 +323,7 @@ sudo pkill -u root -f clixon_backend #-------------------------------------- new "7. Load dir override with module + revision" cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -335,7 +335,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF new "start backend -s init -f $cfg" @@ -366,7 +366,7 @@ sudo pkill -u root -f clixon_backend #-------------------------------------- new "8. Load module w new revision overrided by old file" cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -378,7 +378,7 @@ cat < $cfg /usr/local/var/$APPNAME/$APPNAME.pidfile /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - + EOF new "start backend -s init -f $cfg" diff --git a/test/test_yang_namespace.sh b/test/test_yang_namespace.sh index 7e73b145..2043ac69 100755 --- a/test/test_yang_namespace.sh +++ b/test/test_yang_namespace.sh @@ -14,7 +14,7 @@ fyang1=$dir/example1.yang fyang2=$dir/example2.yang cat < $cfg - + $cfg $dir /usr/local/share/clixon @@ -28,9 +28,8 @@ cat < $cfg 1 /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so - true true - + EOF diff --git a/test/test_yangmodels.sh b/test/test_yangmodels.sh index 12d83d3a..fde9410c 100755 --- a/test/test_yangmodels.sh +++ b/test/test_yangmodels.sh @@ -32,7 +32,7 @@ fi # Experimental IEEE cat < $cfg - + $cfg $YANGMODELS/standard/ietf/RFC $YANGMODELS/standard/ieee/draft @@ -47,7 +47,7 @@ cat < $cfg /usr/local/var/$APPNAME /usr/local/lib/xmldb/text.so true - + EOF new "yangmodels parse: -f $cfg" diff --git a/util/clixon_util_datastore.c b/util/clixon_util_datastore.c index 01425268..22983092 100644 --- a/util/clixon_util_datastore.c +++ b/util/clixon_util_datastore.c @@ -239,7 +239,6 @@ main(int argc, char **argv) clicon_err(OE_DB, 0, "Unrecognized operation: %s", argv[1]); usage(argv0); } - _CLICON_XML_NS_STRICT = 0; if (xml_parse_string(argv[2], NULL, &xt) < 0) goto done; if (xml_rootchild(xt, 0, &xt) < 0) diff --git a/yang/clixon/Makefile.in b/yang/clixon/Makefile.in index 1c498b1a..4a21a439 100644 --- a/yang/clixon/Makefile.in +++ b/yang/clixon/Makefile.in @@ -40,7 +40,7 @@ datarootdir = @datarootdir@ CLIXON_DATADIR = @CLIXON_DATADIR@ -YANGSPECS = clixon-config@2019-02-06.yang +YANGSPECS = clixon-config@2019-03-05.yang YANGSPECS += clixon-lib@2019-01-02.yang YANGSPECS += clixon-rfc5277@2008-07-01.yang diff --git a/yang/clixon/clixon-config@2019-02-06.yang b/yang/clixon/clixon-config@2019-03-05.yang similarity index 95% rename from yang/clixon/clixon-config@2019-02-06.yang rename to yang/clixon/clixon-config@2019-03-05.yang index d5895361..85ce39d7 100644 --- a/yang/clixon/clixon-config@2019-02-06.yang +++ b/yang/clixon/clixon-config@2019-03-05.yang @@ -39,6 +39,11 @@ module clixon-config { ***** END LICENSE BLOCK *****"; + revision 2019-03-05 { + description + "Changed URN. Changed top-level symbol to clixon-config. + Released in Clixon 3.10"; + } revision 2019-02-06 { description "Released in Clixon 3.9"; @@ -121,7 +126,7 @@ module clixon-config { } } } - container config { + container clixon-config { leaf-list CLICON_FEATURE { description "Supported features as used by YANG feature/if-feature @@ -372,20 +377,6 @@ module clixon-config { info. When loaded at startup, a check is made if the system yang modules match"; } - leaf CLICON_XML_NS_STRICT { - type boolean; - default true; - description - "If not set, make non-strict laze namespace checks, by iterating - through modules to find the matching datanode - or rpc if no xmlns attribute specifies namespace. - This is lazy semantics of finding namespaces, which means you - do not need to explicitly give the namespace if the symbol exists - in some loaded module. - Example: is enough, instead of - But it is wrong, but is the way Clixon originally was written. - Strict semantics is the default."; - } leaf CLICON_USE_STARTUP_CONFIG { type int32; default 0;