Actions disappear from CLI if I use "no" on the container

I have a container in a YANG model, and in that container are some leaf nodes and also some actions.

If, from the CLI, I use "no " to clear the contents of the container, then the actions no longer appear in the CLI. They don’t show up in “?” completion, and if I try to type them anyway, they give an error. However, the leaf nodes still appear and can be set in the CLI.

How can I prevent this from happening? I want the actions to always be available. Is there any other known condition in which the actions in a YANG model will disappear from the CLI?

Thank you,
Jude

A YANG example would help people like myself to avoid spending time on your issue only to find out that I misunderstood your setup.

Conny, thank you for your response. The example is from Tail-f’s SNMP agent, and the configuration code provided in the “SNMP Tailpack”. In the YANG below, I have added the “view” and “regenerate” actions. The remainder of the container is what was originally provided by Tail-f, with the only other modifications being the removal of “tailf:hidden” from some of the leaf notes, and removal of “tailf:cli-drop-node-name” from the container. This is so that the leaf nodes are exposed and usable in the CLI.

  augment /snmp:snmp {
    container agent {

    // some other leaf nodes and containers not shown here, for brevity

      container engine-id {
        presence "sets the local engine-id";
        reference "SNMP-FRAMEWORK-MIB.snmpEngineID";
        tailf:info
          "Local SNMP engine's administratively-unique identifier";

        leaf enterprise-number {
          tailf:hidden enterprise-number;
          type uint32;
          mandatory true;
        }
        choice method {
          mandatory true;
          leaf from-ip {
            tailf:info "Construct engine-id from specified IP address";
            type inet:ip-address;
          }
          leaf from-mac-address {
            tailf:info "Construct engine-id from specified MAC address";
            type yang:mac-address;
          }
          leaf from-text {
            tailf:info "Construct engine-id from specified ASCII string";
            type string {
              length 1..27;
            }
          }
          leaf other {
            tailf:info "Construct engine-id from colon-separated hex bytes";
            type string {
              pattern "[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){0,27}";
            }
          }
        }
        tailf:action regenerate {
            description "Regenerate the agent's default engine-id";
            tailf:info "Regenerate the agent's default engine-id";
            tailf:actionpoint snmp-action;
            output {
                leaf result {
                    tailf:cli-drop-node-name;
                    type string;
                }
            }
        }
        tailf:action view {
            description "View the agent's engine-id";
            tailf:info "View the agent's engine-id";
            tailf:actionpoint snmp-action;
            output {
                leaf result {
                    tailf:cli-drop-node-name;
                    type string;
                }
            }
        }
      }
  }

What happens is that, if I am inside the snmp node in the CLI and say “no snmp agent engine-id”, it will clear the contents of that entire container as expected, but it will also remove the actions from being visible in the CLI.

Before:

localhost(config-snmp)# agent engine-id ?
Possible completions:
  from-ip            Construct engine-id from specified IP address
  from-mac-address   Construct engine-id from specified MAC address
  from-text          Construct engine-id from specified ASCII string
  other              Construct engine-id from colon-separated hex bytes
  regenerate         Regenerate the agent's default engine-id
  view               View the agent's engine-id
  <cr>               
localhost(config-snmp)#

After:

localhost(config-snmp)# agent engine-id ?
Possible completions:
  from-ip            Construct engine-id from specified IP address
  from-mac-address   Construct engine-id from specified MAC address
  from-text          Construct engine-id from specified ASCII string
  other              Construct engine-id from colon-separated hex bytes
  <cr>               
localhost(config-snmp)#

Possibly there is some bug in my callback code which is causing this, but if so, what are the conditions which can cause actions to disappear? I have not significantly modified Tail-f’s snmp-config-transform daemon which contains the existing hook callbacks for the entire SNMP container. I did add a separate daemon however, in python, which contains the action handler for the two actions (and that handler works fine). But note that I don’t even have to use the actions themselves to cause them to disappear. All I have to do is say “no snmp agent engine-id”.

As “engine-id” is a presence container you get that behaviour.
When the “engine-id” container is set, the actions show, when not set, the actions will not show.

One option is to change the “engine-id” container into a non-presence container (remove the “presence” statement) and take away mandatory statements from the “method” choice and the hidden “enterprise-number”.

Thank you very much – I will try it.
Jude