Added parameter defaults to library function clicon_rpc_get
This commit is contained in:
parent
6bee1746e0
commit
14cc88ca39
7 changed files with 15 additions and 29 deletions
|
|
@ -437,7 +437,7 @@ cli_auto_show(clicon_handle h,
|
|||
clicon_err(OE_FATAL, 0, "Show state only for running database, not %s", db);
|
||||
goto done;
|
||||
}
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, &xt) < 0)
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
|
||||
goto done;
|
||||
}
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
|
|
|
|||
|
|
@ -484,7 +484,7 @@ cli_show_config1(clicon_handle h,
|
|||
clicon_err(OE_FATAL, 0, "Show state only for running database, not %s", db);
|
||||
goto done;
|
||||
}
|
||||
if (clicon_rpc_get(h, cbuf_get(cbxpath), nsc, CONTENT_ALL, -1, &xt) < 0)
|
||||
if (clicon_rpc_get(h, cbuf_get(cbxpath), nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
|
||||
goto done;
|
||||
}
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
|
|
@ -749,7 +749,7 @@ cli_show_auto1(clicon_handle h,
|
|||
clicon_err(OE_FATAL, 0, "Show state only for running database, not %s", db);
|
||||
goto done;
|
||||
}
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, &xt) < 0)
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
|
||||
goto done;
|
||||
}
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ api_data_get2(clicon_handle h,
|
|||
cxobj *xtop = NULL;
|
||||
cxobj *xbot = NULL;
|
||||
yang_stmt *y = NULL;
|
||||
char *with_defaults = NULL;
|
||||
char *defaults = NULL;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
if ((yspec = clicon_dbspec_yang(h)) == NULL){
|
||||
|
|
@ -197,11 +197,11 @@ api_data_get2(clicon_handle h,
|
|||
}
|
||||
if ((attr = cvec_find_str(qvec, "with-defaults")) != NULL){
|
||||
clicon_debug(1, "%s with_defaults=%s", __FUNCTION__, attr);
|
||||
with_defaults = attr;
|
||||
defaults = attr;
|
||||
}
|
||||
|
||||
clicon_debug(1, "%s path:%s", __FUNCTION__, xpath);
|
||||
ret = clicon_rpc_get2(h, xpath, nsc, content, depth, with_defaults, &xret);
|
||||
ret = clicon_rpc_get(h, xpath, nsc, content, depth, defaults, &xret);
|
||||
|
||||
if (ret < 0){
|
||||
if (netconf_operation_failed_xml(&xerr, "protocol", clicon_err_reason) < 0)
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ snmp_scalar_get(clicon_handle h,
|
|||
clicon_ptr_get(h, "snmp-rowstatus-tree", (void**)&xcache);
|
||||
if (xcache==NULL || (x = xpath_first(xcache, nsc, "%s", xpath)) == NULL){
|
||||
/* If not found do the backend call */
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, &xt) < 0)
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
|
||||
goto done;
|
||||
/* Detect error XXX Error handling could improve */
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
|
|
@ -1160,7 +1160,7 @@ snmp_table_getnext(clicon_handle h,
|
|||
goto done;
|
||||
if (snmp_yang2xpath(ys, NULL, &xpath) < 0)
|
||||
goto done;
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, &xt) < 0)
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "clicon_rpc_get", NULL);
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ mibyang_table_poll(clicon_handle h,
|
|||
goto done;
|
||||
if (snmp_yang2xpath(ys, NULL, &xpath) < 0)
|
||||
goto done;
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, &xt) < 0)
|
||||
if (clicon_rpc_get(h, xpath, nsc, CONTENT_ALL, -1, NULL, &xt) < 0)
|
||||
goto done;
|
||||
if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||
clixon_netconf_error(xerr, "clicon_rpc_get", NULL);
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ int clicon_rpc_copy_config(clicon_handle h, char *db1, char *db2);
|
|||
int clicon_rpc_delete_config(clicon_handle h, char *db);
|
||||
int clicon_rpc_lock(clicon_handle h, char *db);
|
||||
int clicon_rpc_unlock(clicon_handle h, char *db);
|
||||
int clicon_rpc_get2(clicon_handle h, char *xpath, cvec *nsc, netconf_content content, int32_t depth, char *with_defaults, cxobj **xret);
|
||||
int clicon_rpc_get(clicon_handle h, char *xpath, cvec *nsc, netconf_content content, int32_t depth, cxobj **xret);
|
||||
int clicon_rpc_get(clicon_handle h, char *xpath, cvec *nsc, netconf_content content, int32_t depth, char *defaults, cxobj **xret);
|
||||
int clicon_rpc_get_pageable_list(clicon_handle h, char *datastore, char *xpath,
|
||||
cvec *nsc, netconf_content content, int32_t depth,
|
||||
uint32_t offset, uint32_t limit,
|
||||
|
|
|
|||
|
|
@ -824,6 +824,7 @@ clicon_rpc_unlock(clicon_handle h,
|
|||
* @param[in] nsc Namespace context for filter
|
||||
* @param[in] content Clixon extension: all, config, noconfig. -1 means all
|
||||
* @param[in] depth Nr of XML levels to get, -1 is all, 0 is none
|
||||
* @param[in] defaults Value of the with-defaults mode, rfc6243, or NULL
|
||||
* @param[out] xt XML tree. Free with xml_free.
|
||||
* Either <config> or <rpc-error>.
|
||||
* @retval 0 OK
|
||||
|
|
@ -852,26 +853,12 @@ clicon_rpc_unlock(clicon_handle h,
|
|||
* @note the netconf return message is yang populated, as well as the return data
|
||||
*/
|
||||
int
|
||||
clicon_rpc_get(clicon_handle h,
|
||||
clicon_rpc_get(clicon_handle h,
|
||||
char *xpath,
|
||||
cvec *nsc, /* namespace context for filter */
|
||||
netconf_content content,
|
||||
int32_t depth,
|
||||
cxobj **xt)
|
||||
{
|
||||
return clicon_rpc_get2(h, xpath, nsc, content, depth, NULL, xt);
|
||||
}
|
||||
|
||||
/*! Same functionality as the 'clicon_rpc_get' function, but with an additional input parameter 'with-defaults'.
|
||||
* @see clicon_rpc_get
|
||||
*/
|
||||
int
|
||||
clicon_rpc_get2(clicon_handle h,
|
||||
char *xpath,
|
||||
cvec *nsc, /* namespace context for filter */
|
||||
netconf_content content,
|
||||
int32_t depth,
|
||||
char *with_defaults,
|
||||
char *defaults,
|
||||
cxobj **xt)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -912,8 +899,8 @@ clicon_rpc_get2(clicon_handle h,
|
|||
goto done;
|
||||
cprintf(cb, "/>");
|
||||
}
|
||||
if (with_defaults != NULL)
|
||||
cprintf(cb, "<with-defaults xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\">%s</with-defaults>", with_defaults);
|
||||
if (defaults != NULL)
|
||||
cprintf(cb, "<with-defaults xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\">%s</with-defaults>", defaults);
|
||||
cprintf(cb, "</get></rpc>");
|
||||
if ((msg = clicon_msg_encode(session_id,
|
||||
"%s", cbuf_get(cb))) == NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue