02-26-2023 03:45 PM
Hello experts,
I have to use configured inventory to lookup the Loopback IP address so I am using a leafref with a must condition.
This compiles but doesnot filter just for the primary-connection-device instead it shows me all devices' loopbacks.
leaf neighbor_address
must "/ncs:devices/ncs:device[ncs:name=(/inventory:inventory/site:abc/site:abc-sites[site:abc-pe-name=current()/../../../site]/site:primary-connection-device)]/ncs:config/ios:interface/ios:LoopBack/ios:ip/ios:address/ios:primary/ios:address";
Is it possible to do a deref inside a deref? Is there any other way ?
02-26-2023 11:27 PM - edited 02-27-2023 06:41 AM
Hi
I think the must statement will alway be true. Can you try to implement the xpath expression directly in your leafref path? Something like this:
leaf neighbor_address {
type leafref {
path "/ncs:devices/ncs:device[ncs:name=(/inventory:inventory/site:abc/site:abc-sites[site:abc-pe-name=current()/../../../site]/site:primary-connection-device)]/ncs:config/ios:interface/ios:LoopBack/ios:ip/ios:address/ios:primary/ios:address";
}
}
02-27-2023 09:05 AM
I had already tried this and this is the error I get on compilation:
yang/dren-cfs-l3vpn.yang:140: error: bad argument value "/ncs:devices/ncs:device[ncs:name=(/
inventory:inventory/site:abc/site:abc-sites[site:abc-pe-name=current()/../../../site]/site:primary-connection-device
)]/ncs:config/ios:interface/ios:Loopback/ios:ip/ios:address/ios:primary/ios:address", should be of type path-arg
make: *** [../load-dir/dren-cfs-l3vpn.fxs] Error 1
02-27-2023 10:14 PM - edited 02-27-2023 10:16 PM
Can you confirm, the xPath is valid or maybe share your yang module(s)?
03-03-2023 08:34 AM
According to the YANG spec, a predicate cannot contain another predicate. You might be able to do something like:
must "deref(.)/../../../../../../../ncs:name = /inventory:inventory/site:abc/site:abc-sites[site:abc-pe-name=current()/../../../site]/site:primary-connection-device"
But if it works it won't be very efficient.
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