# Show command with multiple input from cli

**URL:** <https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429>\
**Category:** YANG\
**Created:** [March 21, 2016, 11:22am UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429 "2016-03-21T11:22:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jirasap](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jirasap](https://dmap-community.ductus.global/u/jirasap)\
**Post date:** [March 21, 2016, 11:22am UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/1 "2016-03-21T11:22:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@greg](https://dmap-community.ductus.global/u/greg)\
**Post date:** [March 21, 2016, 9:07pm UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/2 "2016-03-21T21:07:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jirasap](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jirasap](https://dmap-community.ductus.global/u/jirasap)\
**Post date:** [March 22, 2016, 4:31am UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/3 "2016-03-22T04:31:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@greg](https://dmap-community.ductus.global/u/greg)\
**Post date:** [March 22, 2016, 4:58pm UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/4 "2016-03-22T16:58:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jirasap](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jirasap](https://dmap-community.ductus.global/u/jirasap)\
**Post date:** [March 29, 2016, 6:06am UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/5 "2016-03-29T06:06:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jirasap](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jirasap](https://dmap-community.ductus.global/u/jirasap)\
**Post date:** [March 30, 2016, 10:08am UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/6 "2016-03-30T10:08:34Z")

</div>

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](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 ?

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [March 30, 2016, 10:37am UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/7 "2016-03-30T10:37:33Z")

</div>

> [@jirasap](#):
>
> 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

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.

---

<div class="post-metadata">

**Author:** ![jirasap](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jirasap](https://dmap-community.ductus.global/u/jirasap)\
**Post date:** [March 30, 2016, 11:45am UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/8 "2016-03-30T11:45:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jirasap](https://avatars.discourse-cdn.com/v4/letter/j/5fc32e/32.png) [@jirasap](https://dmap-community.ductus.global/u/jirasap)\
**Post date:** [April 11, 2016, 9:47am UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/9 "2016-04-11T09:47:02Z")

</div>

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](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 ?

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [April 14, 2016, 7:12pm UTC](https://dmap-community.ductus.global/t/show-command-with-multiple-input-from-cli/429/10 "2016-04-14T19:12:47Z")

</div>

> [@jirasap](#):
>
> hp-flare1# show router\_dev register2 timeinterval 1------------------------------------------------------------^syntax error: unknown argument

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.

> [@jirasap](#):
>
> TRACE CALL data get\_elem(thandle=6,/router\_dev/register2{1}/timeinterval)

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.
