Show command with multiple input from cli

I Need to get the router device(router_dev) information with the below 5 parameter “register” “iftype” “device-add” “port-add” “register-add”

Please suggest me how to design the yang file for the below 5 parameter. should i consider the container or list.

The command must be something like below

hp-flare1# show router_dev register 1 iftype 3 device-add 45 port-add 58 register-add 67

Once I give the above command from the cli, at one shot I want to extract all the 5 paramaters from the my .c file , please suggest me the steps.

Whether you use a container or a list depends on whether the data you are configuring is a set of single values, or forms an entry in a table.

If you have a single router_dev instance, then you can have a container called router-dev, with leaf nodes representing ‘register’, ‘if type’, etc.

If however you can have multiple router_dev instances, then you need to determine what forms the key for that table. It sounds as though from your show command, that possibly all of those items form the key?

Perhaps you can let us know the answer to these questions, then we can make more detailed recommendations. Is there an existing CLI that you are trying to imitate, or is this just specific to your device?

Hi greg,
Thank you very much for your reply.
I am having the single router_dev which takes the multiple input arguments like (“register” “iftype” “device-add” “port-add” “register-add” all these arguments take the integer values with certain range of data like 0-500) to display the router_dev information.
No I am not using the multiple router_dev instances.
Yes the Confd CLI we are using to input the values to show command.

If I give the below command :
hp-flare1# show router_dev register 1 iftype 3 device-add 45 port-add 58 register-add 67

Through my .c file I need to extract these parameter like
register = 1
iftype = 3
device-add = 45
port-add = 58
register-add = 67

And Finally I need to call the API with the above parameters value to get the information of the device.

Please suggest me how to design the yang file for the below 5 parameter. should i consider the container or list.
Once I give the above command from the cli, at one shot I want to extract all the 5 paramaters from the my .c file , please suggest me the steps.

If you have a single router_dev instance, then it sounds as though you will want to model this as a container, with register, iftype, device-add, port-add, register-add all as leafs within that container.

I am still a little confused since your show command has all of the input arguments which make it sound as though it is a list with all of those input arguments forming the key. Normally if router_dev was a container then you would just say ‘show router_dev’ and everything inside the container would be displayed. You wouldn’t need to specify the input arguments. If you are saying you need to specify the input arguments, then it sounds as though you really have a list.

If you haven’t already done so, I would recommend that you watch module 5 and 6 of the training videos, which covers YANG, and module 10, which covers the CDB subscriber, and this would describe how to get the values within your C program.

Hey greg
Thank you very much for the valuable suggestions , it worked for me.

Hi greg,
I designed the yang model with container router_dev with one list register with the 5 leaf items with all the leaf as key values.
Please find the below yang model
module arpe {
namespace “http://tail-f.com/ns/example/arpe”;
prefix arpe;

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

container router_dev {
config false;
tailf:callpoint arpe;
list register {
key “device_index if_type device_address port_address register_address”;
max-elements 1024;
leaf device_index {
type uint32;
}
leaf if_type {
type uint32;
}
leaf device_address {
type uint32;
}
leaf port_address {
type uint32;
}
leaf register_address {
type uint32;
}
}
}
}

And this working fine if i give show command as below
hp-flare1# show router_dev register 1 2 3 4 5
ROUTER_DEV
DEVICE IF DEVICE PORT REGISTER
INDEX TYPE ADDRESS ADDRESS ADDRESS

1 2 3 4 5

hp-flare1#

And I can able to extract the values from the .c file.

But I want to pass the leaf names also in the show command like below ;

show router_dev register 1 iftype 3 device-add 45 port-add 58 register-add 67

Please suggest me further how modify the existing yang model ? and any modification I need to do in the get_next call back ?

You can use the tailf extension “tailf:cli-expose-key-name” in the key leafs that you want to expose the leaf name of. E.g.:

leaf device_index {
  tailf:cli-expose-key-name;
  type uint32;
}

See tailf_yang_cli_extensions man page (also available as an appendix to the UG) for more on the “tailf:cli-expose-key-name” extension.

Hey greg,
Thanks a lot it worked for me.

hp-flare1# show router_dev register register device_index 1 if_type 2 device_address 3 port_address 4 register_address 5

DEVICE IF DEVICE PORT REGISTER
INDEX TYPE ADDRESS ADDRESS ADDRESS

1 2 3 4 5

Hi cohult,
For the above yang model suppose if I add one more list register2 under the same container router_dev.

module arpe {
namespace “http://tail-f.com/ns/example/arpe”;
prefix arpe;
import ietf-inet-types {
prefix inet;
}
import tailf-common {
prefix tailf;
}
container router_dev {
config false;
tailf:callpoint arpe;
list register {
key “device_index if_type device_address port_address register_address”;
max-elements 1024;
leaf device_index {
tailf:cli-expose-key-name;
type uint32;
}
leaf if_type {
tailf:cli-expose-key-name;
type uint32;
}
leaf device_address {
tailf:cli-expose-key-name;
type uint32;
}
leaf port_address {
tailf:cli-expose-key-name;
type uint32;
}
leaf register_address {
tailf:cli-expose-key-name;
type uint32;
}
}

list register2 {
key “timeinterval recycletime”;
max-elements 1024;
leaf timeinterval {
tailf:cli-expose-key-name;
type uint32;
}
leaf recycletime {
tailf:cli-expose-key-name;
type uint32;
}
}
}
}

From the cli if i give the inputs to list resgister2

hp-flare1# show router_dev
Possible completions:
mdio system_param |
hp-flare1# show router_dev register2 timeinterval 1
------------------------------------------------------------^
syntax error: unknown argument

From the application I am getting the below error:

TRACE CALL trans init(thandle=6,mode=“r”,db=running) --> CONFD_OK
TRACE CALL data get_elem(thandle=6,/router_dev/register2{1}/timeinterval)
$$$$$ timeinterval
arpstat: arpstat.c:364: get_elem: Assertion `(&(keypath->v[2][0]))->type == C_UINT32’ failed.
Aborted (core dumped)
make: *** [start] Error 134

The get_element callback code is below:

case arpe_timeinterval:
      {
        printf("\n $$$$$ timeinterval") ;
        int keep_alive = CONFD_GET_UINT32(&(keypath->v[2][0]));
        printf("\n\t timeinterval =%d   \n", timeinterval);
        break;
      }

Please suggest me further how to modify the existing code under case arpe_timeinterval for the keypath value from the API CONFD_GET_UINT32 ? and any modification I need to do in the get_next or get_elem call back ?

The type of your timeinterval is not correct. It seems to be in the YANG model you provided, but not in your CLI output. I don’t believe you are using the same YANG model in your CLI output as the one you provided.

So if your timeinterval really was a key, as in the YANG model you provided, ConfD would not retrieve it using get_elem.

Your YANG model does not match your debug output.
Please provide a matching YANG model, c-application, and debug output if you want/need help.