Changed top-level netconf get-config and get to return <data>..</data> instead of <data><config>...</config></data> to comply to the RFC.

This commit is contained in:
Olof hagsand 2017-07-23 14:45:33 +02:00
parent 2141b4972a
commit 2d65fdbe93
8 changed files with 89 additions and 40 deletions

View file

@ -241,11 +241,16 @@ from_client_get_config(clicon_handle h,
"</rpc-error></rpc-reply>");
goto ok;
}
cprintf(cbret, "<rpc-reply><data>");
if (xret!=NULL &&
clicon_xml2cbuf(cbret, xret, 0, 0) < 0)
cprintf(cbret, "<rpc-reply>");
if (xret==NULL)
cprintf(cbret, "<data/>");
else{
if (xml_name_set(xret, "data") < 0)
goto done;
cprintf(cbret, "</data></rpc-reply>");
if (clicon_xml2cbuf(cbret, xret, 0, 0) < 0)
goto done;
}
cprintf(cbret, "</rpc-reply>");
ok:
retval = 0;
done:
@ -288,17 +293,16 @@ from_client_get(clicon_handle h,
assert(xret);
if (backend_statedata_call(h, selector, xret) < 0)
goto done;
cprintf(cbret, "<rpc-reply><data>");
/* if empty only <config/> */
if (xret!=NULL){
if (xml_child_nr(xret)){
if (xml_name_set(xret, "config") < 0)
goto done;
if (clicon_xml2cbuf(cbret, xret, 0, 0) < 0)
goto done;
}
cprintf(cbret, "<rpc-reply>");
if (xret==NULL)
cprintf(cbret, "<data/>");
else{
if (xml_name_set(xret, "data") < 0)
goto done;
if (clicon_xml2cbuf(cbret, xret, 0, 0) < 0)
goto done;
}
cprintf(cbret, "</data></rpc-reply>");
cprintf(cbret, "</rpc-reply>");
ok:
retval = 0;
done:

View file

@ -159,7 +159,7 @@ netconf_get_config(clicon_handle h,
goto done;
if (xfilter &&
(xfilterconf = xpath_first(xfilter, "//configuration"))!= NULL &&
(xconf = xpath_first(*xret, "/rpc-reply/data/configuration")) != NULL){
(xconf = xpath_first(*xret, "/rpc-reply/data")) != NULL){
/* xml_filter removes parts of xml tree not matching */
if ((strcmp(xml_name(xfilterconf), xml_name(xconf))!=0) ||
xml_filter(xfilterconf, xconf) < 0){
@ -571,7 +571,7 @@ netconf_get(clicon_handle h,
goto done;
if (xfilter &&
(xfilterconf = xpath_first(xfilter, "//configuration"))!= NULL &&
(xconf = xpath_first(*xret, "/rpc-reply/data/configuration")) != NULL){
(xconf = xpath_first(*xret, "/rpc-reply/data")) != NULL){
/* xml_filter removes parts of xml tree not matching */
if ((strcmp(xml_name(xfilterconf), xml_name(xconf))!=0) ||
xml_filter(xfilterconf, xconf) < 0){