05-29-2019 06:07 AM
Hi Guys
I noticed different behavior of xpath on leaf and on when statement. In particular, i've created a yang file with one leaf that identify a switch model trough xpath and one choice statement with "when condition" about model
When I using xpath on when condition statement, it's possibile to use xpath reference about
"show devices device <<NAME DEVICE>> platform model;
When i using xpath on leaf with learef, it's must use
"show runnning devices device <<NAME device>> config ios.."
If I using a show device device xpath on leafref, when i lanch a make command i've a following error
yang/GigaBiz.yang:80: error: the node is config, but refers to a non-config leaf 'model' defined at /home/nso/NSO-4.3.6/src/ncs/yang/tailf-ncs-devices.yang:2865
My code is showing in following tab
leaf device_type { tailf:info "leaf per identificare la tipologia di NT "; type leafref { /* path "/ncs:devices/ncs:device[ncs:name=current()/../NT]/ncs:config/ios:hostname";*/ path "/ncs:devices/ncs:device[ncs:name=current()/../NT]/ncs:platform/ncs:model"; } } ... cut ... choice interface_nt_tir { case gig { when "/ncs:devices/ncs:device[ncs:name=current()/NT]/ncs:platform/ncs:model = 'ME-3400G-12CS-A'"; leaf if_gig_nt_tir { mandatory true; type leafref { path "/ncs:devices/ncs:device[ncs:name=current()/../NT]/ncs:config/ios:interface/ios:GigabitEthernet/ios:name"; } } }
I searched a different show to associate a value on leaf, but show running devices device NAME config ios:cached-show is deprecated and it's not function.
Did anyone have the same problem?
thanks a lot
Maurizio
06-14-2019 09:33 AM
The device platform model leaf is operational data so you can't use it in a leafref config node. This is a YANG limitation. From section 9.9 of the RFC:
If the leaf with the leafref type represents configuration data, the leaf it refers to MUST also represent configuration.
You could use an enumation instead.
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