05-13-2021 03:18 AM
Hello,
Can someone please point me to how to write must statement in the Yang model to test if a device belongs to a given device group ?
Solved! Go to Solution.
05-13-2021 10:40 PM - edited 05-13-2021 10:41 PM
I made a quick example that I am going to attach, but basically the must expression can look like this (this also answers your previous question about two device groups):
leaf-list device { type leafref { path "/ncs:devices/ncs:device/ncs:name"; } must "/ncs:devices/ncs:device-group[ncs:name='g1']/ncs:device-name[. = current()]" + "or /ncs:devices/ncs:device-group[ncs:name='g2']/ncs:device-name[. = current()]"; }
I have devices r0 to r3, but I get this interaction in the CLI, which is better than I was expecting (note that I do not get r2 in the tab expansion):
admin@ncs(config)# show full-configuration devices device-group devices device-group g1 device-name [ r0 r1 ] ! devices device-group g2 device-name [ r1 r3 ] ! admin@ncs(config)# multiref m1 device Possible completions: [ r0 r1 r3
05-13-2021 10:40 PM - edited 05-13-2021 10:41 PM
I made a quick example that I am going to attach, but basically the must expression can look like this (this also answers your previous question about two device groups):
leaf-list device { type leafref { path "/ncs:devices/ncs:device/ncs:name"; } must "/ncs:devices/ncs:device-group[ncs:name='g1']/ncs:device-name[. = current()]" + "or /ncs:devices/ncs:device-group[ncs:name='g2']/ncs:device-name[. = current()]"; }
I have devices r0 to r3, but I get this interaction in the CLI, which is better than I was expecting (note that I do not get r2 in the tab expansion):
admin@ncs(config)# show full-configuration devices device-group devices device-group g1 device-name [ r0 r1 ] ! devices device-group g2 device-name [ r1 r3 ] ! admin@ncs(config)# multiref m1 device Possible completions: [ r0 r1 r3
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