06-15-2017 04:18 AM
Hi there, I've been experimenting w/ IOS-XE 16.5.1 on a CSR & have attempted to query the RESTCONF API. I have had some success, but, honestly, I'm having a hard time getting the information that I want. Being able to identify the correct URI to extract targeted data has been time-consuming because it's based on me just attempting random hit & miss URI combinations to get the data I want. I haven't been able to make sense of how to map the YANG models directly to a functional URI & was hoping that someone could provide me with some guidance on how to take a specific YANG model & then be able to access the desired information within.
A concrete example:
I have configured MPLS tunnels between 2 CSR's & am attempting to query the Cisco-IOS-XE-mpls.yang model.
The closest URI I get to which provides meaningful info is as follows:
http://192.168.3.41/restconf/api/running/ios:native/ios:interface/Tunnel/102?deep
{
"Cisco-IOS-XE-native:Tunnel": {
"name": 102,
"description": "OPS(test1<>test2)::blah::AAAAAAAAAAAA::blahblah",
"ip": {
"unnumbered": "Loopback1000"
},
"Cisco-IOS-XE-tunnel:tunnel": {
"destination": "10.253.24.2",
"mode": {
"mpls": {
"traffic-eng": {}
}
},
"mpls": {
"traffic-eng": {
"path-option": {
"working": [
{
"id": 5,
"explicit": {
"name": {
"exp-name": "TEST1_TO_TEST2_TE"
}
}
}
]
}
}
}
}
}
}
I arrived at this 100% via trial and error (guessing) and it doesn't contain alot of the information I want.
How do I make sure I'm accessing the YANG data model I want (Cisco-IOS-XE-mpls.yang)?
https://<ADDRESS>/<ROOT>/<DATA STORE>/<[YANGMODULE:]CONTAINER>/<LEAF>[?<OPTIONS>]
http://192.168.3.41/restconf/api/running/Cisco-IOS-XE-mpls:traffic-eng ????
My main issues are:
1) which datastore: operational/data/config/running ? some YANG models have "-oper" on the end of them, but otherwise I'm clueless.
2) once you know the datastore, how do you know how to access the specific module that you want? Is there a concrete process for doing this? In Cisco documentation (and other tutorials) I constantly see the same example of querying ieee-interfaces, but nothing w/ more detail.
3) is there a way to show API structure (like a list of keys, etc) through querying the API?
4) is there a way to output an entire yang data model (even if parts of it are empty)
Any help or even a push in the right direction would be greatly appreciated!
Thanks,
Erik
06-15-2017 09:39 AM
I had the same feeling since there is not such thing as RESTCONF API reference menu.
I use pyang and yang-explorer to help me figure out what to use.
DevNet learning labs may help too such as RESTCONF related LLs
https://learninglabs.cisco.com/lab/06-dmi-04-introducing-the-restconf-protocol/step/1
https://learninglabs.cisco.com/lab/lab03-using-restconf-to-interface-with-networking-devices/step/1
.....
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide