More updates for Error/Log/Debug API changes

This commit is contained in:
Olof hagsand 2023-12-18 17:19:14 +01:00
parent 24a4991ec8
commit f25a77734e
8 changed files with 4 additions and 104 deletions

View file

@ -945,23 +945,15 @@ compare_db_names(clixon_handle h,
if (clicon_rpc_get_config(h, NULL, db1, "/", NULL, NULL, &xc1) < 0) if (clicon_rpc_get_config(h, NULL, db1, "/", NULL, NULL, &xc1) < 0)
goto done; goto done;
if ((xerr = xpath_first(xc1, NULL, "/rpc-error")) != NULL){ if ((xerr = xpath_first(xc1, NULL, "/rpc-error")) != NULL){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "Get configuration", NULL);
#endif
goto done; goto done;
} }
if (clicon_rpc_get_config(h, NULL, db2, "/", NULL, NULL, &xc2) < 0) if (clicon_rpc_get_config(h, NULL, db2, "/", NULL, NULL, &xc2) < 0)
goto done; goto done;
if ((xerr = xpath_first(xc2, NULL, "/rpc-error")) != NULL){ if ((xerr = xpath_first(xc2, NULL, "/rpc-error")) != NULL){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "Get configuration", NULL);
#endif
goto done; goto done;
} }
/* Note that XML and TEXT uses a (new) structured in-mem algorithm while /* Note that XML and TEXT uses a (new) structured in-mem algorithm while
@ -1129,12 +1121,8 @@ load_config_file(clixon_handle h,
if ((ret = clixon_xml_parse_file(fp, YB_NONE, yspec, &xt, &xerr)) < 0) if ((ret = clixon_xml_parse_file(fp, YB_NONE, yspec, &xt, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Loading %s", filename) < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Loading %s", filename) < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "Loading", filename);
#endif
goto done; goto done;
} }
break; break;
@ -1142,12 +1130,8 @@ load_config_file(clixon_handle h,
if ((ret = clixon_json_parse_file(fp, 1, YB_NONE, yspec, &xt, &xerr)) < 0) if ((ret = clixon_json_parse_file(fp, 1, YB_NONE, yspec, &xt, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Loading %s", filename) < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Loading %s", filename) < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "Loading", filename);
#endif
goto done; goto done;
} }
break; break;
@ -1158,12 +1142,8 @@ load_config_file(clixon_handle h,
if ((ret = clixon_text_syntax_parse_file(fp, YB_MODULE_NEXT, yspec, &xt, &xerr)) < 0) if ((ret = clixon_text_syntax_parse_file(fp, YB_MODULE_NEXT, yspec, &xt, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Loading %s", filename) < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Loading %s", filename) < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "Loading", filename);
#endif
goto done; goto done;
} }
break; break;
@ -1303,12 +1283,8 @@ save_config_file(clixon_handle h,
goto done; goto done;
} }
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){ if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "Get configuration", NULL);
#endif
goto done; goto done;
} }
/* 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
@ -1692,12 +1668,8 @@ cli_copy_config(clixon_handle h,
if (clicon_rpc_get_config(h, NULL, db, cbuf_get(cb), nsc, NULL, &x1) < 0) if (clicon_rpc_get_config(h, NULL, db, cbuf_get(cb), nsc, NULL, &x1) < 0)
goto done; goto done;
if ((xerr = xpath_first(x1, NULL, "/rpc-error")) != NULL){ if ((xerr = xpath_first(x1, NULL, "/rpc-error")) != NULL){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "Get configuration", NULL);
#endif
goto done; goto done;
} }

View file

@ -151,12 +151,8 @@ restconf_main_config(clixon_handle h,
if ((ret = clixon_xml_parse_string(inline_config, YB_MODULE, yspec, &xrestconf, &xerr)) < 0) if ((ret = clixon_xml_parse_string(inline_config, YB_MODULE, yspec, &xrestconf, &xerr)) < 0)
goto done; goto done;
if (ret == 0){ if (ret == 0){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Inline restconf config") < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Inline restconf config") < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "Inline restconf config", NULL);
#endif
goto done; goto done;
} }
/* Replace parent w first child */ /* Replace parent w first child */

View file

