Fixed: [leafref in new type no work in union type](https://github.com/clicon/clixon/issues/388)
This commit is contained in:
parent
fb45085491
commit
ca23b63a4e
3 changed files with 39 additions and 11 deletions
|
|
@ -82,7 +82,8 @@ Developers may need to change their code
|
||||||
|
|
||||||
### Corrected Bugs
|
### Corrected Bugs
|
||||||
|
|
||||||
* [must statement check int value failed](https://github.com/clicon/clixon/issues/386)
|
* Fixed: [leafref in new type no work in union type](https://github.com/clicon/clixon/issues/388)
|
||||||
|
* Fixed: [must statement check int value failed](https://github.com/clicon/clixon/issues/386)
|
||||||
* Fixed: [Defaults in choice does not work properly](https://github.com/clicon/clixon/issues/390)
|
* Fixed: [Defaults in choice does not work properly](https://github.com/clicon/clixon/issues/390)
|
||||||
* Fixed: [Netconf monitoring](https://github.com/clicon/clixon/issues/370)
|
* Fixed: [Netconf monitoring](https://github.com/clicon/clixon/issues/370)
|
||||||
- Announce module capability
|
- Announce module capability
|
||||||
|
|
|
||||||
|
|
@ -1109,24 +1109,32 @@ xml_yang_validate_leaf_union(clicon_handle h,
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int ret;
|
int ret;
|
||||||
yang_stmt *yc = NULL;
|
yang_stmt *ytsub = NULL;
|
||||||
cxobj *xret1 = NULL;
|
cxobj *xret1 = NULL;
|
||||||
|
yang_stmt *ytype; /* resolved type */
|
||||||
|
char *restype;
|
||||||
|
|
||||||
/* Enough that one is valid, eg returns 1,otherwise fail */
|
/* Enough that one is valid, eg returns 1,otherwise fail */
|
||||||
while ((yc = yn_each(yrestype, yc)) != NULL){
|
while ((ytsub = yn_each(yrestype, ytsub)) != NULL){
|
||||||
if (yang_keyword_get(yc) != Y_TYPE)
|
if (yang_keyword_get(ytsub) != Y_TYPE)
|
||||||
continue;
|
continue;
|
||||||
|
/* Resolve the sub-union type to a resolved type */
|
||||||
|
if (yang_type_resolve(yt, yt, ytsub, /* in */
|
||||||
|
&ytype, NULL, /* resolved type */
|
||||||
|
NULL, NULL, NULL, NULL) < 0)
|
||||||
|
goto done;
|
||||||
|
restype = ytype?yang_argument_get(ytype):NULL;
|
||||||
ret = 1; /* If not leafref/identityref it is valid on this level */
|
ret = 1; /* If not leafref/identityref it is valid on this level */
|
||||||
if (strcmp(yang_argument_get(yc), "leafref") == 0){
|
if (strcmp(restype, "leafref") == 0){
|
||||||
if ((ret = validate_leafref(xt, yt, yc, &xret1)) < 0)
|
if ((ret = validate_leafref(xt, yt, ytype, &xret1)) < 0) // XXX
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else if (strcmp(yang_argument_get(yc), "identityref") == 0){
|
else if (strcmp(restype, "identityref") == 0){
|
||||||
if ((ret = validate_identityref(xt, yt, yc, &xret1)) < 0)
|
if ((ret = validate_identityref(xt, yt, ytype, &xret1)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
else if (strcmp("union", yang_argument_get(yc)) == 0){
|
else if (strcmp("union", yang_argument_get(ytsub)) == 0){
|
||||||
if ((ret = xml_yang_validate_leaf_union(h, xt, yt, yc, &xret1)) < 0)
|
if ((ret = xml_yang_validate_leaf_union(h, xt, yt, ytype, &xret1)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (ret == 1)
|
if (ret == 1)
|
||||||
|
|
@ -1141,7 +1149,7 @@ xml_yang_validate_leaf_union(clicon_handle h,
|
||||||
xret1 = NULL;
|
xret1 = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (yc == NULL)
|
if (ytsub == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
retval = 1;
|
retval = 1;
|
||||||
done:
|
done:
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,18 @@ module example{
|
||||||
identity saab {
|
identity saab {
|
||||||
base "airplane";
|
base "airplane";
|
||||||
}
|
}
|
||||||
|
typedef ref1 {
|
||||||
|
type leafref {
|
||||||
|
path "../x";
|
||||||
|
require-instance true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
typedef ref2 {
|
||||||
|
type leafref {
|
||||||
|
path "../y";
|
||||||
|
require-instance true;
|
||||||
|
}
|
||||||
|
}
|
||||||
container c {
|
container c {
|
||||||
leaf x {
|
leaf x {
|
||||||
type string;
|
type string;
|
||||||
|
|
@ -70,6 +82,13 @@ module example{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
leaf zdecl {
|
||||||
|
description "leafref union using declared types";
|
||||||
|
type union {
|
||||||
|
type ref1;
|
||||||
|
type ref2;
|
||||||
|
}
|
||||||
|
}
|
||||||
leaf w {
|
leaf w {
|
||||||
description "idref union";
|
description "idref union";
|
||||||
type union {
|
type union {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue