cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2027
Views
1
Helpful
1
Replies

NSO REST Query API Usage

Hey NSO Experts,

I came across the NSO REST Query API in the North bound API documentation and found it to be quite interesting and possibly powerful feature. However, the doc is a bit simple in its example and crafting more complex queries has been a bit tricky.

Does anyone have experience with the Query API that could offer some guidance? A sample query would be "Return all GigabitEthernet interface descriptions for devices in a given Device Group"

For those not familiar with the API here is a nifty simple query to get all devices where cdp is enabled:

URL: localhost:8080/api/query

Headers:

    'content-type': "application/vnd.yang.data+xml"

Body:

<start-query xmlns="http://tail-f.com/ns/tailf-rest-query">

<foreach>

/ncs:devices/device

</foreach>

<select>

<label>Host name</label>

<expression>name</expression>

<result-type>string</result-type>

</select>

<select>

<label>cdp enabled</label>

<expression>config/cdp/run</expression>

<result-type>string</result-type>

</select>

<sort-by>name</sort-by>

<limit>100</limit>

<offset>1</offset>

</start-query>

1 Accepted Solution

Accepted Solutions

Jan Lindblad
Cisco Employee
Cisco Employee

This is mostly a question of being able to express your query in XPATH 1.0.

To select all devices that are members of device-group 'group11' and have authgroup 'vagrant' and get all the GigE interface descriptions, you could use (assuming an IOS CLI NED):

/devices/device[name=/devices/device-group[name='group11']/member][authgroup='vagrant']/config/ios:interface/GigabitEthernet/description

View solution in original post

1 Reply 1

Jan Lindblad
Cisco Employee
Cisco Employee

This is mostly a question of being able to express your query in XPATH 1.0.

To select all devices that are members of device-group 'group11' and have authgroup 'vagrant' and get all the GigE interface descriptions, you could use (assuming an IOS CLI NED):

/devices/device[name=/devices/device-group[name='group11']/member][authgroup='vagrant']/config/ios:interface/GigabitEthernet/description

Polls
AI-powered tools for network troubleshooting are likely to be part of everyone’s workflow sooner or later. What is the single biggest challenge or concern you see with adopting these tools in your organization?