11-30-2019 03:31 PM
I have a yang model that needs to reference "servers/nodes" on two types of devices (F5 and A10).
For F5:
root@ncs(config)# devices device slb01sqsccc config bigip:ltm node ?
This line doesn't have a valid range expression
Possible completions:
name test-server-1 test-server-2
For A10:
root@ncs(config)# devices device slb45sqsccc config a10-acos:slb server ?
This line doesn't have a valid range expression
Possible completions:
<NAME<length:1-63>> - Server Name
a10-test -
test-server-1 -
test-server-2 -
How do I model the path to either the F5 or A10 NED based on the device being configured?
Solved! Go to Solution.
12-02-2019 04:23 AM
Yes, unions can contain leafrefs, as per the RFC, but as of now, in NSO, it is not fully supported.
The man page for "ncsc" (the compiler) says
Type leafref in unions are not validated, and treated as a string internally.
So, yes, you can have leafrefs in unions in your model, and NSO can compile and load them. But they won't work as you expect of a normal leafref.
/Ram
11-30-2019 04:18 PM
11-30-2019 05:05 PM
11-30-2019 10:46 PM
I think you won't be able to use leafref directly here.
As far as I recall, the YANG RFC doesn't allow type leafref inside a union.
11-30-2019 11:12 PM
12-01-2019 12:14 AM
12-01-2019 12:13 AM
I believe that used to be true, but with YANG 1.1 it's allowed.
12-01-2019 12:30 AM
"I believe that used to be true, but with YANG 1.1 it's allowed."
Interesting!
Indeed, looking into RFC 6020 we have:
A member type can be of any built-in or derived type, except it MUST NOT be one of the built-in types "empty" or "leafref"
but looking into RFC 7950, we have:
A member type can be of any built-in or derived type.
Which version of NSO started using YANG 1.1?
12-01-2019 09:00 AM
Regarding YANG 1.1 it seems to be from NSO-4.2 [May 26, 2016], but I can also see that some fixes and improvements have been made in the releases just after that.
Regarding the issue at hand, the reason why unions between leafrefs are a little bit iffy is because it is not in general obvious which of the leafrefs a value comes from, both lists may have the same keys. But in this case you probably have some other part of the model that can be used to resolve that ambiguity. Take a look at what you are trying to do and ask a followup question if it seems hard!
12-02-2019 04:23 AM
Yes, unions can contain leafrefs, as per the RFC, but as of now, in NSO, it is not fully supported.
The man page for "ncsc" (the compiler) says
Type leafref in unions are not validated, and treated as a string internally.
So, yes, you can have leafrefs in unions in your model, and NSO can compile and load them. But they won't work as you expect of a normal leafref.
/Ram
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