This commit is contained in:
Olof hagsand 2016-05-20 18:34:20 +02:00
commit f6a6def778
2 changed files with 28 additions and 8 deletions

View file

@ -163,24 +163,35 @@ cvtype_max2str_dup(enum cv_type type)
* @param[in] ys yang_stmt of the node at hand * @param[in] ys yang_stmt of the node at hand
* @param[in] cvtype Type of the cligen variable * @param[in] cvtype Type of the cligen variable
* @param[in] cb0 The string where the result format string is inserted. * @param[in] cb0 The string where the result format string is inserted.
* @param[in] options
* @param[in] fraction_digits
* @see expand_dbvar This is where the expand string is used * @see expand_dbvar This is where the expand string is used
* @note XXX only fraction_digits handled,should also have mincv, maxcv, pattern
*/ */
static int static int
cli_expand_var_generate(clicon_handle h, cli_expand_var_generate(clicon_handle h,
yang_stmt *ys, yang_stmt *ys,
enum cv_type cvtype, enum cv_type cvtype,
cbuf *cb0) cbuf *cb0,
int options,
uint8_t fraction_digits
)
{ {
int retval = -1; int retval = -1;
char *xkfmt = NULL; char *xkfmt = NULL;
if (yang2xmlkeyfmt(ys, &xkfmt) < 0) if (yang2xmlkeyfmt(ys, &xkfmt) < 0)
goto done; goto done;
cprintf(cb0, "|<%s:%s %s(\"candidate %s\")>", cprintf(cb0, "|<%s:%s", ys->ys_argument,
ys->ys_argument, cv_type2str(cvtype));
cv_type2str(cvtype), if (options & YANG_OPTIONS_FRACTION_DIGITS)
cprintf(cb0, " fraction-digits:%u", fraction_digits);
cprintf(cb0, " %s(\"candidate %s\")>",
GENERATE_EXPAND_XMLDB, GENERATE_EXPAND_XMLDB,
xkfmt); xkfmt);
retval = 0; retval = 0;
done: done:
if (xkfmt) if (xkfmt)
@ -327,7 +338,8 @@ yang2cli_var_sub(clicon_handle h,
if (helptext) if (helptext)
cprintf(cb0, "(\"%s\")", helptext); cprintf(cb0, "(\"%s\")", helptext);
if (completion){ if (completion){
if (cli_expand_var_generate(h, ys, cvtype, cb0) < 0) if (cli_expand_var_generate(h, ys, cvtype, cb0,
options, fraction_digits) < 0)
goto done; goto done;
if (helptext) if (helptext)
cprintf(cb0, "(\"%s\")", helptext); cprintf(cb0, "(\"%s\")", helptext);

View file

@ -86,8 +86,8 @@
<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]> <rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>
* filter subnet + no config: * filter subnet + no config:
<rpc><get-config><source><candidate/></source><filter/></get-config></rpc>]]>]]> <rpc><get-config><source><candidate/></source><filter/></get-config></rpc>]]>]]>
* filter xpath + no select: * filter xpath + select all:
<rpc><get-config><source><candidate/></source><filter type="xpath"/></get-config></rpc>]]>]]> <rpc><get-config><source><candidate/></source><filter type="xpath" select="/"/></get-config></rpc>]]>]]>
* filter subnet + config: * filter subnet + config:
<rpc><get-config><source><candidate/></source><filter type="subtree"><configuration><interfaces><interface><ipv4/></interface></interfaces></configuration></filter></get-config></rpc>]]>]]> <rpc><get-config><source><candidate/></source><filter type="subtree"><configuration><interfaces><interface><ipv4/></interface></interfaces></configuration></filter></get-config></rpc>]]>]]>
* filter xpath + select: * filter xpath + select:
@ -152,7 +152,15 @@ netconf_filter_xmldb(clicon_handle h,
clicon_xml2cbuf(cb, xc, 0, 1); clicon_xml2cbuf(cb, xc, 0, 1);
break; break;
case FILTER_XPATH: case FILTER_XPATH:
selector = xml_find_value(xfilter, "select"); if ((selector = xml_find_value(xfilter, "select")) == NULL){
netconf_create_rpc_error(cb_err, xorig,
"missing-attribute",
"protocol",
"error",
NULL,
"<bad-attribute>select</bad-attribute>");
goto done;
}
if (xmldb_get(h, source, selector, 0, &xdb, NULL, NULL) < 0){ if (xmldb_get(h, source, selector, 0, &xdb, NULL, NULL) < 0){
netconf_create_rpc_error(cb_err, xorig, netconf_create_rpc_error(cb_err, xorig,
"operation-failed", "operation-failed",