@ -679,12 +679,8 @@ restconf_clixon_backend(clixon_handle h,
if (clicon_rpc_get_config(h, pw->pw_name, "running", "/restconf", nsc, NULL, &xconfig) < 0) if (clicon_rpc_get_config(h, pw->pw_name, "running", "/restconf", nsc, NULL, &xconfig) < 0)
goto done; goto done;
if ((xerr = xpath_first(xconfig, NULL, "/rpc-error")) != NULL){ if ((xerr = xpath_first(xconfig, NULL, "/rpc-error")) != NULL){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get backend restconf config") < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get backend restconf config") < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "Get backend restconf config", NULL);
#endif
goto done; goto done;
} }
/* Extract restconf configuration */ /* Extract restconf configuration */

View file

@ -263,12 +263,8 @@ snmp_scalar_get(clixon_handle h,
goto done; goto done;
/* Detect error XXX Error handling could improve */ /* Detect error XXX Error handling could improve */
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){ if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
#if 1
if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0) if (clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Get configuration") < 0)
goto done; goto done;
#else
clixon_netconf_error(h, xerr, "clicon_rpc_get", NULL);
#endif
goto done; goto done;
} }
x = xpath_first(xt, nsc, "%s", xpath); x = xpath_first(xt, nsc, "%s", xpath);

View file

@ -204,9 +204,10 @@
*/ */
#undef RESTCONF_INLINE #undef RESTCONF_INLINE
/*! Backward compatible with 6.5 /*! Backward compatible with 6.5 for Error, Log and Debug APIs
* *
* Note: many(most) not covered by this constant need to GREP * Note: many(most) not covered by this constant need to GREP
* This includes lots of clicon->clixon namechanges, see CHANGELOG for whole list * This includes lots of clicon->clixon namechanges, see CHANGELOG for whole list
* This constant will be removed after the 6.6 release
*/ */
#define COMPAT_6_5 #define COMPAT_6_5

View file

