cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
682
Views
7
Helpful
4
Replies

Leafref query

suvdeshm
Cisco Employee
Cisco Employee

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

type leafref {
"/ncs:devices/ncs:device/ncs:config/ios:interface/ios:LoopBack/ios:ip/ios:address/ios:primary/ios: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 ?

4 Replies 4

Marcel Zehnder
Spotlight
Spotlight

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";
 }
}

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

Can you confirm, the xPath is valid or maybe share your yang module(s)?

Michael Maddern
Cisco Employee
Cisco Employee

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.