I am looking to allow configuration of A-dep leaf only when sec-id exists in the list AL’s only possible configurable element. The must statement in A-dep leaf doesn’t look to be executing correctly even when I configure a sec-id=5 in the list AL. Are there any syntactical corrections required?
container A {
list AL {
tailf:cli-drop-node-name;
max-elements 1;
key "prim-id";
leaf prim-id {
type int;
}
leaf sec-id {
type int;
}
}
}
leaf A-dep {
must "A/AL/sec-id" {
error-message "Sec-id must exist for A-dep config";
}
type int;
}
xubuntu-dev# config
Entering configuration mode terminal
xubuntu-dev(config)# A-dep 33
xubuntu-dev(config)# commit
Aborted: 'A-dep' (value "33"): Sec-id must exist for A-dep config
xubuntu-dev(config)#
xubuntu-dev(config)# A 11 sec-id 22
xubuntu-dev(config-A-11)# commit
Commit complete.
xubuntu-dev(config-A-11)# top
xubuntu-dev(config)# show full-configuration A
A 11
sec-id 22
!
xubuntu-dev(config)# show full-configuration A-dep
A-dep 33
Not sure what is your explicit need - if you want the A-dep node not to be configurable at all in the pending transaction when no sec-id is set, maybe the “when” statement will better fit your scenario instead of “must”?
edit: assuming you fix the errors in the YANG excerpt you provide that prevents to successfully compile it… int as unknown type, and wrong must statement path - missing leading /