I am writing a Yang model. Is there away to set a leaf (string or enumeration) with a value based on another field. So for example, I want to say if x then field a value is b, if z then field a value is c.
Edit: I am new to yang and still trying to learn it, if there are any other ideas or operators I can use to solve this issue please do not hesitate to share. :D Thank you very much.
You can use
when
andmust
constructs: YANG 1.1, Section 7.5.3 says:And Section 7.5.4.3 lays it out:
On
when
, Section 7.21.5 reads,ConfD provides a tutorial on XPath in NETCONF and YANG; this examples comes out of it: