* 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:
Olof hagsand 2021-03-05 14:15:15 +01:00
parent 2ab90d847b
commit b7991d9b39
132 changed files with 939 additions and 628 deletions

View file

@ -716,7 +716,7 @@ usage(clicon_handle h,
fprintf(stderr, "usage:%s [options]\n"
"where options are\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-E <dir> \t Extra configuration file directory\n"
"\t-l <s|f<file>> \t Log on (s)yslog, (f)ile (syslog is default)\n"

View file

@ -305,7 +305,7 @@ api_data_write(clicon_handle h,
else
op = OP_REPLACE; /* OP_CREATE if it does not exist */
/* 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;
/* Translate api_path to xml in the form of xtop/xbot */
xbot = xtop;
@ -480,7 +480,7 @@ api_data_write(clicon_handle h,
*/
dname = xml_name(xdata);
if (api_path==NULL) {
if (strcmp(dname, "data")!=0){
if (strcmp(dname, NETCONF_OUTPUT_DATA)!=0){
if (netconf_bad_element_xml(&xerr, "application", dname,
"Data element does not match top-level data") < 0)
goto done;
@ -497,7 +497,7 @@ api_data_write(clicon_handle h,
if (xtop) /* also xbot */
xml_free(xtop);
xtop = xdata;
xml_name_set(xtop, "config");
xml_name_set(xtop, NETCONF_INPUT_CONFIG);
/* remove default namespace */
if ((xa = xml_find_type(xtop, NULL, "xmlns", CX_ATTR)) != NULL){
if (xml_rm(xa) < 0)
@ -818,7 +818,7 @@ api_data_delete(clicon_handle h,
for (i=0; i<pi; i++)
api_path = index(api_path+1, '/');
/* 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;
xbot = xtop;
if (api_path){

View file

@ -188,7 +188,7 @@ api_data_post(clicon_handle h,
for (i=0; i<pi; i++)
api_path = index(api_path+1, '/');
/* 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;
/* Translate api_path to xtop/xbot */
xbot = xtop;
@ -524,7 +524,7 @@ api_operations_post_input(clicon_handle h,
goto fail;
break;
} /* switch media_in */
xml_name_set(xdata, "data");
xml_name_set(xdata, NETCONF_OUTPUT_DATA);
/* Here xdata is:
* <data><input xmlns="urn:example:clixon">...</input></data>
*/

View file

@ -471,7 +471,7 @@ api_root_restconf(clicon_handle h,
if (api_yang_library_version(h, req, pretty, media_out) < 0)
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,
pretty, media_out, IETF_DS_NONE) < 0)
goto done;