I have two properties in a model:
I want to specify that:
There are no conditional default
values in YANG - you need two default
statements for two defaults
with different values, and a single leaf
may only have one default
substatement. You can work around this, however. Perhaps by using a presence container
instead of your protocol leaf
:
module conditional-default {
namespace "http://example.com/conditional-default";
prefix "excd";
grouping common {
leaf port {
type int32;
}
}
container config {
container ssh {
presence "If this container is present, ssh is configured.";
uses common {
refine port {
default 22;
}
}
}
container http {
presence "If this container is present, http is configured.";
uses common {
refine port {
default 80;
}
}
}
}
}
From RFC6020, 7.5.5.:
The "presence" statement assigns a meaning to the presence of a container in the data tree. It takes as an argument a string that contains a textual description of what the node's presence means.