I have one leaf which is dependent on other leaf node(of different grouping) and i want to set its value only if it is configured in dependent leaf node.
ex.
container A{
leaf x{
type uint;
}
}
container B{
leaf Y{
type leafref{
path "../../A/x"
}
when ,
if x is configured then only allow to set y else y should not set
case 1:
# A 10
# B 10 -> should work
case 2:
#B 10 -> should not work as x do not contain this value
No I wanted whatever value i give to Y it should be acceptable only when X has that value . , This dependency can be achieved via leafref .
Thanks for the support.
One quick question, is there any error message i can put in leafref if not statisfied . Currently it is showing me “syntax error: unknown argument”. I want to change this message
@josephm’s solution sounds like it would meet your requirements, but if it doesn’t, @chiya, are you looking for something like this?
container A{
leaf x{
type uint;
}
}
container B{
leaf Y{
type uint;
when "/A/x";
tailf:default-ref "/A/x"
}
}
This will work the same way as @josephm’s suggestion: Y won’t exist in the data model till /A/x is set. As soon as /A/x is set, however, /B/Y will come to be and have whatever value the user set for /A/x.