How to display configured values in the show command?

Hi All,

I want to display configured values in the show command and if anything is not configured then I want to call show command with some default value.

My show command syntax is “show policy access-list [name] stats”

My acl yang is below

grouping policy-config-grouping {

 list access-list {
   tailf:info "configure ACLs";
   tailf:cli-compact-syntax;
   key "name";
   leaf name {
     tailf:info "name of access list";
     type string;
   }
   list sequence {
     tailf:info "list of sequences";
     key "seq-value";
      leaf seq-value {
      }
      leaf protocol {
      }
      leaf source-ip {
      }
      leaf destination-ip {
      }
      leaf source-port {
      }
      leaf destination-port {
      }
      leaf action {
      }
    }
    leaf default-action {
    }
  }
}
container policy {
tailf:info "policy information";
tailf:cli-add-mode;
uses policy-config-grouping;
  }
}

I want the following points:

  1. If the access list is configured then in the “show policy access-list [name] stats” command, I would like to see the configured access-lists if user type ? after access-list keyword.
  2. Also I would also like to see one more keyword name as all along with the configured access-lists. It is because if any user want to dump the stats of all the access-list then he can pass the all keyword instead of the configure access-list

so finally the command what I want looks like something below
show policy access-list [all | acl-1 | acl-2 | acl-n ] stats

I tried to implement the same thing but I am facing below problem

  1. not able to display the extra keyword all along with the configured access-lists
  2. If no access-lists are configured then show command does not move after “show policy access-list”. After this it shows “No entries present”

Can someone please help me

You can try to mix autorendered commands (from datamodel and data) with clispec commands (e.g. to add all parameter).

The clispec callback can call maapi_cli_cmd or maapi_cli_cmd_io and call corresponding command on your data model (e.g. call show running config policy access-list in case user enters clispec command show running config policy access-list all).

Unfortunately, this is not trivial implementation. See ConfD UG section related to clispec.

Hello mnovak,

Thank you for the response and providing your input on this topic. Apart from clispec , is there any other solution possible?
Actually what happens when I write show policy access-list ?, then it does display the configured access-lists but it does not show the <cr> option. So wondering if any user wants to display the stats of all the configured access-lists then How I will achieve that?

Also assume I don’t want all keyword

show policy access-list ? displays all possible CLI completions you can make at this level, In your case you can continue with key element of access-list, so all key elements (leaf name) are suggested.

To display all configured access-list elements, you should use show policy access-list followed by [ENTER].
Or better use show running-config policy access-list (exit config mode for this), which shows what is really configured, not pending in CLI (before commit).