Added decriptive error message when plugins produce invalid state XML.
This commit is contained in:
parent
266e5581e4
commit
bf04131e54
11 changed files with 156 additions and 41 deletions
|
|
@ -284,7 +284,7 @@ clixon_stats_get_db(clicon_handle h,
|
|||
if (xml_stats(xt, &nr, &sz) < 0)
|
||||
goto done;
|
||||
cprintf(cb, "<datastore><name>%s</name><nr>%" PRIu64 "</nr>"
|
||||
"<size>%" PRIu64 "</size></datastore>",
|
||||
"<size>%zu</size></datastore>",
|
||||
dbname, nr, sz);
|
||||
}
|
||||
retval = 0;
|
||||
|
|
@ -977,8 +977,6 @@ from_client_get(clicon_handle h,
|
|||
yang_stmt *yspec;
|
||||
int i;
|
||||
cxobj *xerr = NULL;
|
||||
cxobj *xr;
|
||||
cxobj *xb;
|
||||
int ret;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
|
|
@ -1064,21 +1062,16 @@ from_client_get(clicon_handle h,
|
|||
*/
|
||||
if ((ret = xml_yang_validate_all_top(h, xret, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret > 0 && (ret = xml_yang_validate_add(h, xret, &xerr)) < 0)
|
||||
if (ret > 0 &&
|
||||
(ret = xml_yang_validate_add(h, xret, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (debug)
|
||||
clicon_log_xml(LOG_DEBUG, xret, "VALIDATE_STATE");
|
||||
if ((xr = xpath_first(xerr, NULL, "//error-tag")) != NULL &&
|
||||
(xb = xml_body_get(xr))){
|
||||
if (xml_value_set(xb, "operation-failed") < 0)
|
||||
goto done;
|
||||
}
|
||||
if ((xr = xpath_first(xerr, NULL, "//error-message")) != NULL &&
|
||||
(xb = xml_body_get(xr))){
|
||||
if (xml_value_append(xb, " Internal error, state callback returned invalid XML") < 0)
|
||||
goto done;
|
||||
}
|
||||
if (clixon_netconf_internal_error(xerr,
|
||||
". Internal error, state callback returned invalid XML",
|
||||
NULL) < 0)
|
||||
goto done;
|
||||
if (clicon_xml2cbuf(cbret, xerr, 0, 0, -1) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ clixon_plugin_statedata_all(clicon_handle h,
|
|||
cxobj *x = NULL;
|
||||
clixon_plugin *cp = NULL;
|
||||
cbuf *cberr = NULL;
|
||||
cxobj *xerr = NULL;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
while ((cp = clixon_plugin_each(h, cp)) != NULL) {
|
||||
|
|
@ -249,8 +250,18 @@ clixon_plugin_statedata_all(clicon_handle h,
|
|||
clicon_log_xml(LOG_DEBUG, x, "%s STATE:", __FUNCTION__);
|
||||
#endif
|
||||
/* XXX: ret == 0 invalid yang binding should be handled as internal error */
|
||||
if (xml_bind_yang(x, YB_MODULE, yspec, NULL) < 0)
|
||||
if ((ret = xml_bind_yang(x, YB_MODULE, yspec, &xerr)) < 0)
|
||||
goto done;
|
||||
if (ret == 0){
|
||||
if (clixon_netconf_internal_error(xerr,
|
||||
". Internal error, state callback returned invalid XML: ",
|
||||
cp->cp_name) < 0)
|
||||
goto done;
|
||||
xml_free(*xret);
|
||||
*xret = xerr;
|
||||
xerr = NULL;
|
||||
goto fail;
|
||||
}
|
||||
if (xml_sort_recurse(x) < 0)
|
||||
goto done;
|
||||
if (xml_default_recurse(x) < 0)
|
||||
|
|
@ -266,6 +277,8 @@ clixon_plugin_statedata_all(clicon_handle h,
|
|||
} /* while plugin */
|
||||
retval = 1;
|
||||
done:
|
||||
if (xerr)
|
||||
xml_free(xerr);
|
||||
if (cberr)
|
||||
cbuf_free(cberr);
|
||||
if (x)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue