* Made a separate Clixon datastore XML/JSON top-level symbol
* Replaces the hardcoded "config" keyword. * Implemented by a compile-time option called `DATASTORE_TOP_SYMBOL` option in clixon_custom.h * Tests: added endtest to all tests. Removed all premature exits if BE=0
This commit is contained in:
parent
2ab90d847b
commit
b7991d9b39
132 changed files with 939 additions and 628 deletions
|
|
@ -32,6 +32,9 @@ Expected: April
|
||||||
|
|
||||||
### Minor features
|
### Minor features
|
||||||
|
|
||||||
|
* Made a separate Clixon datastore XML/JSON top-level symbol
|
||||||
|
* Replaces the hardcoded "config" keyword.
|
||||||
|
* Implemented by a compile-time option called `DATASTORE_TOP_SYMBOL` option in clixon_custom.h
|
||||||
* Introduced a delay before making process start/stop/restart processes for race conditions when configuring eg restconf
|
* Introduced a delay before making process start/stop/restart processes for race conditions when configuring eg restconf
|
||||||
* For restconf `CLICON_BACKEND_RESTCONF_PROCESS`, restart restconf if restconf is edited.
|
* For restconf `CLICON_BACKEND_RESTCONF_PROCESS`, restart restconf if restconf is edited.
|
||||||
|
|
||||||
|
|
@ -39,7 +42,6 @@ Expected: April
|
||||||
|
|
||||||
* Reverted blocked signal behavior introduced in 5.0.
|
* Reverted blocked signal behavior introduced in 5.0.
|
||||||
|
|
||||||
|
|
||||||
## 5.0.0
|
## 5.0.0
|
||||||
27 February 2021
|
27 February 2021
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -443,7 +443,7 @@ client_get_config_only(clicon_handle h,
|
||||||
if (xret==NULL)
|
if (xret==NULL)
|
||||||
cprintf(cbret, "<data/>");
|
cprintf(cbret, "<data/>");
|
||||||
else{
|
else{
|
||||||
if (xml_name_set(xret, "data") < 0)
|
if (xml_name_set(xret, NETCONF_OUTPUT_DATA) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth) < 0)
|
if (clicon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -638,10 +638,13 @@ from_client_edit_config(clicon_handle h,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Get config element */
|
/* Get config element */
|
||||||
if ((xc = xpath_first(xn, nsc, "%s%sconfig", prefix?prefix:"", prefix?":":"")) == NULL){
|
if ((xc = xpath_first(xn, nsc, "%s%s%s",
|
||||||
|
prefix?prefix:"",
|
||||||
|
prefix?":":"",
|
||||||
|
NETCONF_INPUT_CONFIG)) == NULL){
|
||||||
cprintf(cbx, "Element not found, or mismatching prefix %s for namespace %s",
|
cprintf(cbx, "Element not found, or mismatching prefix %s for namespace %s",
|
||||||
prefix?prefix:"null", NETCONF_BASE_NAMESPACE);
|
prefix?prefix:"null", NETCONF_BASE_NAMESPACE);
|
||||||
if (netconf_missing_element(cbret, "protocol", "config", cbuf_get(cbx)) < 0)
|
if (netconf_missing_element(cbret, "protocol", NETCONF_INPUT_CONFIG, cbuf_get(cbx)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
|
|
@ -1215,7 +1218,7 @@ from_client_get(clicon_handle h,
|
||||||
if (xret==NULL)
|
if (xret==NULL)
|
||||||
cprintf(cbret, "<data/>");
|
cprintf(cbret, "<data/>");
|
||||||
else{
|
else{
|
||||||
if (xml_name_set(xret, "data") < 0)
|
if (xml_name_set(xret, NETCONF_OUTPUT_DATA) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Top level is data, so add 1 to depth if significant */
|
/* Top level is data, so add 1 to depth if significant */
|
||||||
if (clicon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth) < 0)
|
if (clicon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth) < 0)
|
||||||
|
|
|
||||||
|
|
@ -399,32 +399,37 @@ startup_commit(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
/* 8. Call plugin transaction commit callbacks */
|
/* 8. Call plugin transaction commit callbacks */
|
||||||
if (plugin_transaction_commit_all(h, td) < 0)
|
if (plugin_transaction_commit_all(h, td) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* After commit, make a post-commit call (sure that all plugins have committed) */
|
/* After commit, make a post-commit call (sure that all plugins have committed) */
|
||||||
if (plugin_transaction_commit_done_all(h, td) < 0)
|
if (plugin_transaction_commit_done_all(h, td) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Clear cached trees from default values and marking */
|
/* Clear cached trees from default values and marking */
|
||||||
if (xmldb_get0_clear(h, td->td_target) < 0)
|
if (xmldb_get0_clear(h, td->td_target) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* [Delete and] create running db */
|
/* [Delete and] create running db */
|
||||||
if (xmldb_exists(h, "running") == 1){
|
if (xmldb_exists(h, "running") == 1){
|
||||||
if (xmldb_delete(h, "running") != 0 && errno != ENOENT)
|
if (xmldb_delete(h, "running") != 0 && errno != ENOENT)
|
||||||
goto done;;
|
goto done;;
|
||||||
}
|
}
|
||||||
if (xmldb_create(h, "running") < 0)
|
if (xmldb_create(h, "running") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* 9, write (potentially modified) tree to running
|
/* 9, write (potentially modified) tree to running
|
||||||
* XXX note here startup is copied to candidate, which may confuse everything
|
* XXX note here startup is copied to candidate, which may confuse everything
|
||||||
* XXX default values are overwritten
|
* XXX default values are overwritten
|
||||||
*/
|
*/
|
||||||
if ((ret = xmldb_put(h, "running", OP_REPLACE, td->td_target,
|
if (td->td_target)
|
||||||
clicon_username_get(h), cbret)) < 0)
|
/* target is datastore, but is here transformed to mimic an incoming
|
||||||
goto done;
|
* edit-config
|
||||||
if (ret == 0)
|
*/
|
||||||
goto fail;
|
xml_name_set(td->td_target, NETCONF_INPUT_CONFIG);
|
||||||
|
if ((ret = xmldb_put(h, "running", OP_REPLACE, td->td_target,
|
||||||
|
clicon_username_get(h), cbret)) < 0)
|
||||||
|
goto done;
|
||||||
|
if (ret == 0)
|
||||||
|
goto fail;
|
||||||
/* 10. Call plugin transaction end callbacks */
|
/* 10. Call plugin transaction end callbacks */
|
||||||
plugin_transaction_end_all(h, td);
|
plugin_transaction_end_all(h, td);
|
||||||
retval = 1;
|
retval = 1;
|
||||||
|
|
@ -432,8 +437,8 @@ startup_commit(clicon_handle h,
|
||||||
if (td){
|
if (td){
|
||||||
if (retval < 1)
|
if (retval < 1)
|
||||||
plugin_transaction_abort_all(h, td);
|
plugin_transaction_abort_all(h, td);
|
||||||
xmldb_get0_free(h, &td->td_target);
|
xmldb_get0_free(h, &td->td_target);
|
||||||
transaction_free(td);
|
transaction_free(td);
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
fail: /* cbret should be set */
|
fail: /* cbret should be set */
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ clixon_plugin_statedata_one(clixon_plugin *cp,
|
||||||
cxobj *x = NULL;
|
cxobj *x = NULL;
|
||||||
|
|
||||||
if ((fn = cp->cp_api.ca_statedata) != NULL){
|
if ((fn = cp->cp_api.ca_statedata) != NULL){
|
||||||
if ((x = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
if ((x = xml_new(XML_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
if (fn(h, nsc, xpath, x) < 0){
|
if (fn(h, nsc, xpath, x) < 0){
|
||||||
if (clicon_errno < 0)
|
if (clicon_errno < 0)
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ db_merge(clicon_handle h,
|
||||||
/* Get data as xml from db1 */
|
/* Get data as xml from db1 */
|
||||||
if (xmldb_get0(h, (char*)db1, YB_MODULE, NULL, NULL, 0, &xt, NULL) < 0)
|
if (xmldb_get0(h, (char*)db1, YB_MODULE, NULL, NULL, 0, &xt, NULL) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
xml_name_set(xt, NETCONF_INPUT_CONFIG);
|
||||||
/* Merge xml into db2. Without commit */
|
/* Merge xml into db2. Without commit */
|
||||||
retval = xmldb_put(h, (char*)db2, OP_MERGE, xt, clicon_username_get(h), cbret);
|
retval = xmldb_put(h, (char*)db2, OP_MERGE, xt, clicon_username_get(h), cbret);
|
||||||
done:
|
done:
|
||||||
|
|
@ -168,8 +169,10 @@ load_extraxml(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
cxobj *xt = NULL;
|
cxobj *xt = NULL;
|
||||||
|
cxobj *xerr = NULL;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
yang_stmt *yspec = NULL;
|
yang_stmt *yspec = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -178,11 +181,25 @@ load_extraxml(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
yspec = clicon_dbspec_yang(h);
|
yspec = clicon_dbspec_yang(h);
|
||||||
if (clixon_xml_parse_file(fp, YB_MODULE, yspec, NULL, &xt, NULL) < 0)
|
/* No yang check yet because it has <config> as top symbol, do it later after that is removed */
|
||||||
|
if (clixon_xml_parse_file(fp, YB_NONE, yspec, NULL, &xt, &xerr) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Replace parent w first child */
|
/* Replace parent w first child */
|
||||||
if (xml_rootchild(xt, 0, &xt) < 0)
|
if (xml_rootchild(xt, 0, &xt) < 0)
|
||||||
|
goto done;
|
||||||
|
/* Ensure edit-config "config" statement */
|
||||||
|
if (xt)
|
||||||
|
xml_name_set(xt, NETCONF_INPUT_CONFIG);
|
||||||
|
/* Now we can yang bind */
|
||||||
|
if ((ret = xml_bind_yang(xt, YB_MODULE, yspec, &xerr)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
if (ret == 0){
|
||||||
|
if (netconf_err2cb(xerr, cbret) < 0)
|
||||||
|
goto done;
|
||||||
|
retval = 0;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
/* Merge user reset state */
|
/* Merge user reset state */
|
||||||
retval = xmldb_put(h, (char*)db, OP_MERGE, xt, clicon_username_get(h), cbret);
|
retval = xmldb_put(h, (char*)db, OP_MERGE, xt, clicon_username_get(h), cbret);
|
||||||
done:
|
done:
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ cli_dbxml(clicon_handle h,
|
||||||
if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path, &cvv_i) < 0)
|
if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path, &cvv_i) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
/* Create config top-of-tree */
|
/* Create config top-of-tree */
|
||||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
xbot = xtop;
|
xbot = xtop;
|
||||||
if (api_path){
|
if (api_path){
|
||||||
|
|
@ -834,8 +834,8 @@ load_config_file(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
x = NULL;
|
x = NULL;
|
||||||
while ((x = xml_child_each(xt, x, -1)) != NULL) {
|
while ((x = xml_child_each(xt, x, -1)) != NULL) {
|
||||||
/* Ensure top-level is "config", maybe this is too rough? */
|
/* Read as datastore-top but transformed into an edit-config "config" */
|
||||||
xml_name_set(x, "config");
|
xml_name_set(x, NETCONF_INPUT_CONFIG);
|
||||||
if (clicon_xml2cbuf(cbxml, x, 0, 0, -1) < 0)
|
if (clicon_xml2cbuf(cbxml, x, 0, 0, -1) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -919,7 +919,7 @@ save_config_file(clicon_handle h,
|
||||||
/* get-config returns a <data> tree. Save as <config> tree so it can be used
|
/* get-config returns a <data> tree. Save as <config> tree so it can be used
|
||||||
* as data-store.
|
* as data-store.
|
||||||
*/
|
*/
|
||||||
if (xml_name_set(xt, "config") < 0)
|
if (xml_name_set(xt, DATASTORE_TOP_SYMBOL) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if ((f = fopen(filename, "w")) == NULL){
|
if ((f = fopen(filename, "w")) == NULL){
|
||||||
clicon_err(OE_CFG, errno, "Creating file %s", filename);
|
clicon_err(OE_CFG, errno, "Creating file %s", filename);
|
||||||
|
|
@ -1166,7 +1166,7 @@ cli_unlock(clicon_handle h,
|
||||||
|
|
||||||
/*! Copy one configuration object to antother
|
/*! Copy one configuration object to antother
|
||||||
*
|
*
|
||||||
* Works for objects that are items ina yang list with a keyname, eg as:
|
* Works for objects that are items in a yang list with a keyname, eg as:
|
||||||
* list sender{
|
* list sender{
|
||||||
* key name;
|
* key name;
|
||||||
* leaf name{...
|
* leaf name{...
|
||||||
|
|
@ -1270,11 +1270,11 @@ cli_copy_config(clicon_handle h,
|
||||||
}
|
}
|
||||||
toname = cv_string_get(tocv);
|
toname = cv_string_get(tocv);
|
||||||
/* Create copy xml tree x2 */
|
/* Create copy xml tree x2 */
|
||||||
if ((x2 = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
if ((x2 = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
if (xml_copy(x1, x2) < 0)
|
if (xml_copy(x1, x2) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
xml_name_set(x2, "config");
|
xml_name_set(x2, NETCONF_INPUT_CONFIG);
|
||||||
cprintf(cb, "/%s", keyname);
|
cprintf(cb, "/%s", keyname);
|
||||||
|
|
||||||
if ((x = xpath_first(x2, nsc, "%s", cbuf_get(cb))) == NULL){
|
if ((x = xpath_first(x2, nsc, "%s", cbuf_get(cb))) == NULL){
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ expand_dbvar(void *h,
|
||||||
xcur = xt; /* default top-of-tree */
|
xcur = xt; /* default top-of-tree */
|
||||||
xpathcur = xpath;
|
xpathcur = xpath;
|
||||||
/* Create config top-of-tree */
|
/* Create config top-of-tree */
|
||||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
if ((xtop = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
xbot = xtop;
|
xbot = xtop;
|
||||||
/* This is primarily to get "y",
|
/* This is primarily to get "y",
|
||||||
|
|
|
||||||
|
|
@ -716,7 +716,7 @@ usage(clicon_handle h,
|
||||||
fprintf(stderr, "usage:%s [options]\n"
|
fprintf(stderr, "usage:%s [options]\n"
|
||||||
"where options are\n"
|
"where options are\n"
|
||||||
"\t-h \t\t Help\n"
|
"\t-h \t\t Help\n"
|
||||||
"\t-D <level>\t Debug level _ overrides any config debug setting\n"
|
"\t-D <level>\t Debug level, overrides any config debug setting\n"
|
||||||
"\t-f <file>\t Configuration file (mandatory)\n"
|
"\t-f <file>\t Configuration file (mandatory)\n"
|
||||||
"\t-E <dir> \t Extra configuration file directory\n"
|
"\t-E <dir> \t Extra configuration file directory\n"
|
||||||
"\t-l <s|f<file>> \t Log on (s)yslog, (f)ile (syslog is default)\n"
|
"\t-l <s|f<file>> \t Log on (s)yslog, (f)ile (syslog is default)\n"
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,7 @@ api_data_write(clicon_handle h,
|
||||||
else
|
else
|
||||||
op = OP_REPLACE; /* OP_CREATE if it does not exist */
|
op = OP_REPLACE; /* OP_CREATE if it does not exist */
|
||||||
/* Create config top-of-tree */
|
/* Create config top-of-tree */
|
||||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
/* Translate api_path to xml in the form of xtop/xbot */
|
/* Translate api_path to xml in the form of xtop/xbot */
|
||||||
xbot = xtop;
|
xbot = xtop;
|
||||||
|
|
@ -480,7 +480,7 @@ api_data_write(clicon_handle h,
|
||||||
*/
|
*/
|
||||||
dname = xml_name(xdata);
|
dname = xml_name(xdata);
|
||||||
if (api_path==NULL) {
|
if (api_path==NULL) {
|
||||||
if (strcmp(dname, "data")!=0){
|
if (strcmp(dname, NETCONF_OUTPUT_DATA)!=0){
|
||||||
if (netconf_bad_element_xml(&xerr, "application", dname,
|
if (netconf_bad_element_xml(&xerr, "application", dname,
|
||||||
"Data element does not match top-level data") < 0)
|
"Data element does not match top-level data") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -497,7 +497,7 @@ api_data_write(clicon_handle h,
|
||||||
if (xtop) /* also xbot */
|
if (xtop) /* also xbot */
|
||||||
xml_free(xtop);
|
xml_free(xtop);
|
||||||
xtop = xdata;
|
xtop = xdata;
|
||||||
xml_name_set(xtop, "config");
|
xml_name_set(xtop, NETCONF_INPUT_CONFIG);
|
||||||
/* remove default namespace */
|
/* remove default namespace */
|
||||||
if ((xa = xml_find_type(xtop, NULL, "xmlns", CX_ATTR)) != NULL){
|
if ((xa = xml_find_type(xtop, NULL, "xmlns", CX_ATTR)) != NULL){
|
||||||
if (xml_rm(xa) < 0)
|
if (xml_rm(xa) < 0)
|
||||||
|
|
@ -818,7 +818,7 @@ api_data_delete(clicon_handle h,
|
||||||
for (i=0; i<pi; i++)
|
for (i=0; i<pi; i++)
|
||||||
api_path = index(api_path+1, '/');
|
api_path = index(api_path+1, '/');
|
||||||
/* Create config top-of-tree */
|
/* Create config top-of-tree */
|
||||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
xbot = xtop;
|
xbot = xtop;
|
||||||
if (api_path){
|
if (api_path){
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ api_data_post(clicon_handle h,
|
||||||
for (i=0; i<pi; i++)
|
for (i=0; i<pi; i++)
|
||||||
api_path = index(api_path+1, '/');
|
api_path = index(api_path+1, '/');
|
||||||
/* Create config top-of-tree */
|
/* Create config top-of-tree */
|
||||||
if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
/* Translate api_path to xtop/xbot */
|
/* Translate api_path to xtop/xbot */
|
||||||
xbot = xtop;
|
xbot = xtop;
|
||||||
|
|
@ -524,7 +524,7 @@ api_operations_post_input(clicon_handle h,
|
||||||
goto fail;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
} /* switch media_in */
|
} /* switch media_in */
|
||||||
xml_name_set(xdata, "data");
|
xml_name_set(xdata, NETCONF_OUTPUT_DATA);
|
||||||
/* Here xdata is:
|
/* Here xdata is:
|
||||||
* <data><input xmlns="urn:example:clixon">...</input></data>
|
* <data><input xmlns="urn:example:clixon">...</input></data>
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -471,7 +471,7 @@ api_root_restconf(clicon_handle h,
|
||||||
if (api_yang_library_version(h, req, pretty, media_out) < 0)
|
if (api_yang_library_version(h, req, pretty, media_out) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else if (strcmp(api_resource, "data") == 0){ /* restconf, skip /api/data */
|
else if (strcmp(api_resource, NETCONF_OUTPUT_DATA) == 0){ /* restconf, skip /api/data */
|
||||||
if (api_data(h, req, path, pcvec, 2, qvec, indata,
|
if (api_data(h, req, path, pcvec, 2, qvec, indata,
|
||||||
pretty, media_out, IETF_DS_NONE) < 0)
|
pretty, media_out, IETF_DS_NONE) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
||||||
|
|
@ -92,3 +92,11 @@
|
||||||
* clixon-4.4
|
* clixon-4.4
|
||||||
*/
|
*/
|
||||||
#define STATE_ORDERED_BY_SYSTEM
|
#define STATE_ORDERED_BY_SYSTEM
|
||||||
|
|
||||||
|
/* Top-symbol in clixon datastores
|
||||||
|
* This is traditionally same as NETCONF_INPUT_CONFIG ("config") but can be different
|
||||||
|
* If you change this, you need to change test shell variable in lib.sh: DATASTORE_TOP
|
||||||
|
* Consider making this an option or configure option
|
||||||
|
* see XMLDB_CONFIG_HACK
|
||||||
|
*/
|
||||||
|
#define DATASTORE_TOP_SYMBOL "config"
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,7 @@ int upgrade_callback_reg_fn(clicon_handle h, clicon_upgrade_cb cb, const char *s
|
||||||
int upgrade_callback_delete_all(clicon_handle h);
|
int upgrade_callback_delete_all(clicon_handle h);
|
||||||
int upgrade_callback_call(clicon_handle h, cxobj *xt, char *ns, uint16_t op, uint32_t from, uint32_t to, cbuf *cbret);
|
int upgrade_callback_call(clicon_handle h, cxobj *xt, char *ns, uint16_t op, uint32_t from, uint32_t to, cbuf *cbret);
|
||||||
|
|
||||||
const clixon_auth_type_t clixon_auth_type_str2int(char *auth_type);
|
const int clixon_auth_type_str2int(char *auth_type);
|
||||||
const char *clixon_auth_type_int2str(clixon_auth_type_t auth_type);
|
const char *clixon_auth_type_int2str(clixon_auth_type_t auth_type);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,26 @@
|
||||||
* operations, <error-info> content, and the <action> element.
|
* operations, <error-info> content, and the <action> element.
|
||||||
*/
|
*/
|
||||||
#define YANG_XML_NAMESPACE "urn:ietf:params:xml:ns:yang:1"
|
#define YANG_XML_NAMESPACE "urn:ietf:params:xml:ns:yang:1"
|
||||||
|
|
||||||
|
/* Input symbol for netconf edit-config (+validate)
|
||||||
|
* ietf-netconf.yang defines is as input:
|
||||||
|
* choice edit-content {
|
||||||
|
* anyxml config;
|
||||||
|
* See also DATASTORE_TOP_SYMBOL which is the clixon datastore top symbol. By default also config
|
||||||
|
*/
|
||||||
|
#define NETCONF_INPUT_CONFIG "config"
|
||||||
|
|
||||||
|
/* Output symbol for netconf get/get-config
|
||||||
|
* ietf-netconf.yang defines it as output:
|
||||||
|
* output { anyxml data;
|
||||||
|
*/
|
||||||
|
#define NETCONF_OUTPUT_DATA "data"
|
||||||
|
|
||||||
|
/* Name of xml top object created by xml parse functions
|
||||||
|
* This is a "neutral" symbol without any meaning as opposed to the previous symbols ^
|
||||||
|
*/
|
||||||
|
#define XML_TOP_SYMBOL "top"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Types
|
* Types
|
||||||
*/
|
*/
|
||||||
|
|
@ -147,6 +167,7 @@ typedef struct clixon_xml_vec clixon_xvec; /* struct defined in clicon_xml_vec.c
|
||||||
#define XML_FLAG_CHANGE 0x08 /* Node is changed (commits) or child changed rec */
|
#define XML_FLAG_CHANGE 0x08 /* Node is changed (commits) or child changed rec */
|
||||||
#define XML_FLAG_NONE 0x10 /* Node is added as NONE */
|
#define XML_FLAG_NONE 0x10 /* Node is added as NONE */
|
||||||
#define XML_FLAG_DEFAULT 0x20 /* Added when a value is set as default @see xml_default */
|
#define XML_FLAG_DEFAULT 0x20 /* Added when a value is set as default @see xml_default */
|
||||||
|
#define XML_FLAG_TOP 0x40 /* Top datastore symbol */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
|
|
|
||||||
|
|
@ -407,7 +407,7 @@ clixon_client_get_xdata(int sock,
|
||||||
goto done; /* Not fatal */
|
goto done; /* Not fatal */
|
||||||
}
|
}
|
||||||
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
|
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
|
||||||
if ((xd = xml_new("data", NULL, CX_ELMNT)) == NULL)
|
if ((xd = xml_new(NETCONF_OUTPUT_DATA, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,7 @@ xmldb_copy(clicon_handle h,
|
||||||
else if (x2 == NULL){ /* create x2 and copy from x1 */
|
else if (x2 == NULL){ /* create x2 and copy from x1 */
|
||||||
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
|
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
xml_flag_set(x2, XML_FLAG_TOP);
|
||||||
if (xml_copy(x1, x2) < 0)
|
if (xml_copy(x1, x2) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -224,6 +225,7 @@ xmldb_copy(clicon_handle h,
|
||||||
xml_free(x2);
|
xml_free(x2);
|
||||||
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
|
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
xml_flag_set(x2, XML_FLAG_TOP);
|
||||||
if (xml_copy(x1, x2) < 0)
|
if (xml_copy(x1, x2) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
@ -372,7 +374,7 @@ xmldb_exists(clicon_handle h,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Clear database cache if any for mem/size optimization only
|
/*! Clear database cache if any for mem/size optimization only, not file itself
|
||||||
* @param[in] h Clicon handle
|
* @param[in] h Clicon handle
|
||||||
* @param[in] db Database
|
* @param[in] db Database
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,9 @@ singleconfigroot(cxobj *xt,
|
||||||
x = NULL;
|
x = NULL;
|
||||||
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL){
|
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL){
|
||||||
i++;
|
i++;
|
||||||
if (strcmp(xml_name(x), "config")){
|
if (strcmp(xml_name(x), DATASTORE_TOP_SYMBOL)){
|
||||||
clicon_err(OE_DB, ENOENT, "Wrong top-element %s expected config",
|
clicon_err(OE_DB, ENOENT, "Wrong top-element %s expected %s",
|
||||||
xml_name(x));
|
xml_name(x), DATASTORE_TOP_SYMBOL);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -462,7 +462,7 @@ xmldb_readfile(clicon_handle h,
|
||||||
if ((ret = clixon_json_parse_file(fp, yb, yspec, &x0, NULL)) < 0) /* XXX: ret == 0*/
|
if ((ret = clixon_json_parse_file(fp, yb, yspec, &x0, NULL)) < 0) /* XXX: ret == 0*/
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else if ((ret = clixon_xml_parse_file(fp, yb, yspec, "</config>", &x0, NULL)) < 0)
|
else if ((ret = clixon_xml_parse_file(fp, yb, yspec, NULL /* "</config>" XXX */, &x0, NULL)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef XMLDB_READFILE_FAIL /* The functions calling this function cannot handle a failed parse yet */
|
#ifdef XMLDB_READFILE_FAIL /* The functions calling this function cannot handle a failed parse yet */
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
|
@ -473,7 +473,7 @@ xmldb_readfile(clicon_handle h,
|
||||||
* 1. File is empty <top/> -> rename top-level to "config"
|
* 1. File is empty <top/> -> rename top-level to "config"
|
||||||
*/
|
*/
|
||||||
if (xml_child_nr(x0) == 0){
|
if (xml_child_nr(x0) == 0){
|
||||||
if (xml_name_set(x0, "config") < 0)
|
if (xml_name_set(x0, DATASTORE_TOP_SYMBOL) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* 2. File is not empty <top><config>...</config></top> -> replace root */
|
/* 2. File is not empty <top><config>...</config></top> -> replace root */
|
||||||
|
|
@ -482,6 +482,7 @@ xmldb_readfile(clicon_handle h,
|
||||||
if (singleconfigroot(x0, &x0) < 0)
|
if (singleconfigroot(x0, &x0) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
xml_flag_set(x0, XML_FLAG_TOP);
|
||||||
if (xml_child_nr(x0) == 0 && de)
|
if (xml_child_nr(x0) == 0 && de)
|
||||||
de->de_empty = 1;
|
de->de_empty = 1;
|
||||||
|
|
||||||
|
|
@ -695,6 +696,7 @@ xmldb_get_cache(clicon_handle h,
|
||||||
/* Make new tree by copying top-of-tree from x0t to x1t */
|
/* Make new tree by copying top-of-tree from x0t to x1t */
|
||||||
if ((x1t = xml_new(xml_name(x0t), NULL, CX_ELMNT)) == NULL)
|
if ((x1t = xml_new(xml_name(x0t), NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
|
xml_flag_set(x1t, XML_FLAG_TOP);
|
||||||
xml_spec_set(x1t, xml_spec(x0t));
|
xml_spec_set(x1t, xml_spec(x0t));
|
||||||
|
|
||||||
if (xlen < 1000){
|
if (xlen < 1000){
|
||||||
|
|
@ -996,7 +998,7 @@ xmldb_get0_clear(clicon_handle h,
|
||||||
|
|
||||||
/* clear mark and change */
|
/* clear mark and change */
|
||||||
xml_apply0(x, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
|
xml_apply0(x, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
|
||||||
(void*)(0xffff));
|
(void*)(XML_FLAG_MARK|XML_FLAG_ADD|XML_FLAG_CHANGE));
|
||||||
ok:
|
ok:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ check_body_namespace(cxobj *x0,
|
||||||
|
|
||||||
/* XXX: need to identify root better than hiereustics and strcmp,... */
|
/* XXX: need to identify root better than hiereustics and strcmp,... */
|
||||||
isroot = xml_parent(x1p)==NULL &&
|
isroot = xml_parent(x1p)==NULL &&
|
||||||
strcmp(xml_name(x1p), "config") == 0 &&
|
strcmp(xml_name(x1p), DATASTORE_TOP_SYMBOL) == 0 &&
|
||||||
xml_prefix(x1p)==NULL;
|
xml_prefix(x1p)==NULL;
|
||||||
if (nodeid_split(x1bstr, &prefix, NULL) < 0)
|
if (nodeid_split(x1bstr, &prefix, NULL) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -935,14 +935,14 @@ xmldb_put(clicon_handle h,
|
||||||
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
clicon_err(OE_YANG, ENOENT, "No yang spec");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (x1 && strcmp(xml_name(x1), "config") != 0){
|
if (x1 && strcmp(xml_name(x1), NETCONF_INPUT_CONFIG) != 0){
|
||||||
clicon_err(OE_XML, 0, "Top-level symbol of modification tree is %s, expected \"config\"",
|
clicon_err(OE_XML, 0, "Top-level symbol of modification tree is %s, expected \"%s\"",
|
||||||
xml_name(x1));
|
xml_name(x1), NETCONF_INPUT_CONFIG);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((de = clicon_db_elmnt_get(h, db)) != NULL){
|
if ((de = clicon_db_elmnt_get(h, db)) != NULL){
|
||||||
if (clicon_datastore_cache(h) != DATASTORE_NOCACHE)
|
if (clicon_datastore_cache(h) != DATASTORE_NOCACHE)
|
||||||
x0 = de->de_xml;
|
x0 = de->de_xml; /* XXX flag is not XML_FLAG_TOP */
|
||||||
}
|
}
|
||||||
/* If there is no xml x0 tree (in cache), then read it from file */
|
/* If there is no xml x0 tree (in cache), then read it from file */
|
||||||
if (x0 == NULL){
|
if (x0 == NULL){
|
||||||
|
|
@ -952,9 +952,10 @@ xmldb_put(clicon_handle h,
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (strcmp(xml_name(x0), "config")!=0){
|
if (strcmp(xml_name(x0), DATASTORE_TOP_SYMBOL) !=0 ||
|
||||||
clicon_err(OE_XML, 0, "Top-level symbol is %s, expected \"config\"",
|
xml_flag(x0, XML_FLAG_TOP) == 0){
|
||||||
xml_name(x0));
|
clicon_err(OE_XML, 0, "Top-level symbol is %s, expected \"%s\"",
|
||||||
|
xml_name(x0), DATASTORE_TOP_SYMBOL);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
/* Here x0 looks like: <config>...</config> */
|
/* Here x0 looks like: <config>...</config> */
|
||||||
|
|
|
||||||
|
|
@ -1232,7 +1232,8 @@ _json_parse(char *str,
|
||||||
*/
|
*/
|
||||||
if (yspec && xml_prefix(x) == NULL
|
if (yspec && xml_prefix(x) == NULL
|
||||||
#ifdef XMLDB_CONFIG_HACK
|
#ifdef XMLDB_CONFIG_HACK
|
||||||
&& strcmp(xml_name(x), "config") != 0
|
// && !xml_flag(x, XML_FLAG_TOP)
|
||||||
|
&& strcmp(xml_name(x), DATASTORE_TOP_SYMBOL) != 0
|
||||||
#endif
|
#endif
|
||||||
){
|
){
|
||||||
if ((cberr = cbuf_new()) == NULL){
|
if ((cberr = cbuf_new()) == NULL){
|
||||||
|
|
@ -1261,8 +1262,11 @@ _json_parse(char *str,
|
||||||
break;
|
break;
|
||||||
case YB_MODULE:
|
case YB_MODULE:
|
||||||
#ifdef XMLDB_CONFIG_HACK
|
#ifdef XMLDB_CONFIG_HACK
|
||||||
if (strcmp(xml_name(x),"config") == 0 ||
|
if (
|
||||||
strcmp(xml_name(x),"data") == 0){
|
// xml_flag(x, XML_FLAG_TOP)
|
||||||
|
strcmp(xml_name(x), DATASTORE_TOP_SYMBOL) == 0
|
||||||
|
|| strcmp(xml_name(x), NETCONF_OUTPUT_DATA) == 0
|
||||||
|
){
|
||||||
/* xt:<top> nospec
|
/* xt:<top> nospec
|
||||||
* x: <config>
|
* x: <config>
|
||||||
* <a> <-- populate from modules
|
* <a> <-- populate from modules
|
||||||
|
|
|
||||||
|
|
@ -964,7 +964,7 @@ static const map_str2int clixon_auth_type[] = {
|
||||||
|
|
||||||
/*! Translate from string to auth-type
|
/*! Translate from string to auth-type
|
||||||
*/
|
*/
|
||||||
const clixon_auth_type_t
|
const int
|
||||||
clixon_auth_type_str2int(char *auth_type)
|
clixon_auth_type_str2int(char *auth_type)
|
||||||
{
|
{
|
||||||
return clicon_str2int(clixon_auth_type, auth_type);
|
return clicon_str2int(clixon_auth_type, auth_type);
|
||||||
|
|
|
||||||
|
|
@ -469,7 +469,7 @@ clicon_rpc_get_config(clicon_handle h,
|
||||||
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL)
|
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL)
|
||||||
xd = xml_parent(xd); /* point to rpc-reply */
|
xd = xml_parent(xd); /* point to rpc-reply */
|
||||||
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
|
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
|
||||||
if ((xd = xml_new("data", NULL, CX_ELMNT)) == NULL)
|
if ((xd = xml_new(NETCONF_OUTPUT_DATA, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -831,7 +831,7 @@ clicon_rpc_get(clicon_handle h,
|
||||||
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL)
|
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL)
|
||||||
xd = xml_parent(xd); /* point to rpc-reply */
|
xd = xml_parent(xd); /* point to rpc-reply */
|
||||||
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
|
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
|
||||||
if ((xd = xml_new("data", NULL, CX_ELMNT)) == NULL)
|
if ((xd = xml_new(NETCONF_OUTPUT_DATA, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
||||||
|
|
@ -1905,7 +1905,7 @@ xml_copy_one(cxobj *x0,
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
xml_flag_set(x1, xml_flag(x0, XML_FLAG_DEFAULT)); /* Maybe more flags */
|
xml_flag_set(x1, xml_flag(x0, XML_FLAG_DEFAULT | XML_FLAG_TOP)); /* Maybe more flags */
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,6 @@
|
||||||
#define BUFLEN 1024
|
#define BUFLEN 1024
|
||||||
/* Indentation for xml pretty-print. Consider option? */
|
/* Indentation for xml pretty-print. Consider option? */
|
||||||
#define XML_INDENT 3
|
#define XML_INDENT 3
|
||||||
/* Name of xml top object created by xml parse functions */
|
|
||||||
#define XML_TOP_SYMBOL "top"
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------
|
/*------------------------------------------------------------------------
|
||||||
* XML printing functions. Output a parse tree to file, string cligen buf
|
* XML printing functions. Output a parse tree to file, string cligen buf
|
||||||
|
|
@ -516,8 +513,11 @@ _xml_parse(const char *str,
|
||||||
* x: <a> <-- populate from modules
|
* x: <a> <-- populate from modules
|
||||||
*/
|
*/
|
||||||
#ifdef XMLDB_CONFIG_HACK
|
#ifdef XMLDB_CONFIG_HACK
|
||||||
if (strcmp(xml_name(x),"config") == 0 ||
|
if (
|
||||||
strcmp(xml_name(x),"data") == 0){
|
// xml_flag(x, XML_FLAG_TOP)
|
||||||
|
strcmp(xml_name(x), DATASTORE_TOP_SYMBOL) == 0
|
||||||
|
|| strcmp(xml_name(x), NETCONF_OUTPUT_DATA) == 0
|
||||||
|
){
|
||||||
/* xt:<top> nospec
|
/* xt:<top> nospec
|
||||||
* x: <config>
|
* x: <config>
|
||||||
* <a> <-- populate from modules
|
* <a> <-- populate from modules
|
||||||
|
|
|
||||||
|
|
@ -1329,7 +1329,7 @@ xml_global_defaults(clicon_handle h,
|
||||||
/* First get or compute global xml tree cache */
|
/* First get or compute global xml tree cache */
|
||||||
if ((de = clicon_db_elmnt_get(h, key)) == NULL){
|
if ((de = clicon_db_elmnt_get(h, key)) == NULL){
|
||||||
/* Create it */
|
/* Create it */
|
||||||
if ((xcache = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
if ((xcache = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
if (xml_global_defaults_create(xcache, yspec, state) < 0)
|
if (xml_global_defaults_create(xcache, yspec, state) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -1353,7 +1353,7 @@ xml_global_defaults(clicon_handle h,
|
||||||
xml_apply_ancestor(x0, (xml_applyfn_t*)xml_flag_set, (void*)XML_FLAG_CHANGE);
|
xml_apply_ancestor(x0, (xml_applyfn_t*)xml_flag_set, (void*)XML_FLAG_CHANGE);
|
||||||
}
|
}
|
||||||
/* Create a new tree and copy over the parts from the cache that matches xpath */
|
/* Create a new tree and copy over the parts from the cache that matches xpath */
|
||||||
if ((xpart = xml_new("config", NULL, CX_ELMNT)) == NULL)
|
if ((xpart = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
if (xml_copy_marked(xcache, xpart) < 0) /* config */
|
if (xml_copy_marked(xcache, xpart) < 0) /* config */
|
||||||
goto done;
|
goto done;
|
||||||
|
|
@ -1763,11 +1763,12 @@ assign_namespace_element(cxobj *x0, /* source */
|
||||||
char *prefix0 = NULL;;
|
char *prefix0 = NULL;;
|
||||||
int isroot;
|
int isroot;
|
||||||
|
|
||||||
/* XXX: need to identify root better than hiereustics and strcmp,... */
|
/* XXX: need to identify root better than hiereustics and strcmp,...
|
||||||
|
* see XMLDB_CONFIG_HACK
|
||||||
|
*/
|
||||||
isroot = xml_parent(x1p)==NULL &&
|
isroot = xml_parent(x1p)==NULL &&
|
||||||
(strcmp(xml_name(x1p), "config") == 0 || strcmp(xml_name(x1p), "top") == 0)&&
|
xml_flag(x1p, XML_FLAG_TOP) &&
|
||||||
xml_prefix(x1p)==NULL;
|
xml_prefix(x1p)==NULL;
|
||||||
|
|
||||||
/* 1. Find N=namespace(x0) in x0 element */
|
/* 1. Find N=namespace(x0) in x0 element */
|
||||||
prefix0 = xml_prefix(x0);
|
prefix0 = xml_prefix(x0);
|
||||||
if (xml2ns(x0, prefix0, &namespace) < 0)
|
if (xml2ns(x0, prefix0, &namespace) < 0)
|
||||||
|
|
|
||||||
|
|
@ -61,3 +61,8 @@ TOP_SRCDIR=@top_srcdir@
|
||||||
|
|
||||||
# Clixon version
|
# Clixon version
|
||||||
CLIXON_VERSION=@CLIXON_VERSION@
|
CLIXON_VERSION=@CLIXON_VERSION@
|
||||||
|
|
||||||
|
# Which XML symbol to add to top datastore config level
|
||||||
|
# see also DATASTORE_TOP_SYMBOL
|
||||||
|
DATASTORE_TOP="config"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,7 @@ function wait_restconf(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# End of test, final tests before normal exit of test
|
||||||
function endtest()
|
function endtest()
|
||||||
{
|
{
|
||||||
if [ $valgrindtest -eq 1 ]; then
|
if [ $valgrindtest -eq 1 ]; then
|
||||||
|
|
@ -657,6 +658,10 @@ function expectmatch(){
|
||||||
r=$2
|
r=$2
|
||||||
expret=$3
|
expret=$3
|
||||||
expect=$4
|
expect=$4
|
||||||
|
# echo "ret:$ret"
|
||||||
|
# echo "ret:$r"
|
||||||
|
# echo "expret:$expret"
|
||||||
|
# echo "expect:$expect"
|
||||||
if [ $r != $expret ]; then
|
if [ $r != $expret ]; then
|
||||||
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
|
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
|
||||||
echo -e "\e[0m:"
|
echo -e "\e[0m:"
|
||||||
|
|
|
||||||
|
|
@ -277,3 +277,6 @@ unset format
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -260,3 +260,7 @@ unset nr
|
||||||
unset clixon_util_path
|
unset clixon_util_path
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -311,3 +311,6 @@ fi
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -246,17 +246,18 @@ testrun "$CONFIG" "$EXPSTATE"
|
||||||
|
|
||||||
#-----------------------------
|
#-----------------------------
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -135,3 +135,6 @@ fi
|
||||||
stop_backend -f $cfg
|
stop_backend -f $cfg
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -169,3 +169,5 @@ fi
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -287,20 +287,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -126,17 +126,18 @@ new "cli rpc"
|
||||||
# We dont know which message-id the cli app uses
|
# We dont know which message-id the cli app uses
|
||||||
expectpart "$($clixon_cli -1 -f $cfg -l o rpc ipv4)" 0 "<rpc-reply $DEFAULTONLY message-id=" "><x xmlns=\"urn:example:clixon\">ipv4</x><y xmlns=\"urn:example:clixon\">42</y></rpc-reply>"
|
expectpart "$($clixon_cli -1 -f $cfg -l o rpc ipv4)" 0 "<rpc-reply $DEFAULTONLY message-id=" "><x xmlns=\"urn:example:clixon\">ipv4</x><y xmlns=\"urn:example:clixon\">42</y></rpc-reply>"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -63,14 +63,14 @@ show("Show a particular state of the system"){
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<table xmlns="urn:example:clixon">
|
<table xmlns="urn:example:clixon">
|
||||||
<parameter>
|
<parameter>
|
||||||
<name>a</name>
|
<name>a</name>
|
||||||
<value>42</value>
|
<value>42</value>
|
||||||
</parameter>
|
</parameter>
|
||||||
</table>
|
</table>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Add inline state
|
# Add inline state
|
||||||
|
|
|
||||||
|
|
@ -291,3 +291,6 @@ fi
|
||||||
stop_backend -f $cfg
|
stop_backend -f $cfg
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -215,3 +215,6 @@ fi
|
||||||
stop_backend -f $cfg
|
stop_backend -f $cfg
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ show("Show a particular state of the system"){
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<table xmlns="urn:example:clixon">
|
<table xmlns="urn:example:clixon">
|
||||||
<parameter>
|
<parameter>
|
||||||
<name>p1</name>
|
<name>p1</name>
|
||||||
|
|
@ -110,7 +110,7 @@ cat <<EOF > $dir/startup_db
|
||||||
</index>
|
</index>
|
||||||
</parameter>
|
</parameter>
|
||||||
</table>
|
</table>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
new "test params: -f $cfg"
|
new "test params: -f $cfg"
|
||||||
|
|
@ -162,3 +162,6 @@ fi
|
||||||
stop_backend -f $cfg
|
stop_backend -f $cfg
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -136,3 +136,6 @@ fi
|
||||||
|
|
||||||
unset nr
|
unset nr
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -125,17 +125,18 @@ expectpart "$($clixon_cli -1 -f $cfg set ex y a 2 b v2)" 0 ""
|
||||||
new "show conf"
|
new "show conf"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><ex xmlns=\"urn:example:clixon\"><x><a>1</a><b>v1</b></x><x><a>1</a><b>v2</b></x><x><a>1</a><b>v3</b></x><x><a>2</a><b>v1</b></x><x><a>2</a><b>v2</b></x><x><a>2</a><b>v3</b></x><y><a>1</a><b>v1</b></y><y><a>2</a><b>v1</b></y><y><a>1</a><b>v2</b></y><y><a>1</a><b>v3</b></y><y><a>2</a><b>v2</b></y></ex></data></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><ex xmlns=\"urn:example:clixon\"><x><a>1</a><b>v1</b></x><x><a>1</a><b>v2</b></x><x><a>1</a><b>v3</b></x><x><a>2</a><b>v1</b></x><x><a>2</a><b>v2</b></x><x><a>2</a><b>v3</b></x><y><a>1</a><b>v1</b></y><y><a>2</a><b>v1</b></y><y><a>1</a><b>v2</b></y><y><a>1</a><b>v3</b></y><y><a>2</a><b>v2</b></y></ex></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -109,17 +109,18 @@ for c in 2 4; do
|
||||||
expectpart "$($clixon_cli -1 -m $m -f $cfg cmd$c)" 255 "^$"
|
expectpart "$($clixon_cli -1 -m $m -f $cfg cmd$c)" 255 "^$"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -79,3 +79,6 @@ if [ $BE -ne 0 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -157,19 +157,17 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=`pgrep -u root -f clixon_backend`
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset format
|
unset format
|
||||||
|
|
||||||
|
|
@ -177,3 +175,6 @@ unset format
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -126,3 +126,6 @@ new "Start with 2 extra configfiles + command-line"
|
||||||
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_MODULE_SET_ID=4 -o CLICON_FEATURE=test4 -l o show options)" 0 'CLICON_MODULE_SET_ID: "4"' 'CLICON_FEATURE: "test1"' 'CLICON_FEATURE: "test2"' 'CLICON_FEATURE: "test3"' 'CLICON_FEATURE: "test4"'
|
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_MODULE_SET_ID=4 -o CLICON_FEATURE=test4 -l o show options)" 0 'CLICON_MODULE_SET_ID: "4"' 'CLICON_FEATURE: "test1"' 'CLICON_FEATURE: "test2"' 'CLICON_FEATURE: "test3"' 'CLICON_FEATURE: "test4"'
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ EOF
|
||||||
|
|
||||||
# Create empty startup
|
# Create empty startup
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config/>
|
<${DATASTORE_TOP}/>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# rm candidate and running
|
# rm candidate and running
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,9 @@ module ietf-ip{
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
xml='<config><x xmlns="urn:example:clixon"><y><a>1</a><b>2</b><c>first-entry</c></y><y><a>1</a><b>3</b><c>second-entry</c></y><y><a>2</a><b>3</b><c>third-entry</c></y><d/><f><e>a</e><e>b</e><e>c</e></f><g>astring</g></x></config>'
|
xml="<x xmlns=\"urn:example:clixon\"><y><a>1</a><b>2</b><c>first-entry</c></y><y><a>1</a><b>3</b><c>second-entry</c></y><y><a>2</a><b>3</b><c>third-entry</c></y><d/><f><e>a</e><e>b</e><e>c</e></f><g>astring</g></x>"
|
||||||
|
|
||||||
|
xml2="<${DATASTORE_TOP}><x xmlns=\"urn:example:clixon\"><y><a>1</a><b>2</b><c>first-entry</c></y><y><a>1</a><b>3</b><c>second-entry</c></y><y><a>2</a><b>3</b><c>third-entry</c></y><d/><f><e>a</e><e>b</e><e>c</e></f><g>astring</g></x></${DATASTORE_TOP}>"
|
||||||
|
|
||||||
name=text
|
name=text
|
||||||
|
|
||||||
|
|
@ -68,13 +70,13 @@ ret=$($clixon_util_datastore $conf put replace "$xml")
|
||||||
expectmatch "$ret" $? "0" ""
|
expectmatch "$ret" $? "0" ""
|
||||||
|
|
||||||
new "datastore get"
|
new "datastore get"
|
||||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$"
|
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml2$"
|
||||||
|
|
||||||
new "datastore put all remove"
|
new "datastore put all remove"
|
||||||
expectpart "$($clixon_util_datastore $conf put remove "<config/>")" 0 ""
|
expectpart "$($clixon_util_datastore $conf put remove "")" 0 ""
|
||||||
|
|
||||||
new "datastore get"
|
new "datastore get"
|
||||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^<config/>$"
|
expectpart "$($clixon_util_datastore $conf get /)" 0 "^<${DATASTORE_TOP}/>$"
|
||||||
|
|
||||||
new "datastore put all merge"
|
new "datastore put all merge"
|
||||||
ret=$($clixon_util_datastore $conf put merge "$xml")
|
ret=$($clixon_util_datastore $conf put merge "$xml")
|
||||||
|
|
@ -83,23 +85,23 @@ expectmatch "$ret" $? "0" ""
|
||||||
# expectpart "$($clixon_util_datastore $conf put merge $xml)" 0 ""
|
# expectpart "$($clixon_util_datastore $conf put merge $xml)" 0 ""
|
||||||
|
|
||||||
new "datastore get"
|
new "datastore get"
|
||||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$"
|
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml2$"
|
||||||
|
|
||||||
new "datastore put all delete"
|
new "datastore put all delete"
|
||||||
expectpart "$($clixon_util_datastore $conf put remove "<config/>")" 0 ""
|
expectpart "$($clixon_util_datastore $conf put remove "")" 0 ""
|
||||||
|
|
||||||
new "datastore get"
|
new "datastore get"
|
||||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^<config/>$"
|
expectpart "$($clixon_util_datastore $conf get /)" 0 "^<${DATASTORE_TOP}/>$"
|
||||||
|
|
||||||
new "datastore put all create"
|
new "datastore put all create"
|
||||||
ret=$($clixon_util_datastore $conf put create "$xml")
|
ret=$($clixon_util_datastore $conf put create "$xml")
|
||||||
expectmatch "$ret" $? "0" ""
|
expectmatch "$ret" $? "0" ""
|
||||||
|
|
||||||
new "datastore get"
|
new "datastore get"
|
||||||
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$"
|
expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml2$"
|
||||||
|
|
||||||
new "datastore put top create"
|
new "datastore put top create"
|
||||||
expectpart "$($clixon_util_datastore $conf put create "<config><x/></config>")" 0 "" # error
|
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"/>')" 0 "" # error
|
||||||
|
|
||||||
# Single key operations
|
# Single key operations
|
||||||
# leaf
|
# leaf
|
||||||
|
|
@ -110,43 +112,43 @@ new "datastore init"
|
||||||
expectpart "$($clixon_util_datastore $conf init)" 0 ""
|
expectpart "$($clixon_util_datastore $conf init)" 0 ""
|
||||||
|
|
||||||
new "datastore create leaf"
|
new "datastore create leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put create "<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>")" 0 ""
|
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore create leaf"
|
new "datastore create leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put create '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore delete leaf"
|
new "datastore delete leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put delete '<config><x><y><a>1</a><b>3</b></y></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put delete '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b></y></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore replace leaf"
|
new "datastore replace leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put create '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore remove leaf"
|
new "datastore remove leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put remove '<config><x><g/></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put remove '<x xmlns="urn:example:clixon"><g/></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore remove leaf"
|
new "datastore remove leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put remove '<config><x><y><a>1</a><b>3</b><c/></y></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put remove '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c/></y></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore delete leaf"
|
new "datastore delete leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put delete '<config><x><g/></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put delete '<x xmlns="urn:example:clixon"><g/></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore merge leaf"
|
new "datastore merge leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put merge '<config><x><g>nalle</g></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put merge '<x xmlns="urn:example:clixon"><g>nalle</g></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore replace leaf"
|
new "datastore replace leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put replace '<config><x><g>nalle</g></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put replace '<x xmlns="urn:example:clixon"><g>nalle</g></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore merge leaf"
|
new "datastore merge leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put merge '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put merge '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore replace leaf"
|
new "datastore replace leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put replace '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put replace '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore create leaf"
|
new "datastore create leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put create '<config><x><h><j>aaa</j></h></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><h><j>aaa</j></h></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore create leaf"
|
new "datastore create leaf"
|
||||||
expectpart "$($clixon_util_datastore $conf put create '<config><x><y><a>1</a><b>3</b><c>newentry</c></y></x></config>')" 0 ""
|
expectpart "$($clixon_util_datastore $conf put create '<x xmlns="urn:example:clixon"><y><a>1</a><b>3</b><c>newentry</c></y></x>')" 0 ""
|
||||||
|
|
||||||
new "datastore other db init"
|
new "datastore other db init"
|
||||||
expectpart "$($clixon_util_datastore -d kalle -b $mydir -y $dir/ietf-ip.yang init)" 0 ""
|
expectpart "$($clixon_util_datastore -d kalle -b $mydir -y $dir/ietf-ip.yang init)" 0 ""
|
||||||
|
|
@ -166,3 +168,6 @@ rm -rf $mydir
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
function testrun(){
|
function testrun(){
|
||||||
new "test params: -f $cfg -- -U"
|
new "test params: -f $cfg -- -U" # -U : upgrade
|
||||||
# Bring your own backend
|
# Bring your own backend
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
# kill old backend (if any)
|
# kill old backend (if any)
|
||||||
|
|
@ -116,7 +116,7 @@ function testrun(){
|
||||||
# Create startup db of "old" db with incorrect augment namespace tagging
|
# Create startup db of "old" db with incorrect augment namespace tagging
|
||||||
# without modstate
|
# without modstate
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<x xmlns="urn:example:a">
|
<x xmlns="urn:example:a">
|
||||||
<y>
|
<y>
|
||||||
<z>
|
<z>
|
||||||
|
|
@ -126,10 +126,13 @@ cat <<EOF > $dir/startup_db
|
||||||
</x>
|
</x>
|
||||||
<remove_me xmlns="urn:example:a"><k>This node is obsolete</k></remove_me>
|
<remove_me xmlns="urn:example:a"><k>This node is obsolete</k></remove_me>
|
||||||
<remove_me xmlns="urn:example:a"><k>this too</k></remove_me>
|
<remove_me xmlns="urn:example:a"><k>this too</k></remove_me>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
new "general-purpose upgrade without modstate"
|
new "general-purpose upgrade without modstate"
|
||||||
testrun
|
testrun
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,7 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
# Check if premature kill
|
# Check if premature kill
|
||||||
pid=$(pgrep -u root -f clixon_backend)
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
|
|
||||||
|
|
@ -72,3 +72,6 @@ rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset make
|
unset make
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -328,4 +328,5 @@ rm -rf $dir
|
||||||
unset nr
|
unset nr
|
||||||
unset clixon_util_path # for other script reusing it
|
unset clixon_util_path # for other script reusing it
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -99,4 +99,5 @@ expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /ex:table/ex:parameter/ex:n
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
unset clixon_util_path # for other script reusing it
|
unset clixon_util_path # for other script reusing it
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -138,3 +138,6 @@ rm -rf $dir
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset clixon_util_json
|
unset clixon_util_json
|
||||||
unset clixon_util_xml
|
unset clixon_util_xml
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -197,3 +197,6 @@ rm -rf $dir
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset clixon_util_json
|
unset clixon_util_json
|
||||||
unset clixon_util_xml
|
unset clixon_util_xml
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -158,9 +158,9 @@ fi
|
||||||
# From startup 1, only r1, all else should be filled in
|
# From startup 1, only r1, all else should be filled in
|
||||||
SXML='<r1 xmlns="urn:example:clixon">99</r1>'
|
SXML='<r1 xmlns="urn:example:clixon">99</r1>'
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
$SXML
|
$SXML
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
XML='<r1 xmlns="urn:example:clixon">99</r1><r2 xmlns="urn:example:clixon">22</r2><np3 xmlns="urn:example:clixon"><s3>33</s3><np31><s31>31</s31></np31></np3>'
|
XML='<r1 xmlns="urn:example:clixon">99</r1><r2 xmlns="urn:example:clixon">22</r2><np3 xmlns="urn:example:clixon"><s3>33</s3><np31><s31>31</s31></np31></np3>'
|
||||||
|
|
||||||
|
|
@ -186,11 +186,11 @@ sudo chmod 666 $dir/running_db
|
||||||
new "Check running no defaults: r1 only"
|
new "Check running no defaults: r1 only"
|
||||||
# Running should have only non-defaults, ie only r1 that is set to 99
|
# Running should have only non-defaults, ie only r1 that is set to 99
|
||||||
|
|
||||||
moreret=$(diff $dir/running_db <(echo "<config>
|
moreret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>
|
||||||
$SXML
|
$SXML
|
||||||
</config>"))
|
</${DATASTORE_TOP}>"))
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err "<config>$SXML</config>" "$moreret"
|
err "<${DATASTORE_TOP}>$SXML</${DATASTORE_TOP}>" "$moreret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "Change default value r2"
|
new "Change default value r2"
|
||||||
|
|
@ -201,12 +201,12 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "
|
||||||
|
|
||||||
new "Check running no defaults: r1 and r2"
|
new "Check running no defaults: r1 and r2"
|
||||||
# Again, running should have only non-defaults, ie only r1 and r2
|
# Again, running should have only non-defaults, ie only r1 and r2
|
||||||
moreret=$(diff $dir/running_db <(echo "<config>
|
moreret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>
|
||||||
$SXML
|
$SXML
|
||||||
<r2 xmlns=\"urn:example:clixon\">88</r2>
|
<r2 xmlns=\"urn:example:clixon\">88</r2>
|
||||||
</config>"))
|
</${DATASTORE_TOP}>"))
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err "<config>$SXML<r2 xmlns=\"urn:example:clixon\">88</r2></config>" "$moreret"
|
err "<${DATASTORE_TOP}>$SXML<r2 xmlns=\"urn:example:clixon\">88</r2></${DATASTORE_TOP}>" "$moreret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
|
|
@ -218,9 +218,9 @@ fi
|
||||||
|
|
||||||
# From startup 2, only presence p4, s4/np5 should be filled in
|
# From startup 2, only presence p4, s4/np5 should be filled in
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<p4 xmlns="urn:example:clixon"></p4>
|
<p4 xmlns="urn:example:clixon"></p4>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
XML='<r1 xmlns="urn:example:clixon">11</r1><r2 xmlns="urn:example:clixon">22</r2><np3 xmlns="urn:example:clixon"><s3>33</s3><np31><s31>31</s31></np31></np3><p4 xmlns="urn:example:clixon"><s4>44</s4><np45><s5>45</s5></np45></p4>'
|
XML='<r1 xmlns="urn:example:clixon">11</r1><r2 xmlns="urn:example:clixon">22</r2><np3 xmlns="urn:example:clixon"><s3>33</s3><np31><s31>31</s31></np31></np3><p4 xmlns="urn:example:clixon"><s4>44</s4><np45><s5>45</s5></np45></p4>'
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
|
|
@ -248,9 +248,9 @@ fi
|
||||||
|
|
||||||
# Only single x list element
|
# Only single x list element
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<xs-config xmlns="urn:example:clixon"><x><name>a</name></x></xs-config>
|
<xs-config xmlns="urn:example:clixon"><x><name>a</name></x></xs-config>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
XML='<r1 xmlns="urn:example:clixon">11</r1><r2 xmlns="urn:example:clixon">22</r2><np3 xmlns="urn:example:clixon"><s3>33</s3><np31><s31>31</s31></np31></np3>'
|
XML='<r1 xmlns="urn:example:clixon">11</r1><r2 xmlns="urn:example:clixon">22</r2><np3 xmlns="urn:example:clixon"><s3>33</s3><np31><s31>31</s31></np31></np3>'
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
|
|
@ -277,3 +277,6 @@ if [ -z "$pid" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -187,17 +187,18 @@ expectpart "$($clixon_cli -1f $cfg -l o set sender a)" 0 "^$"
|
||||||
new "cli sender template"
|
new "cli sender template"
|
||||||
expectpart "$($clixon_cli -1f $cfg -l o set sender b template a)" 0 "^$"
|
expectpart "$($clixon_cli -1f $cfg -l o set sender b template a)" 0 "^$"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -264,17 +264,19 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><validate><source><candi
|
||||||
new "netconf discard-changes"
|
new "netconf discard-changes"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><discard-changes/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><discard-changes/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
|
||||||
fi
|
|
||||||
|
|
||||||
new "Kill backend"
|
new "Kill backend"
|
||||||
# Check if premature kill
|
# Check if premature kill
|
||||||
pid=$(pgrep -u root -f clixon_backend)
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
if [ -z "$pid" ]; then
|
if [ -z "$pid" ]; then
|
||||||
err "backend already dead"
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
# kill backend
|
|
||||||
stop_backend -f $cfg
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -175,17 +175,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get content=\"nonconfig
|
||||||
new "netconf get / config-only ok"
|
new "netconf get / config-only ok"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get content=\"config\"><filter type=\"xpath\" select=\"/\"/></get></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><sender-config xmlns=\"urn:example:example\"><name>y</name></sender-config></data></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get content=\"config\"><filter type=\"xpath\" select=\"/\"/></get></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><sender-config xmlns=\"urn:example:example\"><name>y</name></sender-config></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -245,17 +245,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS $DEFAULTNS><edit-config>
|
||||||
new "minmax: validate should fail empty list"
|
new "minmax: validate should fail empty list"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>operation-failed</error-tag><error-app-tag>too-few-elements</error-app-tag><error-severity>error</error-severity><error-path>/c/a1</error-path></rpc-error></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>protocol</error-type><error-tag>operation-failed</error-tag><error-app-tag>too-few-elements</error-app-tag><error-severity>error</error-severity><error-path>/c/a1</error-path></rpc-error></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -191,20 +191,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -231,3 +231,6 @@ rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset clixon_util_socket
|
unset clixon_util_socket
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -321,20 +321,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ EOF
|
||||||
|
|
||||||
# Set initial NACM rules in startup enabling admin and a single param config
|
# Set initial NACM rules in startup enabling admin and a single param config
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<table xmlns="urn:example:nacm">
|
<table xmlns="urn:example:nacm">
|
||||||
<parameters>
|
<parameters>
|
||||||
<parameter>
|
<parameter>
|
||||||
|
|
@ -86,7 +86,7 @@ cat <<EOF > $dir/startup_db
|
||||||
$NGROUPS
|
$NGROUPS
|
||||||
$NADMIN
|
$NADMIN
|
||||||
</nacm>
|
</nacm>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
new "test params: -f $cfg"
|
new "test params: -f $cfg"
|
||||||
|
|
@ -171,3 +171,6 @@ fi
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -303,3 +303,6 @@ fi
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -301,3 +301,6 @@ fi
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ EOF
|
||||||
|
|
||||||
# Use startup or set values with POST (below)
|
# Use startup or set values with POST (below)
|
||||||
if [ $db = startup ]; then
|
if [ $db = startup ]; then
|
||||||
sudo echo "<config>$NACM$XML</config>" > $dir/startup_db
|
sudo echo "<${DATASTORE_TOP}>$NACM$XML</${DATASTORE_TOP}>" > $dir/startup_db
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then # Bring your own backend
|
if [ $BE -ne 0 ]; then # Bring your own backend
|
||||||
|
|
|
||||||
|
|
@ -216,20 +216,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -259,20 +259,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -261,20 +261,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -227,20 +227,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -304,17 +304,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><client-rpc xmlns=\"urn:
|
||||||
new "netconf extra leaf in leaf should fail"
|
new "netconf extra leaf in leaf should fail"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"><interface><name>e0<name>e1</name></name></interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>name</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces</error-message></rpc-error></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"><interface><name>e0<name>e1</name></name></interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>unknown-element</error-tag><error-info><bad-element>name</bad-element></error-info><error-severity>error</error-severity><error-message>Failed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces</error-message></rpc-error></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -80,17 +80,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get><filter type='xpath
|
||||||
new "get xpath one"
|
new "get xpath one"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get><filter type='xpath' select=\"/fi:x/fi:y[fi:a='1']\" xmlns:fi='urn:example:filter' /></get></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:filter\"><y><a>1</a><b>1</b></y></x></data></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get><filter type='xpath' select=\"/fi:x/fi:y[fi:a='1']\" xmlns:fi='urn:example:filter' /></get></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:filter\"><y><a>1</a><b>1</b></y></x></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -149,3 +149,5 @@ fi
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,9 @@ EOF
|
||||||
|
|
||||||
new "test params: -f $cfg -s startup"
|
new "test params: -f $cfg -s startup"
|
||||||
|
|
||||||
echo '<config><ex:x xmlns:ex="urn:example:whitespace">
|
# Keep the following as is (whitespace)
|
||||||
<ex:y> <ex:a>foo</ex:a>\n <ex:b> </ex:b></ex:y> </ex:x></config></edit-config></rpc>]]>]]>$start</config>' > $dir/startup_db
|
echo "<${DATASTORE_TOP}><ex:x xmlns:ex=\"urn:example:whitespace\">
|
||||||
|
<ex:y> <ex:a>foo</ex:a>\n <ex:b> </ex:b></ex:y> </ex:x></${DATASTORE_TOP}>" > $dir/startup_db
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
|
|
@ -137,17 +138,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><validate><source><candi
|
||||||
new "netconf discard-changes"
|
new "netconf discard-changes"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><discard-changes/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><discard-changes/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -161,3 +161,5 @@ fi
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ EOF
|
||||||
rm -f $dbdir/candidate_db
|
rm -f $dbdir/candidate_db
|
||||||
# alt
|
# alt
|
||||||
cat <<EOF > $dbdir/running_db
|
cat <<EOF > $dbdir/running_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<y0 xmlns="urn:example:order">d</y0>
|
<y0 xmlns="urn:example:order">d</y0>
|
||||||
<y1 xmlns="urn:example:order">d</y1>
|
<y1 xmlns="urn:example:order">d</y1>
|
||||||
<y2 xmlns="urn:example:order"><k>d</k><a>bar</a></y2>
|
<y2 xmlns="urn:example:order"><k>d</k><a>bar</a></y2>
|
||||||
|
|
@ -148,7 +148,7 @@ cat <<EOF > $dbdir/running_db
|
||||||
<y3 xmlns="urn:example:order"><k>c</k><a>bar</a></y3>
|
<y3 xmlns="urn:example:order"><k>c</k><a>bar</a></y3>
|
||||||
<y2 xmlns="urn:example:order"><k>b</k><a>bar</a></y2>
|
<y2 xmlns="urn:example:order"><k>b</k><a>bar</a></y2>
|
||||||
<y3 xmlns="urn:example:order"><k>b</k><a>bar</a></y3>
|
<y3 xmlns="urn:example:order"><k>b</k><a>bar</a></y3>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
new "test params: -s running -f $cfg -- -s"
|
new "test params: -s running -f $cfg -- -s"
|
||||||
|
|
@ -391,20 +391,21 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><ca
|
||||||
new "check ordered-by-user: e,a,71,b,42,c,d"
|
new "check ordered-by-user: e,a,71,b,42,c,d"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><y2 xmlns=\"urn:example:order\"><k>e</k><a>bar</a></y2><y2 xmlns=\"urn:example:order\"><k>a</k><a>foo</a></y2><y2 xmlns=\"urn:example:order\"><k>71</k><a>fie</a></y2><y2 xmlns=\"urn:example:order\"><k>b</k><a>bar</a></y2><y2 xmlns=\"urn:example:order\"><k>42</k><a>fum</a></y2><y2 xmlns=\"urn:example:order\"><k>c</k><a>foo</a></y2><y2 xmlns=\"urn:example:order\"><k>d</k><a>fie</a></y2></data></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><y2 xmlns=\"urn:example:order\"><k>e</k><a>bar</a></y2><y2 xmlns=\"urn:example:order\"><k>a</k><a>foo</a></y2><y2 xmlns=\"urn:example:order\"><k>71</k><a>fie</a></y2><y2 xmlns=\"urn:example:order\"><k>b</k><a>bar</a></y2><y2 xmlns=\"urn:example:order\"><k>42</k><a>fum</a></y2><y2 xmlns=\"urn:example:order\"><k>c</k><a>foo</a></y2><y2 xmlns=\"urn:example:order\"><k>d</k><a>fie</a></y2></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset format
|
unset format
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -824,3 +824,6 @@ rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset regex
|
unset regex
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -149,22 +149,23 @@ expecteof "time -p $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<r
|
||||||
|
|
||||||
# XXX No leafref cli tests
|
# XXX No leafref cli tests
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset format
|
unset format
|
||||||
unset perfnr
|
unset perfnr
|
||||||
unset perfreq
|
unset perfreq
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -70,11 +70,11 @@ function testrun(){
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "generate config with $nr list entries"
|
new "generate config with $nr list entries"
|
||||||
echo -n "<config><x xmlns=\"urn:example:clixon\">" > $dir/startup_db
|
echo -n "<${DATASTORE_TOP}><x xmlns=\"urn:example:clixon\">" > $dir/startup_db
|
||||||
for (( i=0; i<$nr; i++ )); do
|
for (( i=0; i<$nr; i++ )); do
|
||||||
echo -n "<y><a>$i</a><b>$i</b></y>" >> $dir/startup_db
|
echo -n "<y><a>$i</a><b>$i</b></y>" >> $dir/startup_db
|
||||||
done
|
done
|
||||||
echo "</x></config>" >> $dir/startup_db
|
echo "</x></${DATASTORE_TOP}>" >> $dir/startup_db
|
||||||
|
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
sudo clixon_backend -zf $cfg
|
sudo clixon_backend -zf $cfg
|
||||||
|
|
@ -173,5 +173,7 @@ b:
|
||||||
childvec: 8
|
childvec: 8
|
||||||
(ns-cache: 115) # only in startup?
|
(ns-cache: 115) # only in startup?
|
||||||
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -191,22 +191,23 @@ expecteof "time -p $clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]
|
||||||
new "netconf get large leaf-list config"
|
new "netconf get large leaf-list config"
|
||||||
expecteof "time -p $clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:clixon\"><c>0</c><c>1</c>" 2>&1 | awk '/real/ {print $2}'
|
expecteof "time -p $clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:clixon\"><c>0</c><c>1</c>" 2>&1 | awk '/real/ {print $2}'
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset format
|
unset format
|
||||||
unset perfnr
|
unset perfnr
|
||||||
unset perfreq
|
unset perfreq
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -197,19 +197,17 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
|
|
@ -219,3 +217,6 @@ unset RESTCONFIG
|
||||||
unset format
|
unset format
|
||||||
unset perfnr
|
unset perfnr
|
||||||
unset perfreq
|
unset perfreq
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -163,3 +163,6 @@ rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset perfnr
|
unset perfnr
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -196,19 +196,17 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
|
|
@ -219,3 +217,5 @@ unset perfreq
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -208,5 +208,5 @@ unset format
|
||||||
unset perfnr
|
unset perfnr
|
||||||
unset perfreq
|
unset perfreq
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -30,3 +30,5 @@ rm -rf $dir
|
||||||
unset clixon_util_xml
|
unset clixon_util_xml
|
||||||
unset perfnr
|
unset perfnr
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -134,3 +134,6 @@ new "Start as non-privileged, try to drop (but fail)"
|
||||||
testrun $(whoami) $BUSER $BUSER drop_perm 1
|
testrun $(whoami) $BUSER $BUSER drop_perm 1
|
||||||
|
|
||||||
sudo rm -rf $dir
|
sudo rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -414,3 +414,6 @@ unset RESTCONFIG
|
||||||
unset RESTCONFIG1
|
unset RESTCONFIG1
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -208,20 +208,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ EOF
|
||||||
|
|
||||||
# NACM rules and top/ config
|
# NACM rules and top/ config
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
|
<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
|
||||||
<enable-nacm>true</enable-nacm>
|
<enable-nacm>true</enable-nacm>
|
||||||
<read-default>deny</read-default>
|
<read-default>deny</read-default>
|
||||||
|
|
@ -163,7 +163,7 @@ cat <<EOF > $dir/startup_db
|
||||||
<anonymous>42</anonymous>
|
<anonymous>42</anonymous>
|
||||||
<wilma>71</wilma>
|
<wilma>71</wilma>
|
||||||
</top>
|
</top>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Restconf auth test with arguments:
|
# Restconf auth test with arguments:
|
||||||
|
|
@ -316,3 +316,6 @@ unset MSGERR1
|
||||||
unset MSGERR2
|
unset MSGERR2
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -245,20 +245,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -256,20 +256,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -171,20 +171,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,9 @@ NACM0="<nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\">
|
||||||
"
|
"
|
||||||
|
|
||||||
cat<<EOF > $startupdb
|
cat<<EOF > $startupdb
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
$NACM0
|
$NACM0
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# An extra testmodule that includes nacm
|
# An extra testmodule that includes nacm
|
||||||
|
|
@ -158,9 +158,9 @@ fi
|
||||||
|
|
||||||
# Restart
|
# Restart
|
||||||
cat<<EOF > $startupdb
|
cat<<EOF > $startupdb
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
$NACM0
|
$NACM0
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
|
|
@ -270,3 +270,6 @@ fi
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,17 @@ cat <<EOF > $cfg
|
||||||
</clixon-config>
|
</clixon-config>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF > $dir/example.yang
|
||||||
|
module example {
|
||||||
|
namespace "urn:example:clixon";
|
||||||
|
prefix ex;
|
||||||
|
revision 2021-03-05;
|
||||||
|
leaf val{
|
||||||
|
type string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
# Subroutine send a process control RPC and tricks to echo process-id returned
|
# Subroutine send a process control RPC and tricks to echo process-id returned
|
||||||
# Args:
|
# Args:
|
||||||
# 1: operation
|
# 1: operation
|
||||||
|
|
@ -101,11 +112,11 @@ EOF
|
||||||
new "ENABLE true"
|
new "ENABLE true"
|
||||||
# First basic operation with restconf enable is true
|
# First basic operation with restconf enable is true
|
||||||
cat<<EOF > $startupdb
|
cat<<EOF > $startupdb
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<restconf xmlns="http://clicon.org/restconf">
|
<restconf xmlns="http://clicon.org/restconf">
|
||||||
<enable>true</enable>
|
<enable>true</enable>
|
||||||
</restconf>
|
</restconf>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
new "kill old restconf"
|
new "kill old restconf"
|
||||||
|
|
@ -273,11 +284,11 @@ fi
|
||||||
new "ENABLE false"
|
new "ENABLE false"
|
||||||
# Second basic operation with restconf enable is false
|
# Second basic operation with restconf enable is false
|
||||||
cat<<EOF > $startupdb
|
cat<<EOF > $startupdb
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
<restconf xmlns="http://clicon.org/restconf">
|
<restconf xmlns="http://clicon.org/restconf">
|
||||||
<enable>false</enable>
|
<enable>false</enable>
|
||||||
</restconf>
|
</restconf>
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
new "kill old restconf"
|
new "kill old restconf"
|
||||||
|
|
@ -320,7 +331,7 @@ pid=$(testrpc status 1)
|
||||||
if [ $? -ne 0 ]; then echo "$pid";exit -1; fi
|
if [ $? -ne 0 ]; then echo "$pid";exit -1; fi
|
||||||
|
|
||||||
# Edit a field, eg debug
|
# Edit a field, eg debug
|
||||||
new "Edit a field via restconf"
|
new "Edit a restconf field via restconf"
|
||||||
expectpart "$(curl $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/clixon-restconf:restconf/debug -d '{"clixon-restconf:debug":1}' )" 0 "HTTP/1.1 201 Created"
|
expectpart "$(curl $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/clixon-restconf:restconf/debug -d '{"clixon-restconf:debug":1}' )" 0 "HTTP/1.1 201 Created"
|
||||||
|
|
||||||
new "check status RPC new pid"
|
new "check status RPC new pid"
|
||||||
|
|
@ -331,6 +342,18 @@ if [ $pid -eq $pid1 ]; then
|
||||||
err "A different pid" "Same pid: $pid"
|
err "A different pid" "Same pid: $pid"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
new "Edit a non-restconf field via restconf"
|
||||||
|
echo "curl $CURLOPTS -X POST -H \"Content-Type: application/yang-data+json\" $RCPROTO://localhost/restconf/data -d '{\"example:val\":\"xyz\"}'"
|
||||||
|
|
||||||
|
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data -d '{"example:val":"xyz"}' )" 0 "HTTP/1.1 201 Created"
|
||||||
|
|
||||||
|
new "check status RPC same pid"
|
||||||
|
pid2=$(testrpc status 1)
|
||||||
|
if [ $? -ne 0 ]; then echo "$pid2";exit -1; fi
|
||||||
|
if [ $pid1 -ne $pid2 ]; then
|
||||||
|
err "Same pid $pid1" "$pid2"
|
||||||
|
fi
|
||||||
|
|
||||||
new "Disable restconf"
|
new "Disable restconf"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><default-operation>merge</default-operation><target><candidate/></target><config><restconf xmlns=\"http://clicon.org/restconf\"><enable>false</enable></restconf></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><default-operation>merge</default-operation><target><candidate/></target><config><restconf xmlns=\"http://clicon.org/restconf\"><enable>false</enable></restconf></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,9 +166,9 @@ EOF
|
||||||
function testrun()
|
function testrun()
|
||||||
{
|
{
|
||||||
cat <<EOF > $dir/startup_db
|
cat <<EOF > $dir/startup_db
|
||||||
<config>
|
<${DATASTORE_TOP}>
|
||||||
$RULES
|
$RULES
|
||||||
</config>
|
</${DATASTORE_TOP}>
|
||||||
EOF
|
EOF
|
||||||
if [ $BE -ne 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
|
|
|
||||||
|
|
@ -135,3 +135,6 @@ fi
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -188,20 +188,21 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
new "Kill backend"
|
||||||
|
# Check if premature kill
|
||||||
|
pid=$(pgrep -u root -f clixon_backend)
|
||||||
|
if [ -z "$pid" ]; then
|
||||||
|
err "backend already dead"
|
||||||
|
fi
|
||||||
|
# kill backend
|
||||||
|
stop_backend -f $cfg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -96,4 +96,5 @@ rm -rf $dir
|
||||||
unset nr
|
unset nr
|
||||||
unset clixon_util_path # for other script reusing it
|
unset clixon_util_path # for other script reusing it
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -94,3 +94,6 @@ rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset clixon_util_socket
|
unset clixon_util_socket
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,9 @@ function testrun(){
|
||||||
exprun=$5 # expected running_db after startup
|
exprun=$5 # expected running_db after startup
|
||||||
|
|
||||||
sudo rm -f $dir/*_db
|
sudo rm -f $dir/*_db
|
||||||
echo "<config>$rdb</config>" > $dir/running_db
|
echo "<${DATASTORE_TOP}>$rdb</${DATASTORE_TOP}>" > $dir/running_db
|
||||||
echo "<config>$sdb</config>" > $dir/startup_db
|
echo "<${DATASTORE_TOP}>$sdb</${DATASTORE_TOP}>" > $dir/startup_db
|
||||||
echo "<config>$edb</config>" > $dir/extra_db
|
echo "<${DATASTORE_TOP}>$edb</${DATASTORE_TOP}>" > $dir/extra_db
|
||||||
|
|
||||||
if [ $BE -ne 0 ]; then # Bring your own backend
|
if [ $BE -ne 0 ]; then # Bring your own backend
|
||||||
# kill old backend (if any)
|
# kill old backend (if any)
|
||||||
|
|
@ -118,9 +118,9 @@ function testfail(){
|
||||||
|
|
||||||
sudo rm -f $dir/*_db
|
sudo rm -f $dir/*_db
|
||||||
|
|
||||||
echo "<config>$rdb</config>" > $dir/running_db
|
echo "<${DATASTORE_TOP}>$rdb</${DATASTORE_TOP}>" > $dir/running_db
|
||||||
echo "<config>$sdb</config>" > $dir/startup_db
|
echo "<${DATASTORE_TOP}>$sdb</${DATASTORE_TOP}>" > $dir/startup_db
|
||||||
echo "<config>$edb</config>" > $dir/extra_db
|
echo "<${DATASTORE_TOP}>$edb</${DATASTORE_TOP}>" > $dir/extra_db
|
||||||
|
|
||||||
# kill old backend (if any)
|
# kill old backend (if any)
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
|
|
@ -138,20 +138,20 @@ function testfail(){
|
||||||
sudo chmod 666 $dir/running_db
|
sudo chmod 666 $dir/running_db
|
||||||
sudo chmod 666 $dir/startup_db
|
sudo chmod 666 $dir/startup_db
|
||||||
new "Checking running unchanged"
|
new "Checking running unchanged"
|
||||||
ret=$(diff $dir/running_db <(echo "<config>$rdb</config>"))
|
ret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>$rdb</${DATASTORE_TOP}>"))
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err "<config>$rdb</config>" "$ret"
|
err "<${DATASTORE_TOP}>$rdb</${DATASTORE_TOP}>" "$ret"
|
||||||
fi
|
fi
|
||||||
new "Checking startup unchanged"
|
new "Checking startup unchanged"
|
||||||
ret=$(diff $dir/startup_db <(echo "<config>$sdb</config>"))
|
ret=$(diff $dir/startup_db <(echo "<${DATASTORE_TOP}>$sdb</${DATASTORE_TOP}>"))
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err "<config>$sdb</config>" "$ret"
|
err "<${DATASTORE_TOP}>$sdb</${DATASTORE_TOP}>" "$ret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "Checking extra unchanged"
|
new "Checking extra unchanged"
|
||||||
ret=$(diff $dir/extra_db <(echo "<config>$edb</config>"))
|
ret=$(diff $dir/extra_db <(echo "<${DATASTORE_TOP}>$edb</${DATASTORE_TOP}>"))
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
err "<config>$edb</config>" "$ret"
|
err "<${DATASTORE_TOP}>$edb</${DATASTORE_TOP}>" "$ret"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -190,3 +190,6 @@ rm -rf $dir
|
||||||
|
|
||||||
# unset conditional parameters
|
# unset conditional parameters
|
||||||
unset format
|
unset format
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
|
|
@ -253,21 +253,22 @@ if [ $RC -ne 0 ]; then
|
||||||
stop_restconf
|
stop_restconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $BE -eq 0 ]; then
|
if [ $BE -ne 0 ]; then
|
||||||
exit # BE
|
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
|
||||||
|
sudo pkill -u root -f clixon_backend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
sudo pkill -u root -f clixon_backend
|
|
||||||
|
|
||||||
# Set by restconf_config
|
# Set by restconf_config
|
||||||
unset RESTCONFIG
|
unset RESTCONFIG
|
||||||
|
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
|
|
||||||
|
new "endtest"
|
||||||
|
endtest
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue