Default dependency

this is my container “feature” when i use cli i want to not show the command if feature have “supported” and “all” but i want to show the command if container feature have supported and value1.

exemple

feature supported value1
show
feature value1 (i want ==> feature supported value1)

exemple2

feature no-supported all
show
feature no-supported (i want ==> feature no supported all)

exemple3

feature supported all
show
(its empty that’s ok)

how to resole that case ??
thanks a lot

  container feature {
      leaf type {
        type enumeration {
          enum "supported" {
            value 0;
          }
          enum "not-supported" {
            value 1;
          }
          tailf:info "<type>;;Set type <supported[def]|not-supported>";
        }
        default "supported";
        tailf:cli-drop-node-name;
        tailf:cli-incomplete-command;
      }
      leaf category {
        type enumeration {
          enum "value1" {
            value 1;
          }
          enum "value2" {
            value 2;
          }
          enum "all" {
            value 3;
          }
          tailf:info "<category>;;Set post process field<value1|value2|all>";
        }
        tailf:cli-drop-node-name;
      }

      tailf:cli-compact-syntax;
      tailf:cli-sequence-commands;
    }

The “tailf:display-when” YANG annotation can be used for this. It applies to both CLI and WebUI. An example for the second half of your use case is as follows:

container feature {
  tailf:display-when "./type = 'supported' and ./category = 'value1'";
  ...

You can find out more detail about the use of the tailf:display-when statement in the tailf_yang_extensions section in vol. 5 of the ConfD man-pages.

1 Like

My container is undisplay when i used >? i don’t understand why.
I cannot enter my command.

In your example, if the display-when condition is false the container isn’t there from the point of view of the CLI. However, you can still set the values in the feature container fro other northbound interfaces.

If you look at the examples in the User Guide the display-when condition refers to objects that is outside of the hidden objects:

  typedef interface-type {
     type enumeration {
        enum ethernet;
        enum atm;
        enum appletalk;
     }
  }

  leaf if-type {
     type interface-type;
  }
  container ethernet {
     tailf:display-when "../if-type = 'ethernet'";
     ...
  }
  container atm {
     tailf:display-when "../if-type = 'atm'";
     ...
  }
  container appletalk {
     tailf:display-when "../if-type = 'appletalk'";
     ...
  }

I’m not aware of a way to have display-when “refer to itself” the way you are trying to do but if your display-when condition refer to an object outside of the “feature” container things should work.

Your container will need to be initialized to correspond to the XPath expression as specified by the display-when statement in order for it to be displayed in CLI.

One way to do this is to create a initialization file in xml format that gets loaded upon the startup of confd such as follows:

<config xmlns="http://tail-f.com/ns/config/1.0">
  <feature xmlns="http://www.tail-f.com/examples/feature">
    <type>supported</type>
    <category>value1</category>
  </feature>
</config>

The above assumes the following definition at the top of your YANG module:

module feature {
    namespace "http://www.tail-f.com/examples/feature";

For testing purpose, you can save the above XML configuration block into a file named for example fe_init.xml and use the load command (load merge fe_init.xml) in the CLI’s config mode to properly initialize your container. After that, you will be be able to see the feature container getting displayed when you perform a question mark prompt in the config mode.

As was pointed out by Jonas in his response, you can also configure the container in other northbound interfaces that aren’t affected by the display-when statement such as NETCONF.