* Fixed: Datastore read on startup got fixed default values.
* Fixed: Default values only worked on leafs, not typedefs.
This commit is contained in:
parent
7425a3b520
commit
28fad0303a
7 changed files with 157 additions and 16 deletions
|
|
@ -754,8 +754,6 @@ xmldb_get0_clear(clicon_handle h,
|
|||
{
|
||||
int retval = -1;
|
||||
|
||||
if (clicon_datastore_cache(h) != DATASTORE_CACHE_ZEROCOPY)
|
||||
goto ok;
|
||||
if (x == NULL)
|
||||
goto ok;
|
||||
/* clear XML tree of defaults */
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ xml_tree_prune_flagged(cxobj *xt,
|
|||
x = NULL;
|
||||
xprev = NULL;
|
||||
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL) {
|
||||
if (xml_flag(x, flag) == test?flag:0){ /* Pass test means purge */
|
||||
if (xml_flag(x, flag) == (test?flag:0)){ /* Pass test means purge */
|
||||
if (xml_purge(x) < 0)
|
||||
goto done;
|
||||
x = xprev;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
*
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
|
||||
Copyright (C) 2009-2020 Olof Hagsand
|
||||
Copyright (C) 2009-2019 Olof Hagsand
|
||||
Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC
|
||||
|
||||
This file is part of CLIXON.
|
||||
|
||||
|
|
@ -1314,6 +1315,7 @@ ys_populate_leaf(clicon_handle h,
|
|||
char *origtype=NULL; /* original type */
|
||||
uint8_t fraction_digits;
|
||||
int options = 0x0;
|
||||
yang_stmt *ytypedef; /* where type is define */
|
||||
|
||||
yparent = ys->ys_parent; /* Find parent: list/container */
|
||||
/* 1. Find type specification and set cv type accordingly */
|
||||
|
|
@ -1335,8 +1337,12 @@ ys_populate_leaf(clicon_handle h,
|
|||
clicon_err(OE_YANG, errno, "cv_new_set");
|
||||
goto done;
|
||||
}
|
||||
/* get parent of where type is defined, can be original object */
|
||||
ytypedef = yrestype?yang_parent_get(yrestype):ys;
|
||||
|
||||
/* 3. Check if default value. Here we parse the string in the default-stmt
|
||||
* and add it to the leafs cv.
|
||||
* 3a) First check local default
|
||||
*/
|
||||
if ((ydef = yang_find(ys, Y_DEFAULT, NULL)) != NULL){
|
||||
if ((cvret = cv_parse1(ydef->ys_argument, cv, &reason)) < 0){ /* error */
|
||||
|
|
@ -1349,6 +1355,19 @@ ys_populate_leaf(clicon_handle h,
|
|||
goto done;
|
||||
}
|
||||
}
|
||||
/* 2. then check typedef default */
|
||||
else if (ytypedef != ys &&
|
||||
(ydef = yang_find(ytypedef, Y_DEFAULT, NULL)) != NULL) {
|
||||
if ((cvret = cv_parse1(ydef->ys_argument, cv, &reason)) < 0){ /* error */
|
||||
clicon_err(OE_YANG, errno, "parsing cv");
|
||||
goto done;
|
||||
}
|
||||
if (cvret == 0){ /* parsing failed */
|
||||
clicon_err(OE_YANG, errno, "Parsing CV: %s", reason);
|
||||
free(reason);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else{
|
||||
/* 3b. If not default value, indicate empty cv. */
|
||||
cv_flag_set(cv, V_UNSET); /* no value (no default) */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue