04-12-2019 12:46 PM
I am working on a creating an action that returns some output for a certain show command. I can successfully run the command via the rest api but was wondering if it is possible to do the same via restconf and if their are any advantagaes to doing so.
Also what is the correct way to find a URI path for restconf?
REST api curl:
curl -X POST \
http://localhost:8080/api/running/NDOS:action/_operations/ShowCommands \
-H 'Authorization: Basic dAAAAAAAAAAAAAA==' \
-H 'Content-Type: application/vnd.yang.operation+xml' \
-H 'Postman-Token: AAAAAAAAAAAAAAAAAAAAAAA' \
-H 'cache-control: no-cache' \
-d '<input>
<deviceName>CQ5LAB9K</deviceName>
<showCMD>show l2vpn bridge-domain brief</showCMD>
</input>
'
Which outputs the results of the custom command and its parser.
<output xmlns='http://example.com/NDOS'>
<result>{'CISCO_TAC': ['TEST_TAC'], 'EVPN_DHN': ['EVPN_2001'], 'Eng': ['LTE_LAB_1', 'LTE_LAB_2']}</result>
</output>
Solved! Go to Solution.
04-16-2019 12:25 PM
Hello,
Here is a comparison of REST vs RESTCONF for the same action call - notice the difference in the Content Type, as well as the URI path:
04-15-2019 12:51 AM
Hi here is an example using restconf
POST
https://<user>:<pass>@<nso-host>:8888/restconf/operations/devices/device=<nexus device>/live-status/tailf-ned-cisco-nx-stats:exec/any
Headers
Accept application/yang-data+xml
Content-Type application/yang-data+json
Body
{"input":{"args": "show run"}}
Thanks
Regards
Yale
04-15-2019 05:58 AM - edited 04-16-2019 10:59 AM
I was able to get this working after reading the rfc and realizing that it just follows the yang model you create with the action. Also I was sending the input in XML and needed to be JSON in my case.
curl -X POST \
http://localhost:8080/restconf/operations/NDOS:action/ShowCommands \
-H 'Authorization: Basic dAAAAAAAAAAAAAA==' \
-H 'Content-Type: application/vnd.yang.operation+xml' \
-H 'Postman-Token: AAAAAAAAAAAAAAAAAAAAAAA' \
-H 'cache-control: no-cache' \
-d '{
"input": {
"deviceName": "CQ5CORPLBA41",
"deviceType": "cisco-ios-xr",
"showCMD": "show l2vpn bridge-domain brief"
}
}'
04-15-2019 11:42 PM
the example you have posted is using RESTAPI not RESTCONF
04-16-2019 11:00 AM
Updated. Pasted over the wrong one. The edited command works.
04-16-2019 12:25 PM
Hello,
Here is a comparison of REST vs RESTCONF for the same action call - notice the difference in the Content Type, as well as the URI path:
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: