ConfD User Community

How to show more options in cli autocompletion for next container

Please see the sample code below, I have used cli-flatten-contianer to allow the cli continue with next container.
I worked file as I enter command “servers server 1 server 4”.
However if I did “servers server 1 ?”, only carriage return is shown.
How come can I get the next option “server” shown".
cat generic-yang.yang

module generic-yang {

namespace “https://tail-f.com/ns/example/generic-yang”;
prefix “generic”;

import tailf-common {
prefix tailf;
}
import ietf-inet-types {
prefix inet;
}

grouping servers-group {
container servers {
description
“Activate BMP for server”;
tailf:cli-compact-syntax;
container server-1 {
tailf:cli-drop-node-name;
tailf:cli-flatten-container;
tailf:cli-sequence-commands;
leaf server1-name {
tailf:cli-drop-node-name;
description
“Activate BMP for server-1”;
type enumeration {
enum “server”;
}
}
leaf server1-value {
tailf:cli-drop-node-name;
type enumeration {
enum “1”;
}
}
}

      container server-2 {
        tailf:cli-drop-node-name;
        tailf:cli-flatten-container;
        tailf:cli-sequence-commands;
    leaf server2-name {
          tailf:cli-drop-node-name;
      description
        "Activate BMP for server-1";
          type enumeration {
        enum "server";
      }
        }
        leaf server4-value {
          tailf:cli-drop-node-name;
          type enumeration {
        enum "4";
      }
        }
     }
  }

}

container native {
tailf:cli-drop-node-name;
uses servers-group;
}
}

ott-ads-647(config)# servers ?
Possible completions:
[server] server
ott-ads-647(config)# servers server ?
Possible completions:
[1] 1 4
ott-ads-647(config)# servers server 1 ?
Possible completions:

ott-ads-647(config)# servers server 1 ser
^
% Invalid input detected at ‘^’ marker.
ott-ads-647(config)# servers server 1 server ? <=this consider to be invalid
^
% Invalid input detected at ‘^’ marker.
ott-ads-647(config)# servers server 1 server
ott-ads-647(config)# servers server 1 server 4 (this works, but the above line is confusing)
ott-ads-647(config)# commit
27-Sep-2021::13:58:55.104 421us [14facff32740] INFO app.c:111: Subscription for /hosts triggered
27-Sep-2021::13:58:55.104 450us [14facff32740] TRACE app.c:26: ==> process_subscription subsock=3 spoint=7
27-Sep-2021::13:58:55.130 523us [14facff32740] INFO app.c:36: Printing modifications
servers server 1 server 4
27-Sep-2021::13:58:55.130 550us [14facff32740] TRACE app.c:46: <== process_subscription rv=0
Commit complete.

Quick tip: You can use GitHub flavored Markdown to make your posts a bit more readable. Mastering Markdown · GitHub Guides

module generic-yang {

  namespace "https://tail-f.com/ns/example/generic-yang";
  prefix "generic";

  import tailf-common {
    prefix tailf;
  }
  import ietf-inet-types {
    prefix inet;
  }

  grouping servers-group {
        container servers {
          description
            "Activate BMP for server";
          tailf:cli-compact-syntax;
          container server-1 {
            tailf:cli-drop-node-name;
            tailf:cli-flatten-container;
            tailf:cli-sequence-commands;
            leaf server1-name {
            tailf:cli-drop-node-name;
              description
                "Activate BMP for server-1";
              type enumeration {
                enum "server";
              }
            }
            leaf server1-value {
              tailf:cli-drop-node-name;
              type enumeration {
                enum "1";
              }
            }
          }

          container server-2 {
            tailf:cli-drop-node-name;
            tailf:cli-flatten-container;
            tailf:cli-sequence-commands;
            leaf server2-name {
              tailf:cli-drop-node-name;
              description
                "Activate BMP for server-1";
              type enumeration {
                enum "server";
              }
            }
            leaf server4-value {
              tailf:cli-drop-node-name;
              type enumeration {
                enum "4";
              }
            }
         }
      }
  }

  container native {
    tailf:cli-drop-node-name;
    uses servers-group;
  }
}

As you noticed, since you are dropping all node names under the “servers” container, there is no “next” node to show by the tailf:cli-flatten-container extension once the leafs in the container have been set.

Some creativity is required so that there are nodes names under the “servers” container that are not dropped.

  1. Perhaps you can simplify to something like this:
  grouping servers-group {
    container servers {
      description
      "Activate BMP for server";
      tailf:cli-compact-syntax;
      container server-1 {
        tailf:cli-drop-node-name;
        tailf:cli-flatten-container;
        leaf server {
          type enumeration {
            enum "1";
          }
        }
      }
      container server-2 {
        tailf:cli-drop-node-name;
        tailf:cli-flatten-container;
        leaf server {
          type enumeration {
            enum "4";
          }
        }
      }
    }
  }
  1. Or if there can be multiple “server values” you can do something like this:
  grouping servers-group {
    container servers {
      description
      "Activate BMP for server";
      tailf:cli-compact-syntax;
      container server-1 {
        tailf:cli-drop-node-name;
        tailf:cli-flatten-container;
        container server {
          tailf:cli-flatten-container;
          leaf server-value {
            tailf:cli-drop-node-name;
            type enumeration {
              enum "1";
            }
          }
        }
      }
      container server-2 {
        tailf:cli-drop-node-name;
        tailf:cli-flatten-container;
        container server {
          tailf:cli-flatten-container;
          leaf server-value {
            tailf:cli-drop-node-name;
            type enumeration {
              enum "4";
            }
          }
        }
      }
    }
  }

Thanks for the quick response. Both approaches are working and the first one is more straight forward.
Seems when a flatten container has more than one leafs the autocompletion is stop working across the containers in my original example and the solutions you provide just workaround it. Anyway, we are good for now and will adopt your first approach. Thank you!

Good to read you found a solution. Simple beats complex.

But regarding “just a workaround” I disagree. As I wrote in my response, your initial solution had a tailf:cli-drop-node-name on all nodes which was unnecessary and likely always will be. That’s why the tailf:cli-flatten-container could not find a node to continue with after the leafs in the container had been set.
If you find yourself with a proposed solution where you will have to drop the names of all nodes, there will likely always be a better soluiton.