cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2131
Views
2
Helpful
1
Replies

RESTCONF API on IOS-XE

edruedin
Level 1
Level 1

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

1 Reply 1

yawming
Cisco Employee
Cisco Employee

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

.....

https://github.com/CiscoDevNet/yang-explorer

Getting Started

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 community: