State callback error message changed to include namespace and use proper <bad-element>
This commit is contained in:
parent
7ad16bd84b
commit
b78054e7cf
4 changed files with 38 additions and 14 deletions
|
|
@ -953,7 +953,7 @@ netconf_operation_not_supported(cbuf *cb,
|
|||
* some reason not covered by any other error condition.
|
||||
* @param[out] cb CLIgen buf. Error XML is written in this buffer
|
||||
* @param[in] type Error type: "rpc", "application" or "protocol"
|
||||
* @param[in] message Error message
|
||||
* @param[in] message Error message (will be XML encoded)
|
||||
* @see netconf_operation_failed_xml Same but returns XML tree
|
||||
*/
|
||||
int
|
||||
|
|
@ -994,6 +994,7 @@ int
|
|||
netconf_operation_failed_xml(cxobj **xret,
|
||||
char *type,
|
||||
char *message)
|
||||
|
||||
{
|
||||
int retval =-1;
|
||||
cxobj *xerr;
|
||||
|
|
@ -1009,7 +1010,8 @@ netconf_operation_failed_xml(cxobj **xret,
|
|||
goto done;
|
||||
if (xml_parse_va(&xerr, NULL, "<error-type>%s</error-type>"
|
||||
"<error-tag>operation-failed</error-tag>"
|
||||
"<error-severity>error</error-severity>", type) < 0)
|
||||
"<error-severity>error</error-severity>",
|
||||
type) < 0)
|
||||
goto done;
|
||||
if (message){
|
||||
if (xml_chardata_encode(&encstr, "%s", message) < 0)
|
||||
|
|
|
|||
|
|
@ -1274,13 +1274,27 @@ xml_yang_validate_all(clicon_handle h,
|
|||
int nr;
|
||||
int ret;
|
||||
cxobj *x;
|
||||
char *namespace = NULL;
|
||||
cbuf *cb = NULL;
|
||||
|
||||
/* if not given by argument (overide) use default link
|
||||
and !Node has a config sub-statement and it is false */
|
||||
ys=xml_spec(xt);
|
||||
if (ys==NULL){
|
||||
if (netconf_unknown_element_xml(xret, "application", xml_name(xt), NULL) < 0)
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
if (xml2ns(xt, xml_prefix(xt), &namespace) < 0)
|
||||
goto done;
|
||||
if (namespace){
|
||||
cprintf(cb, "namespace is: %s", namespace);
|
||||
if (netconf_unknown_element_xml(xret, "application", xml_name(xt), cbuf_get(cb)) < 0)
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
if (netconf_unknown_element_xml(xret, "application", xml_name(xt), NULL) < 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
}
|
||||
if (yang_config(ys) != 0){
|
||||
|
|
@ -1326,7 +1340,7 @@ xml_yang_validate_all(clicon_handle h,
|
|||
goto done;
|
||||
if (!nr){
|
||||
ye = yang_find(yc, Y_ERROR_MESSAGE, NULL);
|
||||
if (netconf_operation_failed_xml(xret, "application",
|
||||
if (netconf_operation_failed_xml(xret, "application",
|
||||
ye?ye->ys_argument:"must xpath validation failed") < 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
|
|
@ -1338,7 +1352,7 @@ xml_yang_validate_all(clicon_handle h,
|
|||
if ((nr = xpath_vec_bool(xt, NULL, "%s", xpath)) < 0)
|
||||
goto done;
|
||||
if (!nr){
|
||||
if (netconf_operation_failed_xml(xret, "application",
|
||||
if (netconf_operation_failed_xml(xret, "application",
|
||||
"when xpath validation failed") < 0)
|
||||
goto done;
|
||||
goto fail;
|
||||
|
|
@ -1363,6 +1377,8 @@ xml_yang_validate_all(clicon_handle h,
|
|||
ok:
|
||||
retval = 1;
|
||||
done:
|
||||
if (cb)
|
||||
cbuf_free(cb);
|
||||
return retval;
|
||||
fail:
|
||||
retval = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue