Adding conditional parts of models using 'when' statements

When you are designing your YANG models, some of the configuration may only be applicable if some condition is true. For example, as part of your interface configuration, some leaf nodes may only make sense if the interface is of a certain type. Or certain areas of configuration may only apply if the customer has licensed a particular feature, otherwise the configuration should not be possible.

For these types of situations, YANG has the ‘when’ statement. This allows you to place conditions on whether a particular node is valid by using an XPath expression.

Tail-f has extended this conditional notion by controlling when a particular node is valid, by controlling instead when the node is visible through the Web API or CLI. This conditional is the tail-f:display-when statement. Use of this statement will keep the node as a valid node in the model, and only control the visibility. If the tail-f:display-when statement is false, the node is not visible, but when it is true, the node is visible.

1 Like

Hi Greg,

Thanks for your input!
It helped me:)