@ -103,10 +103,6 @@ clixon_log_init(clixon_handle h,
int upto, int upto,
int flags) int flags)
{ {
if (h == NULL){
errno = EINVAL;
return -1;
}
_log_clixon_h = h; _log_clixon_h = h;
_log_flags = flags; _log_flags = flags;
if (flags & CLIXON_LOG_SYSLOG){ if (flags & CLIXON_LOG_SYSLOG){

View file

@ -2354,7 +2354,7 @@ netconf_input_chunked_framing(char ch,
* printf("%s", cbuf_get(cb)); * printf("%s", cbuf_get(cb));
* cbuf_free(cb); * cbuf_free(cb);
* @endcode * @endcode
* @see clixon_netconf_error_fn * @see clixon_err_netconf_fn
*/ */
int int
netconf_err2cb(clixon_handle h, netconf_err2cb(clixon_handle h,
@ -2407,7 +2407,7 @@ netconf_err2cb(clixon_handle h,
* @retval 0 OK * @retval 0 OK
* @retval -1 Error * @retval -1 Error
* @see netconf_err2cb * @see netconf_err2cb
* @see clixon_netconf_error macro * @see clixon_err_netconf macro
*/ */
int int
clixon_err_netconf_fn(clixon_handle h, clixon_err_netconf_fn(clixon_handle h,

View file

@ -509,7 +509,6 @@ clicon_rpc_netconf_xml(clixon_handle h,
* xml_nsctx_free(nsc); * xml_nsctx_free(nsc);
* @endcode * @endcode
* @see clicon_rpc_get * @see clicon_rpc_get
* @see clixon_netconf_error
* @note the netconf return message is yang populated, as well as the return data * @note the netconf return message is yang populated, as well as the return data
*/ */
int int
@ -671,11 +670,7 @@ clicon_rpc_edit_config(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Editing configuration"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Editing configuration");
#else
clixon_netconf_error(h, xerr, "Editing configuration", NULL);
#endif
goto done; goto done;
} }
retval = 0; retval = 0;
@ -737,11 +732,7 @@ clicon_rpc_copy_config(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Copying configuration"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Copying configuration");
#else
clixon_netconf_error(h, xerr, "Copying configuration", NULL);
#endif
goto done; goto done;
} }
retval = 0; retval = 0;
@ -799,11 +790,7 @@ clicon_rpc_delete_config(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Deleting configuration"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Deleting configuration");
#else
clixon_netconf_error(h, xerr, "Deleting configuration", NULL);
#endif
goto done; goto done;
} }
retval = 0; retval = 0;
@ -857,11 +844,7 @@ clicon_rpc_lock(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Locking configuration"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Locking configuration");
#else
clixon_netconf_error(h, xerr, "Locking configuration", NULL);
#endif
goto done; goto done;
} }
retval = 0; retval = 0;
@ -915,11 +898,7 @@ clicon_rpc_unlock(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Unlocking configuration"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Unlocking configuration");
#else
clixon_netconf_error(h, xerr, "Configuration unlock", NULL);
#endif
goto done; goto done;
} }
retval = 0; retval = 0;
@ -1350,11 +1329,7 @@ clicon_rpc_close_session(clixon_handle h)
clicon_client_socket_set(h, -1); clicon_client_socket_set(h, -1);
} }
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Close session"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Close session");
#else
clixon_netconf_error(h, xerr, "Close session", NULL);
#endif
goto done; goto done;
} }
retval = 0; retval = 0;
@ -1408,11 +1383,7 @@ clicon_rpc_kill_session(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Kill session"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Kill session");
#else
clixon_netconf_error(h, xerr, "Kill session", NULL);
#endif
goto done; goto done;
} }
retval = 0; retval = 0;
@ -1468,11 +1439,7 @@ clicon_rpc_validate(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, CLIXON_ERRSTR_VALIDATE_FAILED); clixon_err_netconf(h, OE_NETCONF, 0, xerr, CLIXON_ERRSTR_VALIDATE_FAILED);
#else
clixon_netconf_error(h, xerr, CLIXON_ERRSTR_VALIDATE_FAILED, NULL);
#endif
retval = 0; retval = 0;
goto done; goto done;
} }
@ -1579,11 +1546,7 @@ clicon_rpc_commit(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, CLIXON_ERRSTR_COMMIT_FAILED); clixon_err_netconf(h, OE_NETCONF, 0, xerr, CLIXON_ERRSTR_COMMIT_FAILED);
#else
clixon_netconf_error(h, xerr, CLIXON_ERRSTR_COMMIT_FAILED, NULL);
#endif
retval = 0; retval = 0;
goto done; goto done;
} }
@ -1642,11 +1605,7 @@ clicon_rpc_discard_changes(clixon_handle h)
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Discard changes"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Discard changes");
#else
clixon_netconf_error(h, xerr, "Discard changes", NULL);
#endif
goto done; goto done;
} }
retval = 0; retval = 0;
@ -1711,11 +1670,7 @@ clicon_rpc_create_subscription(clixon_handle h,
if (clicon_rpc_msg_persistent(h, msg, &xret, s0) < 0) if (clicon_rpc_msg_persistent(h, msg, &xret, s0) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Create subscription"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Create subscription");
#else
clixon_netconf_error(h, xerr, "Create subscription", NULL);
#endif
goto done; goto done;
} }
retval = 0; retval = 0;
@ -1770,11 +1725,7 @@ clicon_rpc_debug(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Debug"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Debug");
#else
clixon_netconf_error(h, xerr, "Debug", NULL);
#endif
goto done; goto done;
} }
if (xpath_first(xret, NULL, "//rpc-reply/ok") == NULL){ if (xpath_first(xret, NULL, "//rpc-reply/ok") == NULL){
@ -1840,11 +1791,7 @@ clicon_rpc_restconf_debug(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Debug"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Debug");
#else
clixon_netconf_error(h, xerr, "Debug", NULL);
#endif
goto done; goto done;
} }
if (xpath_first(xret, NULL, "//rpc-reply/ok") == NULL){ if (xpath_first(xret, NULL, "//rpc-reply/ok") == NULL){
@ -1933,11 +1880,7 @@ clicon_hello_req(clixon_handle h,
if (clicon_rpc_msg(h, msg, &xret) < 0) if (clicon_rpc_msg(h, msg, &xret) < 0)
goto done; goto done;
if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){ if ((xerr = xpath_first(xret, NULL, "//rpc-error")) != NULL){
#if 1
clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Hello"); clixon_err_netconf(h, OE_NETCONF, 0, xerr, "Hello");
#else
clixon_netconf_error(h, xerr, "Hello", NULL);
#endif
goto done; goto done;
} }
if ((x = xpath_first(xret, NULL, "hello/session-id")) == NULL){ if ((x = xpath_first(xret, NULL, "hello/session-id")) == NULL){