cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2597
Views
20
Helpful
4
Replies

NSO, show devices brief via RESTCONF

bfinnema
Cisco Employee
Cisco Employee

When doing this:

curl --location --request GET 'http://localhost:8080/restconf/data/tailf-ncs:devices' \
--header 'Accept: application/yang-data+json' \
--header 'Cache-Control: no-cache' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw ''

I get enormous amounts of data, including complete config of each device. I just want a list o devices similar to running "show devices brief" on NSO. How can I do that with RESTCONF?

 

4 Replies 4

rogaglia
Cisco Employee
Cisco Employee

Hi,

 

You should review RFC8040 query parameters:

https://tools.ietf.org/html/rfc8040#section-4.8

 

+---------------+---------+-----------------------------------------+
   | Name          | Methods | Description                             |
   +---------------+---------+-----------------------------------------+
   | content       | GET,    | Select config and/or non-config data    |
   |               | HEAD    | resources                               |
   |               |         |                                         |
   | depth         | GET,    | Request limited subtree depth in the    |
   |               | HEAD    | reply content                           |
   |               |         |                                         |
   | fields        | GET,    | Request a subset of the target resource |
   |               | HEAD    | contents                                |
   |               |         |                                         |
   | filter        | GET,    | Boolean notification filter for event   |
   |               | HEAD    | stream resources                        |
   |               |         |                                         |
   | insert        | POST,   | Insertion mode for "ordered-by user"    |
   |               | PUT     | data resources                          |
   |               |         |                                         |
   | point         | POST,   | Insertion point for "ordered-by user"   |
   |               | PUT     | data resources                          |
   |               |         |                                         |
   | start-time    | GET,    | Replay buffer start time for event      |
   |               | HEAD    | stream resources                        |
   |               |         |                                         |
   | stop-time     | GET,    | Replay buffer stop time for event       |
   |               | HEAD    | stream resources                        |
   |               |         |                                         |
   | with-defaults | GET,    | Control the retrieval of default values |
   |               | HEAD    |                                         |
   +---------------+---------+-----------------------------------------+

 

omz
VIP Alumni
VIP Alumni

 

http://localhost:8080/restconf/data/tailf-ncs:devices/device
http://localhost:8080/restconf/data/tailf-ncs:devices/device=ios0/config

curl -i -u admin:admin http://localhost:8080/restconf/operations/devices/device=ios0/live-status/tailf-ned-cisco-ios-stats:exec/any -X POST -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json' -d "{\"input\": {\"args\": \"show devices brief\"}}"

 

 

perander
Cisco Employee
Cisco Employee

As Roque stated, review thew RESTCONF query parameters; specifically "depth" and

"fields" are useful for pruning data.

 

Note though that there might be better performace using the RESTCONF Query API

(it might be called REST Query API in documentation). If it's a one shot query without

the need for pagination use "immediate-query", where the query response contains

the results in the payload; thus eliminiating the need for an explicit "fetch-query-result".

curl --location 'https://localhost:4464/restconf/data/tailf-ncs:devices/device?depth=1&fields=name' \
--header 'Accept: application/vnd.yang.collection+xml' \
--header 'Content-Type: application/vnd.yang.collection+xml' \

response like,

    <device xmlns="http://tail-f.com/ns/ncs"  xmlns:ncs="http://tail-f.com/ns/ncs">
        <name>pe-0</name>
    </device>