Is there possibility in YANG language to select one option in bit type leaf, which will deselect all other bits ? What I would like to do is, by default Whole-Platform is selected, but when user selects some other option, the Whole-Platform will be deselected. And otherwise when user selects Whole-Platform, all other options should be deselected.
leaf check-type {
type bits {
bit Whole-platform;
bit NSO-checks;
bit ESC-checks;
}
default "Whole-platform";
}
No, YANG bits type will not let you do that, since no relation between individual bits ever exists by default - other than the notion of all of them belonging to the same set of "configurable flags".
This is where a union type would be a viable modeling decision.
leaf check-type {
type union {
type enumeration {
enum Whole-platform;
}
type bits {
bit NSO-checks;
bit ESC-checks;
}
}
default Whole-platform;
}
Doing this implies an XOR (mutual exclusivity) between value Whole-platform
and the set of remaining bit values to the reader.
Valid values:
<check-type>Whole-platform</check-type>
<check-type>NSO-checks</check-type>
<check-type>NSO-checks ESC-checks</check-type>
Invalid:
<check-type>Whole-platform ESC-checks</check-type>
You could leave your type as is and handle the one bit to rule them all in a description, since that is just human readable normative text.
description "Implementations must ensure an XOR relationship between
'Whole-platform' bit value and the other bit values of this
leaf. When the former is used it means that
...";
Note: what you are trying to achieve is an implementation detail.