cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
761
Views
0
Helpful
0
Replies

Include Interface Name in api Query return

tsiemers1
Spotlight
Spotlight

I am trying to pull some data from the query api and would like it to include the interface name in a foreach loop.

 

The call:

 

curl -u user:pass -i 'http://localhost:8080/api/query' -X POST -T testquery.json -H "Content-Type: application/vnd.yang.data+json"

 

with input data:

 

{
"immediate-query": {
"foreach": "/devices/device[name='CC4CORPLBB12']/config/interface/",
"select": [
{
"expression": "interface_name",
"result-type": ["string"]
}
],

"select": [
{
"expression": "name",
"result-type": ["string"]
}
], 
"sort-by": ["interface_type"],
"limit": 100,
"offset": 1
}
}

I am trying to build a json return that list the interface_type, name, and all service-policies attached to it.

 

The part that doesn't exist is the interface_type. I would like it to return something in json like this:

 

"select": [
{
"label": "Interface_Type",
"value": "Gi0/0/5",

"label": "PMAP_INPUT",

"value": "pmap_ingress",
}
]
},

 Is it possible to return the interface type in a query?

 

Alternatively I tried to accomplish this with the live-status doing a "show policy-map interface brief" but it returns as one long string and is hard to parse.

 

devices device CC4CORPLBB12 live-status ios-stats:exec show policy-map int br | display json
{
  "result": "\n> show policy-map int br\r\nService-policy output: PMAP__OAM_E\r\n GigabitEthernet0/0/5: EFP 1001 \r\nService-policy input: PMAP__OAM_I\r\n GigabitEthernet0/0/5: EFP 1001 \r\nService-policy output: PMAP_FIXED_IPTV_E\r\n GigabitEthernet0/0/5: EFP 1032 \r\nService-policy input: PMAP_FIXED_IPTV_I\r\n GigabitEthernet0/0/5: EFP 1032 \r\nService-policy input: PMAP_MGMT_I\r\n GigabitEthernet0/0/1 \r\n GigabitEthernet0/0/8: EFP 1000 \r\n GigabitEthernet0/0/5: EFP 5 \r\nService-policy output: PMAP_MGMT_BE_E\r\n GigabitEthernet0/0/1 \r\n GigabitEthernet0/0/8: EFP 1000 \r\nService-policy input: PMAP_FIXED_BNG_PRNT_I\r\n GigabitEthernet0/0/5: EFP 4 \r\nService-policy output: PMAP_FIXED_BNG_PRNT_E\r\n GigabitEthernet0/0/5: EFP 4 \r\nService-policy input: PMAP__PRNT_I\r\n GigabitEthernet0/0/5: EFP 1000 \r\nService-policy output: PMAP__PRNT_E\r\n GigabitEthernet0/0/5: EFP 1000 \r\nService-policy input: PMAP_FIXED_VOICE_PRNT_I\r\n GigabitEthernet0/0/5: EFP 103 \r\nService-policy output: PMAP_FIXED_VOICE_PRNT_E\r\n GigabitEthernet0/0/5: EFP 103 \r\nService-policy output: TEST\r\n GigabitEthernet0/0/0 \r\nLAB-ASR920-24SZ-2#"

Is there a cleaner way of doing this?

0 Replies 0