Added validation for leafref forward and nackward references.

This commit is contained in:
Olof hagsand 2017-07-18 19:56:54 +02:00
parent 96f341d8fc
commit 1b6c9aacbe
11 changed files with 295 additions and 49 deletions

View file

@ -275,9 +275,10 @@ yang2cli_var_sub(clicon_handle h,
if (helptext)
cprintf(cb0, "(\"%s\")", helptext);
if (completion){
#if 0
if (type && (strcmp(type, "leafref") == 0)){
yang_stmt *ypath;
/* XXX only for absolute xpath */
if ((ypath = yang_find((yang_node*)ytype, Y_PATH, NULL)) == NULL){
clicon_err(OE_XML, 0, "leafref should have path sub");
goto done;
@ -290,6 +291,7 @@ yang2cli_var_sub(clicon_handle h,
ypath->ys_argument);
}
else
#endif
if (cli_expand_var_generate(h, ys, cvtype, cb0,
options, fraction_digits) < 0)
goto done;

View file

@ -141,12 +141,29 @@ expand_dbvar(void *h,
if (api_path_fmt2xpath(api_path, cvv, &xpath) < 0)
goto done;
/* XXX read whole configuration, why not send xpath? */
if (clicon_rpc_get_config(h, dbstr, "/", &xt) < 0)
if (clicon_rpc_get_config(h, dbstr, xpath, &xt) < 0)
goto done;
if ((xerr = xpath_first(xt, "/rpc-error")) != NULL){
clicon_rpc_generate_error(xerr);
goto done;
}
#if 0
/* Get xpath from datastore?
* 1. Get whole datastore,
* 2. Add tentative my location to xpath,
* 3. If leafref, compute relative xpath
*/
{
cxobj *xcur = NULL; /* xpath, NULL if datastore */
// yang_node *y = NULL; /* yang spec of xpath */
if ((xcur = xpath_first(xt, xpath)) == NULL)
goto done;
}
#endif
/* One round to detect duplicates
* XXX The code below would benefit from some cleanup
*/