local restconf rpc callback sent error and then main restconf handler sent ok. Callback should just return xml buffer, not do actual restconf callback
This commit is contained in:
parent
24de61f14a
commit
b2abab71f0
3 changed files with 18 additions and 5 deletions
|
|
@ -385,7 +385,7 @@ get_user_cookie(char *cookiestr,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Return error on get/head request
|
/*! Return restconf error on get/head request
|
||||||
* @param[in] h Clixon handle
|
* @param[in] h Clixon handle
|
||||||
* @param[in] r Fastcgi request handle
|
* @param[in] r Fastcgi request handle
|
||||||
* @param[in] xerr XML error message from backend
|
* @param[in] xerr XML error message from backend
|
||||||
|
|
|
||||||
|
|
@ -984,6 +984,7 @@ api_operations_post(clicon_handle h,
|
||||||
yang_stmt *youtput;
|
yang_stmt *youtput;
|
||||||
cxobj *xdata = NULL;
|
cxobj *xdata = NULL;
|
||||||
cxobj *xret = NULL;
|
cxobj *xret = NULL;
|
||||||
|
cxobj *xerr;
|
||||||
cbuf *cbx = NULL;
|
cbuf *cbx = NULL;
|
||||||
cxobj *xtop = NULL; /* xpath root */
|
cxobj *xtop = NULL; /* xpath root */
|
||||||
cxobj *xe;
|
cxobj *xe;
|
||||||
|
|
@ -1080,6 +1081,7 @@ api_operations_post(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
xe = NULL;
|
xe = NULL;
|
||||||
|
|
||||||
while ((xe = xml_child_each(xtop, xe, CX_ELMNT)) != NULL) {
|
while ((xe = xml_child_each(xtop, xe, CX_ELMNT)) != NULL) {
|
||||||
/* Look for local (client-side) restconf plugins. */
|
/* Look for local (client-side) restconf plugins. */
|
||||||
if ((ret = rpc_callback_call(h, xe, cbret, r)) < 0)
|
if ((ret = rpc_callback_call(h, xe, cbret, r)) < 0)
|
||||||
|
|
@ -1087,6 +1089,12 @@ api_operations_post(clicon_handle h,
|
||||||
if (ret == 1){ /* Handled locally */
|
if (ret == 1){ /* Handled locally */
|
||||||
if (xml_parse_string(cbuf_get(cbret), NULL, &xret) < 0)
|
if (xml_parse_string(cbuf_get(cbret), NULL, &xret) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
/* Local error: return it and quit */
|
||||||
|
if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){
|
||||||
|
if (api_return_err(h, r, xerr, pretty, use_xml) < 0)
|
||||||
|
goto done;
|
||||||
|
goto ok;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break; /* Just one if local */
|
break; /* Just one if local */
|
||||||
}
|
}
|
||||||
|
|
@ -1095,11 +1103,13 @@ api_operations_post(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
if ((cbx = cbuf_new()) == NULL)
|
if ((cbx = cbuf_new()) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
xoutput=xpath_first(xret, "/");
|
if ((xoutput=xpath_first(xret, "/")) != NULL)
|
||||||
xml_name_set(xoutput, "output");
|
xml_name_set(xoutput, "output");
|
||||||
if ((youtput = yang_find((yang_node*)yrpc, Y_OUTPUT, NULL)) != NULL &&
|
if ((youtput = yang_find((yang_node*)yrpc, Y_OUTPUT, NULL)) != NULL &&
|
||||||
xoutput){
|
xoutput){
|
||||||
// clicon_debug(1, "%s xoutput:%s", __FUNCTION__, cbuf_get(cbx));
|
#if 0
|
||||||
|
clicon_debug(1, "%s xoutput:%s", __FUNCTION__, cbuf_get(cbx));
|
||||||
|
#endif
|
||||||
cbuf_reset(cbx);
|
cbuf_reset(cbx);
|
||||||
xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */
|
xml_spec_set(xoutput, youtput); /* needed for xml_spec_populate */
|
||||||
if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, youtput) < 0)
|
if (xml_apply(xoutput, CX_ELMNT, xml_spec_populate, youtput) < 0)
|
||||||
|
|
@ -1122,7 +1132,9 @@ api_operations_post(clicon_handle h,
|
||||||
else
|
else
|
||||||
if (xml2json_cbuf(cbx, xoutput, pretty) < 0)
|
if (xml2json_cbuf(cbx, xoutput, pretty) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
#if 1
|
||||||
clicon_debug(1, "%s xoutput:%s", __FUNCTION__, cbuf_get(cbx));
|
clicon_debug(1, "%s xoutput:%s", __FUNCTION__, cbuf_get(cbx));
|
||||||
|
#endif
|
||||||
FCGX_FPrintF(r->out, "%s", cbx?cbuf_get(cbx):"");
|
FCGX_FPrintF(r->out, "%s", cbx?cbuf_get(cbx):"");
|
||||||
FCGX_FPrintF(r->out, "\r\n\r\n");
|
FCGX_FPrintF(r->out, "\r\n\r\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -465,8 +465,8 @@ rpc_callback_call(clicon_handle h,
|
||||||
cbuf *cbret,
|
cbuf *cbret,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
rpc_callback_t *rc;
|
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
rpc_callback_t *rc;
|
||||||
|
|
||||||
if (rpc_cb_list == NULL)
|
if (rpc_cb_list == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -486,5 +486,6 @@ rpc_callback_call(clicon_handle h,
|
||||||
} while (rc != rpc_cb_list);
|
} while (rc != rpc_cb_list);
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue