ConfD User Community

How to hide a container when default value is set?


#1

How to hide a container when default value is set ?

        container test {
          presence "";
          leaf value {
            type uint16 {
              range "0..63";
            }
            default "1";
            tailf:cli-drop-node-name;
          }
        }

when i set my container with default value, show run print my on my CLI my container without value.
I want to hide my container when the default value is set.
Actualy i print that with show run; I’m looking to have show run empty when default value is set.
conf>test 1
show run>“test”

conf> test 2
show run>“test 2”


#2

See tailf:cli-trim-default in the tailf_yang_cli_extensions man page


#3

my container remains visible without the default with tailf:cli-trim-default


#4

If I understand the model correctly - you have two separate elements - presence container “test” can be created/delete by itself, independently on presence/default-ness of internal leaf “value”…

I assume that cli-trim-default applied to leaf “value” does what you want with “value”, but does not affect "test’ - which is expected.

Do you really need the container to be “present”?

I assume if will follow your desired behavior when it’s just a regular container, with cli-trim-default annotation applied to “value” leaf.