-
Couldn't load subscription status.
- Fork 315
Description
Hi,
I have a question regarding YANG data structure extensions (RFC 8791) and the use of augment-structure. Specifically, I am inquiring whether it is possible to augment to the root of a YANG data structure. For instance, with the provided YANG model, yanglint successfully validates the model if the last sx:augment-structure /foo:mystruct statement is commented out. However, if that statement is included, yanglint reports an error:
- Yang model
module foo {
namespace "foo";
prefix foo;
import ietf-yang-structure-ext { prefix sx; }
sx:structure mystruct {
container mycontainer {
leaf leaf1 {
type string;
}
}
}
sx:augment-structure /foo:mystruct/foo:mycontainer {
leaf leaf2 {
type string;
}
}
// Augment to the root of the structure, so `leaf3` will be a sibling of `mycontainer`.
sx:augment-structure /foo:mystruct {
leaf leaf3 {
type string;
}
}
}
- Yanglint error
libyang err : Augment extension target node "/foo:mystruct" from module "foo" was not found. (/foo:{extension='sx:augment-structure'}/{augment='/foo:mystruct'})
Moreover, if we cannot use augment-structure to add augments to the root of a structure, could you please suggest how to make the following leafref path valid in the Yang model below?
- a.yang
module a {
namespace "urn:a";
prefix a;
import b {
prefix b;
}
import ietf-yang-structure-ext {
prefix sx;
}
grouping leafrefs {
leaf leaf1 {
type leafref {
path "/a:top/a:leaf2";
}
}
}
grouping leaves {
leaf leaf2 {
type string;
}
}
container top {
config false;
uses leaves;
}
// Augments 'a:leaf1' into '/b:mystruct/b:mycontainer'. This augmented
// 'a:leaf1' will be a sibling of 'b:myleaf'.
//
// XPath within a structure can only reference nodes inside the same
// structure. Therefore, '/a:top/a:leaf2' must also be augmented into
// 'b:mystruct' to satisfy the leafref path.
sx:augment-structure "/b:mystruct/b:mycontainer" {
uses leafrefs;
}
// This 'augment-structure' attempts to satisfy the leafref path by augmenting
// '/a:top/a:leaf2' into the root of '/b:mystruct'. However, yanglint reports
// an error because we are augmenting to the root of a structure.
sx:augment-structure "/b:mystruct" {
container top {
uses leaves;
}
}
// This 'augment-structure' is valid in yanglint but does not satisfy the
// leafref path because it augments '/b:top/a:leaf2', not '/a:top/a:leaf2'.
sx:augment-structure "/b:mystruct/b:top" {
uses leaves;
}
}
- b.yang
module b {
namespace "urn:b";
prefix b;
import ietf-yang-structure-ext {
prefix sx;
}
sx:structure mystruct {
container mycontainer {
leaf myleaf {
type string;
}
}
container top { }
}
}
Yanglint reports the following error for the second augment-structure statement:
libyang err : Augment extension target node "/b:mystruct" from module "a" was not found. (/a:{extension='sx:augment-structure'}/{augment='/b:mystruct'})
And the following error for the third augment-structure statement:
libyang err : Not found node "top" in path. (/b:mycontainer/a:leaf1)