Improved performance of mountpoint show config
This commit is contained in:
parent
35ad68fa70
commit
1a43a32770
3 changed files with 75 additions and 10 deletions
|
|
@ -54,6 +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_delete_config(clicon_handle h, char *db);
|
||||||
int clicon_rpc_lock(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_unlock(clicon_handle h, char *db);
|
||||||
|
int clicon_rpc_get2(clicon_handle h, char *xpath, cvec *nsc, netconf_content content, int32_t depth, char *defaults, int bind, 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(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,
|
int clicon_rpc_get_pageable_list(clicon_handle h, char *datastore, char *xpath,
|
||||||
cvec *nsc, netconf_content content, int32_t depth, char *defaults,
|
cvec *nsc, netconf_content content, int32_t depth, char *defaults,
|
||||||
|
|
|
||||||
|
|
@ -957,6 +957,55 @@ clicon_rpc_get(clicon_handle h,
|
||||||
int32_t depth,
|
int32_t depth,
|
||||||
char *defaults,
|
char *defaults,
|
||||||
cxobj **xt)
|
cxobj **xt)
|
||||||
|
{
|
||||||
|
return clicon_rpc_get2(h, xpath, nsc, content, depth, defaults, 1, xt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! Get database configuration and state data (please use instead of clicon_rpc_get)
|
||||||
|
*
|
||||||
|
* @param[in] h Clicon handle
|
||||||
|
* @param[in] xpath XPath in a filter stmt (or NULL/"" for no filter)
|
||||||
|
* @param[in] namespace Namespace associated w xpath
|
||||||
|
* @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
|
||||||
|
* @retval -1 Error, fatal or xml
|
||||||
|
* @note if xpath is set but namespace is NULL, the default, netconf base
|
||||||
|
* namespace will be used which is most probably wrong.
|
||||||
|
* @code
|
||||||
|
* cxobj *xt = NULL;
|
||||||
|
* cvec *nsc = NULL;
|
||||||
|
*
|
||||||
|
* if ((nsc = xml_nsctx_init(NULL, "urn:example:hello")) == NULL)
|
||||||
|
* err;
|
||||||
|
* if (clicon_rpc_get(h, "/hello/world", nsc, CONTENT_ALL, -1, &xt) < 0)
|
||||||
|
* err;
|
||||||
|
* if ((xerr = xpath_first(xt, NULL, "/rpc-error")) != NULL){
|
||||||
|
* clixon_netconf_error(xerr, "clicon_rpc_get", NULL);
|
||||||
|
* err;
|
||||||
|
* }
|
||||||
|
* if (xt)
|
||||||
|
* xml_free(xt);
|
||||||
|
* if (nsc)
|
||||||
|
* xml_nsctx_free(nsc);
|
||||||
|
* @endcode
|
||||||
|
* @see clicon_rpc_get_config which is almost the same as with content=config, but you can also select dbname
|
||||||
|
* @see clixon_netconf_error
|
||||||
|
* @note the netconf return message is yang populated, as well as the return data
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
clicon_rpc_get2(clicon_handle h,
|
||||||
|
char *xpath,
|
||||||
|
cvec *nsc, /* namespace context for filter */
|
||||||
|
netconf_content content,
|
||||||
|
int32_t depth,
|
||||||
|
char *defaults,
|
||||||
|
int bind,
|
||||||
|
cxobj **xt)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
struct clicon_msg *msg = NULL;
|
struct clicon_msg *msg = NULL;
|
||||||
|
|
@ -1030,15 +1079,17 @@ clicon_rpc_get(clicon_handle h,
|
||||||
else{
|
else{
|
||||||
if (xml_bind_special(xd, yspec, "/nc:get/output/data") < 0)
|
if (xml_bind_special(xd, yspec, "/nc:get/output/data") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if ((ret = xml_bind_yang(h, xd, YB_MODULE, yspec, &xerr)) < 0)
|
if (bind){
|
||||||
goto done;
|
if ((ret = xml_bind_yang(h, xd, YB_MODULE, yspec, &xerr)) < 0)
|
||||||
if (ret == 0){
|
|
||||||
if (clixon_netconf_internal_error(xerr,
|
|
||||||
". Internal error, backend returned invalid XML.",
|
|
||||||
NULL) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
xd = xerr;
|
if (ret == 0){
|
||||||
xerr = NULL;
|
if (clixon_netconf_internal_error(xerr,
|
||||||
|
". Internal error, backend returned invalid XML.",
|
||||||
|
NULL) < 0)
|
||||||
|
goto done;
|
||||||
|
xd = xerr;
|
||||||
|
xerr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (xt && xd){
|
if (xt && xd){
|
||||||
|
|
@ -1791,6 +1842,8 @@ clicon_hello_req(clicon_handle h,
|
||||||
int ret;
|
int ret;
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
int clixon_lib = 0;
|
int clixon_lib = 0;
|
||||||
|
char *ns = NULL;
|
||||||
|
char *prefix = NULL;
|
||||||
|
|
||||||
if ((cb = cbuf_new()) == NULL){
|
if ((cb = cbuf_new()) == NULL){
|
||||||
clicon_err(OE_XML, errno, "cbuf_new");
|
clicon_err(OE_XML, errno, "cbuf_new");
|
||||||
|
|
@ -1802,6 +1855,8 @@ clicon_hello_req(clicon_handle h,
|
||||||
clixon_lib++;
|
clixon_lib++;
|
||||||
}
|
}
|
||||||
/* RFC 6022 session parameters transport and source-host */
|
/* RFC 6022 session parameters transport and source-host */
|
||||||
|
clicon_data_get(h, "session-namespace", &ns);
|
||||||
|
clicon_data_get(h, "session-namespace-prefix", &prefix);
|
||||||
if (transport == NULL)
|
if (transport == NULL)
|
||||||
clicon_data_get(h, "session-transport", &transport);
|
clicon_data_get(h, "session-transport", &transport);
|
||||||
if (transport){
|
if (transport){
|
||||||
|
|
|
||||||
|
|
@ -1225,8 +1225,17 @@ xml2xpath1(cxobj *x,
|
||||||
|
|
||||||
if ((xp = xml_parent(x)) == NULL)
|
if ((xp = xml_parent(x)) == NULL)
|
||||||
goto ok;
|
goto ok;
|
||||||
if (spec && xml_spec(x) == NULL)
|
y = xml_spec(x);
|
||||||
|
|
||||||
|
if (spec && y == NULL)
|
||||||
goto ok;
|
goto ok;
|
||||||
|
/* Strip top-level netconf anydata, eg from get-config protocol processing */
|
||||||
|
if (y != NULL){
|
||||||
|
if (yang_keyword_get(y) == Y_ANYXML)
|
||||||
|
goto ok;
|
||||||
|
if (yang_keyword_get(y) == Y_ANYDATA)
|
||||||
|
goto ok;
|
||||||
|
}
|
||||||
if (xml2xpath1(xp, nsc, spec, apostrophe, cb) < 0)
|
if (xml2xpath1(xp, nsc, spec, apostrophe, cb) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (nsc){
|
if (nsc){
|
||||||
|
|
@ -1246,7 +1255,7 @@ xml2xpath1(cxobj *x,
|
||||||
if (prefix)
|
if (prefix)
|
||||||
cprintf(cb, "%s:", prefix);
|
cprintf(cb, "%s:", prefix);
|
||||||
cprintf(cb, "%s", xml_name(x));
|
cprintf(cb, "%s", xml_name(x));
|
||||||
if ((y = xml_spec(x)) != NULL){
|
if (y != NULL){
|
||||||
keyword = yang_keyword_get(y);
|
keyword = yang_keyword_get(y);
|
||||||
switch (keyword){
|
switch (keyword){
|
||||||
case Y_LEAF_LIST:
|
case Y_LEAF_LIST:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue