container cont1
leaf lef1
range 1..10
default 5
leaf lef2
range 11..20
default 15
leaf lef3
range 21..30
default 25
leaf lef4
range 31..40
default 35
leaf lef5
range 41..50
default 45
requirement is, if I configure “cont1 lef1” or any other leaf “cont1 lef2” or “cont1 lef3” or “cont1 lef4” or “cont1 lef5”
output I am expecting as:
cont1 lef1 5 lef2 15 lef3 25 lef4 35 lef5 45
if I configure any one leaf then cont1 should be configured with all leaves with their default value.
not sure it i understand correctly the requirement, but, it looks like “presence container” (see YANG rfc) might be the thing you need?
container cont1
presence "all my children will exist";
leaf lef1 {
default 5
}
leaf lef2 {
default 5
}
...
}
presence container can be created/deleted by itself (in contrast to regular container), thus making all it’s descendants created with defaults, or deleted, as appropriate…
will only have inside leaves defined by default whne you explicitly create/set container, or one of it’s descendants (which creates parent presence container as well)
Adding “tailf:cli-show-with-default” in each leaf has made me achieve my expectation.
container cont1 {
tailf:cli-compact-syntax;
presence "all my children will exist";
leaf lef1 {
**tailf:cli-show-with-default;**
type uint8 {
range "1..10";
}
default 5;
}
leaf lef2 {
**tailf:cli-show-with-default;**
type uint8 {
range "10..25";
}
default 15;
}
}
Above changes are working as expected:
Results on Confd_cli:
network(config-dial-peer)# show full-con
dial-peer voice 10 voip
!
network(config-dial-peer)# **cont1 lef1 3**
network(config-dial-peer)# commit
Commit complete.
network(config-dial-peer)# show full-con
dial-peer voice 10 voip
**cont1 lef1 3 lef2 15**
!
network(config-dial-peer)# no cont1
network(config-dial-peer)# commit
Commit complete.
network(config-dial-peer)# show full-con
dial-peer voice 10 voip
!
network(config-dial-peer)#