* xml_merge() changed to use 3-value return: 1:OK, 0:Yang failed, -1: Error

* `clixon_netconf_error(category, xerr, msg, arg)` removed first argument -> `clixon_netconf_error(xerr, msg, arg)`
* Renamed utility function `clixon_util_insert()` to `clixon_util_xml_mod()` and added merge functionality.
* Fixed: Insertion of subtree leaf nodes were not made in the crrect place, always ended up last regardless of yang spec (if ordered-by system).
This commit is contained in:
Olof hagsand 2020-04-17 15:47:37 +02:00
parent f401c07c4b
commit 0d4263e324
16 changed files with 376 additions and 274 deletions

View file

@ -301,7 +301,7 @@ clicon_rpc_netconf_xml(clicon_handle h,
* if (clicon_rpc_get_config(h, NULL, "running", "/hello/world", nsc, &xt) < 0)
* err;
* if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
* clixon_netconf_error(OE_NETCONF, xerr, "msg", "/hello/world");
* clixon_netconf_error(xerr, "msg", "/hello/world");
* err;
* }
* if (xt)
@ -445,7 +445,7 @@ clicon_rpc_edit_config(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Editing configuration", NULL);
clixon_netconf_error(xerr, "Editing configuration", NULL);
goto done;
}
retval = 0;
@ -495,7 +495,7 @@ clicon_rpc_copy_config(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Copying configuration", NULL);
clixon_netconf_error(xerr, "Copying configuration", NULL);
goto done;
}
retval = 0;
@ -538,7 +538,7 @@ clicon_rpc_delete_config(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Deleting configuration", NULL);
clixon_netconf_error(xerr, "Deleting configuration", NULL);
goto done;
}
retval = 0;
@ -577,7 +577,7 @@ clicon_rpc_lock(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Locking configuration", NULL);
clixon_netconf_error(xerr, "Locking configuration", NULL);
goto done;
}
retval = 0;
@ -615,7 +615,7 @@ clicon_rpc_unlock(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Configuration unlock", NULL);
clixon_netconf_error(xerr, "Configuration unlock", NULL);
goto done;
}
retval = 0;
@ -649,7 +649,7 @@ clicon_rpc_unlock(clicon_handle h,
* if (clicon_rpc_get(h, "/hello/world", nsc, CONTENT_ALL, -1, &xt) < 0)
* err;
* if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
* clixon_netconf_error(OE_NETCONF, xerr, "clicon_rpc_get", NULL);
* clixon_netconf_error(xerr, "clicon_rpc_get", NULL);
* err;
* }
* if (xt)
@ -779,7 +779,7 @@ clicon_rpc_close_session(clicon_handle h)
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Close session", NULL);
clixon_netconf_error(xerr, "Close session", NULL);
goto done;
}
retval = 0;
@ -818,7 +818,7 @@ clicon_rpc_kill_session(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Kill session", NULL);
clixon_netconf_error(xerr, "Kill session", NULL);
goto done;
}
retval = 0;
@ -856,7 +856,7 @@ clicon_rpc_validate(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, CLIXON_ERRSTR_VALIDATE_FAILED, NULL);
clixon_netconf_error(xerr, CLIXON_ERRSTR_VALIDATE_FAILED, NULL);
goto done;
}
retval = 0;
@ -892,7 +892,7 @@ clicon_rpc_commit(clicon_handle h)
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, CLIXON_ERRSTR_COMMIT_FAILED, NULL);
clixon_netconf_error(xerr, CLIXON_ERRSTR_COMMIT_FAILED, NULL);
goto done;
}
retval = 0;
@ -928,7 +928,7 @@ clicon_rpc_discard_changes(clicon_handle h)
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Discard changes", NULL);
clixon_netconf_error(xerr, "Discard changes", NULL);
goto done;
}
retval = 0;
@ -978,7 +978,7 @@ clicon_rpc_create_subscription(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, s0) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Create subscription", NULL);
clixon_netconf_error(xerr, "Create subscription", NULL);
goto done;
}
retval = 0;
@ -1016,7 +1016,7 @@ clicon_rpc_debug(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Debug", NULL);
clixon_netconf_error(xerr, "Debug", NULL);
goto done;
}
if (xpath_first(xret, NULL, "//rpc-reply/ok") == NULL){
@ -1059,7 +1059,7 @@ clicon_hello_req(clicon_handle h,
if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
clixon_netconf_error(OE_NETCONF, xerr, "Hello", NULL);
clixon_netconf_error(xerr, "Hello", NULL);
goto done;
}
if ((x = xpath_first(xret, NULL, "hello/session-id")) == NULL){