Added support for yang presence and no-presence containers.

This commit is contained in:
Olof hagsand 2017-07-23 12:59:02 +02:00
parent e56cf607a3
commit e5b625e722
19 changed files with 188 additions and 104 deletions

View file

@ -242,14 +242,9 @@ from_client_get_config(clicon_handle h,
goto ok;
}
cprintf(cbret, "<rpc-reply><data>");
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;
}
}
if (xret!=NULL &&
clicon_xml2cbuf(cbret, xret, 0, 0) < 0)
goto done;
cprintf(cbret, "</data></rpc-reply>");
ok:
retval = 0;

View file

@ -387,7 +387,7 @@ show_yang(clicon_handle h,
}
else
yn = (yang_node*)yspec;
yang_print(stdout, yn, 0);
yang_print(stdout, yn);
return 0;
}
int show_yangv(clicon_handle h, cvec *vars, cvec *argv)

View file

@ -238,6 +238,8 @@ netconf_plugin_callbacks(clicon_handle h,
yang_spec *yspec;
yang_stmt *yrpc;
yang_stmt *yinput;
yang_stmt *youtput;
cxobj *xoutput;
find_rpc_arg fra = {0,0};
int ret;
@ -279,6 +281,18 @@ netconf_plugin_callbacks(clicon_handle h,
*/
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
goto done;
/* Sanity check of outgoing XML */
if ((youtput = yang_find((yang_node*)yrpc, Y_OUTPUT, NULL)) != NULL){
xoutput=xpath_first(*xret, "/");
xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */
if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, yinput) < 0)
goto done;
if (xml_apply(xoutput, CX_ELMNT,
(xml_applyfn_t*)xml_yang_validate_all, NULL) < 0)
goto done;
if (xml_yang_validate_add(xoutput, NULL) < 0)
goto done;
}
retval = 1; /* handled by callback */
goto done;
}