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

Example of NSO REST call for live-status information

previousqna
Level 5
Level 5

All ,

 

 

I believe this question was asked/answered a couple weeks back.

 

I’m unable to locate the thread.

 

 

I’m looking for a sample REST call (via CURL or python request) to sample live-status info from an IOS device.

 

 

In my specific case , I just need to get a “Show IP route”

 

 

Also, is it possible to have it rendered as json ? or is that dependent on the capabilities of the device being queried?

2 Replies 2

previousqna
Level 5
Level 5

Following is an example I tested in my lab.

 

 

test@test-mint ~ $ cat body.txt

 

{

 

  "show":

 

  {

 

    "args":"users"

 

  }

 

}

 

 

test@test-mint ~ $ curl -i -u admin:admin -X POST -T body.txt http://127.0.0.1:8080/api/operational/devices/device/R1/live-status/ios-stats:exec/_operations/show -H "Content-Type:application/vnd.yang.operation+json"

 

HTTP/1.1 100 Continue

 

Server:

 

Allow: GET, POST, OPTIONS, HEAD

 

Content-Length: 0

 

 

HTTP/1.1 200 OK

 

Server:

 

Date: Tue, 13 Dec 2016 02:29:10 GMT

 

Allow: GET, POST, OPTIONS, HEAD

 

Cache-Control: private, no-cache, must-revalidate, proxy-revalidate

 

Content-Length: 264

 

Content-Type: application/vnd.yang.operation+json

 

Vary: Accept-Encoding

 

Pragma: no-cache

 

 

{

 

  "output": {

 

    "result": "\r\n    Line       User       Host(s)              Idle       Location\r\n*  2 vty 0     cisco      idle                 00:00:00 10.1.1.1\r\n\r\n  Interface    User               Mode         Idle     Peer Address\r\n\r\nR1#"

 

  }

 

}

 

test@test-mint ~ $

 

 

Hope this helps.

I believe following is exactly what you are looking for.

 

 

test@test-mint ~ $ cat body.txt

 

{

 

  "show":

 

  {

 

    "args":"ip",

 

    "args":"route"

 

  }

 

}

 

test@test-mint ~ $ curl  -u admin:admin -X POST -T body.txt http://127.0.0.1:8080/api/operational/devices/device/R1/live-status/ios-stats:exec/_operations/show -H "Content-Type:application/vnd.yang.operation+json"

 

{

 

  "tailf-ned-cisco-ios-stats:output": {

 

    "result": "\r\nCodes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP\r\n       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area \r\n       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2\r\n       E1 - OSPF external type 1, E2 - OSPF external type 2\r\n       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2\r\n       ia - IS-IS inter area, * - candidate default, U - per-user static route\r\n       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP\r\n       a - application route\r\n       + - replicated route, % - next hop override\r\n\r\nGateway of last resort is not set\r\n\r\n      1.0.0.0/32 is subnetted, 1 subnets\r\nC        1.1.1.1 is directly connected, Loopback0\r\n      10.0.0.0/8 is variably subnetted, 6 subnets, 2 masks\r\nC        10.1.1.0/24 is directly connected, Ethernet0/0\r\nL        10.1.1.2/32 is directly connected, Ethernet0/0\r\nC        10.12.0.0/24 is directly connected, Ethernet0/1\r\nL        10.12.0.1/32 is directly connected, Ethernet0/1\r\nC        10.13.0.0/24 is directly connected, Ethernet0/2\r\nL        10.13.0.1/32 is directly connected, Ethernet0/2\r\nR1#"

 

  }

 

}

 

test@test-mint ~ $

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?