How to access list attributes in container

From the top level container I want to access list attribute value…e.g

Container aut
{
Container use
{
Tail:cli-show-template “usm : $(msm)”; //but this not accessing my list attribute value…
List unm
{
Key “msm”;
Leaf msm{
Type string;
}
Leaf ab{
\ some type
}
}}}

Also I want access every list attribute individually…
Pls suggest some idea to access my list entries…

Following is an example of how to access your list entries using the show-template feature:

container aut {
  container use {
    list unm {
      config false;
      key "msm";
      tailf:cli-suppress-table;
      tailf:cli-show-template-enter "";
      tailf:cli-show-template-legend
          "MSM     "
          +"$(.selected~=ab?AB   )\n"
          +"=============="
          +"$(.selected~=ab?=====)\n";
      tailf:cli-show-template
          "$(msm|ljust:5) - "
          +"$(.selected~=ab?$(ab|ljust:8)  )\n";

      tailf:cli-show-template-footer
          "$(.?% $(.licounter) entries in the table.\n:"
          +"% No entries in the table.\n)";

      leaf msm {
        type string;
      }
      leaf ab{
        type string;
      }
    }
  }
}

Description of the Show templates feature can be found in Chapter 16.27.2, Show templates, of the ConfD User Guide. You can also refer to the tailf_yang_extensions section in Volume 5 of the ConfD man-pages for more information on the various show-template related YANG annotations and the definition of the YANG type called cli-template-string. There are also various show-template related examples in ConfD Premium that are available including the one under examples.conf/cli/show_templates.

Thank you waitai…

But i want to customize this output for container,not for list.

how to achieve the same thing for container?

You won’t be able to specify the list instances at the container level with the show template feature. Can you describe your display requirements when the user types the following:

show aut use

show aut use unm

I may be able to provide a solution.

1 Like

suppose user typed “show aut use” command then it should display output in tabular format…

for this command (" show aut use unm " ) it should not display output in tabular format.(it should be in auto rendered format)… How i can achieve this requirement by using show template ?. Pls suggest some Idea…

This is the same as the default show output behavior.

There seems to be some conflict with your requirement here. The auto-rendered format for a list is in tabular format.

To make your requirements crystal clear, can you provide a sample output for the two show output commands being discussed?

show aut use

USER AB // here it is listing all the user details.

// 1st user details.
// 2nd user details.
// 3rd user details.

Example:

show aut use

USER AB

net che
sec ban
ems mum

show aut use unm

Example:
show aut use unm net //it should display all the attributes to that specific user.

User:net
Ab:che
email: abc@yahoo.com
phone:1234

Your example output format has more information than is shown in your original YANG file.

With the following YANG snippet:

container aut {
  container use {
    list unm {
      tailf:cli-suppress-table;
      tailf:cli-show-template-enter "";
      tailf:cli-show-template-legend
        "USER AB\n";
      tailf:cli-show-template
        " $(msm) $(ab)\n";

      config false;
      key "msm";
      leaf msm {
        type string;
      }
      leaf ab{
        type string;
      }
    }
  }
}

you will get the following CLI show output behavior:

localhost# show aut use 
USER AB

 ems mum
 net che
 sec ban
localhost# show aut use unm net 
 net che

You are right.I’m seeing same output format for both the command.only few output differences like 1st command listing all the user details in tabular format. 2nd command listing that specific user detail in same (tabular) format.as per my require ment 2nd command output format should be differ from my 1st command…