07-10-2019 09:34 AM
Hello,
want to use device-groups to ease the selection of devices.
For testing I start with a static group name "PE-group".
I start trying with YANG-path below and always got this error message:
error: bad argument value "/ncs:devices/ncs:device-group[ncs:name = 'PE-group']/ncs:device-name", should be of type path-arg
leaf device_PE {
tailf:info "PE Router";
type leafref {
path "/ncs:devices/ncs:device-group[ncs:name = 'PE-group']/ncs:device-name";
}
mandatory 'true';
}
Doublecheck if anything is wrong with the path in general by replacing the constant value with a current() reference:
leaf device_PE {
tailf:info "PE Router";
type leafref {
//path "/ncs:devices/ncs:device-group[ncs:name = current()/../group_name]/ncs:device-name";
}
mandatory 'true';
}
leaf group_name {
type string;
default 'PE-group';
}With this yang file anything works as expected.
Any idea want's wrong with the expression with the constant value?
Regards
Lothar
Solved! Go to Solution.
07-10-2019 10:14 AM
The YANG standard RFC6020 restricts an xpath to a path-arg, defined as:
path-arg-str = < a string that matches the rule
path-arg >
path-arg = absolute-path / relative-path
absolute-path = 1*("/" (node-identifier *path-predicate))
relative-path = 1*(".." "/") descendant-path
descendant-path = node-identifier
[*path-predicate absolute-path]
path-predicate = "[" *WSP path-equality-expr *WSP "]"
path-equality-expr = node-identifier *WSP "=" *WSP path-key-expr
path-key-expr = current-function-invocation *WSP "/" *WSP
rel-path-keyexpr
rel-path-keyexpr = 1*(".." *WSP "/" *WSP)
*(node-identifier *WSP "/" *WSP)
node-identifier
Which is a little bit of a mouthful, but the key here is that path-key-expr can only be current() plus a path, or a pure relative path. Which unfortunately means that it cannot be a string.
07-10-2019 10:14 AM
The YANG standard RFC6020 restricts an xpath to a path-arg, defined as:
path-arg-str = < a string that matches the rule
path-arg >
path-arg = absolute-path / relative-path
absolute-path = 1*("/" (node-identifier *path-predicate))
relative-path = 1*(".." "/") descendant-path
descendant-path = node-identifier
[*path-predicate absolute-path]
path-predicate = "[" *WSP path-equality-expr *WSP "]"
path-equality-expr = node-identifier *WSP "=" *WSP path-key-expr
path-key-expr = current-function-invocation *WSP "/" *WSP
rel-path-keyexpr
rel-path-keyexpr = 1*(".." *WSP "/" *WSP)
*(node-identifier *WSP "/" *WSP)
node-identifier
Which is a little bit of a mouthful, but the key here is that path-key-expr can only be current() plus a path, or a pure relative path. Which unfortunately means that it cannot be a string.
07-10-2019 11:27 PM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide