01-09-2019 02:46 AM - edited 03-01-2019 04:15 AM
Hi all,
I have a few user cases where will need to run show commands on the devices that nso is managing
i can run this type of command from the cli
devices device C6880 live-status ios-stats:exec any show version
does some one know how to do the same via RESTCONF
Thanks
Regards
Yale
Solved! Go to Solution.
01-09-2019 02:56 AM
Hi,
See a similar example but for ios-xr below. For ios it should be very similar (note that the prefix needs to be changed on the uri):
curl -i -u admin:admin http://localhost:8080/restconf/operations/devices/device=xr-0/live-status/tailf-ned-cisco-ios-xr-stats:exec/any -X POST -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json' -T show-run-vrf.json cat show-run-vrf.json { "input": { "args": "show run vrf foo" } }
01-09-2019 02:56 AM
Hi,
See a similar example but for ios-xr below. For ios it should be very similar (note that the prefix needs to be changed on the uri):
curl -i -u admin:admin http://localhost:8080/restconf/operations/devices/device=xr-0/live-status/tailf-ned-cisco-ios-xr-stats:exec/any -X POST -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json' -T show-run-vrf.json cat show-run-vrf.json { "input": { "args": "show run vrf foo" } }
01-09-2019 03:30 AM
Hi,
not having much luck, this section of the url "tailf-ned-cisco-ios-xr-stats:exe" how do you work this part out, i'm trying to run against XRv in the example below, but how would i find out what the url would be for NX, IOS or ASA.
[admin@localhost:~]$ curl -i -u admin:admin http://localhost:8888/restconf/operations/devices/device=XRv-1/live-status/tailf-ned-cisco-ios-xr-stats:exec/any -X POST -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json' -T show.json
curl: (52) Empty reply from server
[admin@localhost:~]$ cat show.json
{
"input":
{
"args": "show ver"
}
}
[admin@localhost:~]$
Thanks
Regards
Yale
01-09-2019 04:30 AM
Hi,
In ncs.conf:
Do you have port 8888 enabled? Does it use http? (not https?)
Do you have restconf enabled? Do you have webui enabled?
Should be something like this in a local-install (on a system-install it looks different by default):
<webui> <enabled>true</enabled> <transport> <tcp> <enabled>true</enabled> <ip>0.0.0.0</ip> <port>8080</port> </tcp> <ssl> <enabled>true</enabled> <ip>0.0.0.0</ip> <port>8888</port> <key-file>${NCS_DIR}/var/ncs/webui/cert/host.key</key-file> <cert-file>${NCS_DIR}/var/ncs/webui/cert/host.cert</cert-file> </ssl> </transport> <cgi> <enabled>true</enabled> <php> <enabled>false</enabled> </php> </cgi> </webui> <rest> <enabled>true</enabled> </rest> <restconf> <enabled>true</enabled> </restconf>
One way to get the prefix for other NEDs (might be smarter ways...), is to find the NED module that implements the action you want to run.
In this case, on your cli command you saw 'ios-stats:exec' and if you search the NED YANG files, you'd find this prefix in file tailf-ned-cisco-ios-stats.yang:
// ========================================================================= // CISCO-IOS NED STATS // ========================================================================= module tailf-ned-cisco-ios-stats { namespace "urn:ios-stats"; prefix ios-stats;
So, your uri should have: 'live-status/tailf-ned-cisco-ios-stats:exec/any'
Hope that helps!
01-09-2019 04:32 AM
BTW,
I tried accessing my https port 8888 with http, and got the same results as you did ((52) Empty reply from server).
Try using the http port, or change the URI to use https.
Yftach
01-09-2019 04:43 AM
school boy error missed the s off the https
and thanks for explaining how to find the right path
Thanks
Regards
Yale
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: