cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3835
Views
15
Helpful
5
Replies
Highlighted
Participant

RESTCONF YANG Idiots Guide?

Afternoon..

 

I've been playing with RESTCONF/YANG and a few other product APIs recently, but I'm really struggling with the documentation for the Switches / Routers, and in particular, understanding what YANG models are implemented for what device/IOS.

 

If I go here for example - https://github.com/YangModels/yang/blob/master/vendor/cisco/xe/1681/csr1k-netconf-capability.xml - it tells me there are loads of YANG models available for the CSR1K, which conveniently is what's available in the Always-On Sandbox.  I know this is a NETCONF list, but as I understand it, YANG models are independant from the Protocol I'm using, so if they're available for NETCONF they should be available for RESTCONF (right?)

 

I started with the ubiquitous URI that seems to be in all the documents, just to make sure I'm barking up the right tree - https://ios-xe-mgmt.cisco.com:9443/restconf/data/ietf-interfaces:interfaces - and it works perfectly, returning a nice list of interfaces, addresses, descriptions, and so on.

 

Now if I want to switch to using a different resource, say 'Cisco-IOS-XE-cdp' (identified as being a valid resource by the NETCONF Capability URL above) via this URI - https://ios-xe-mgmt.cisco.com:9443/restconf/data/Cisco-IOS-XE-cdp - all I get is an error message.  Even if I try this - https://ios-xe-mgmt.cisco.com:9443/restconf/data/Cisco-IOS-XE-cdp:CdpNeighborDetails - or this - https://ios-xe-mgmt.cisco.com:9443/restconf/data/Cisco-IOS-XE-cdp:CdpNeighborDetails?depth=unbounded&content=all - all I ever get back is;

 

{
    "errors": {
        "error": [
            {
                "error-message": "uri keypath not found",
                "error-tag": "invalid-value",
                "error-type": "application"
            }
        ]
    }
}

 

The same seems to be true for just about whatever I try, and I can't believe trial and error is the best way to work out what is, or is not, available for use.

 

I thought I was on to something when I found this seemingly helpful response on GitHub - https://github.com/YangModels/yang/issues/270#issuecomment-338592405 - but the skills / knowledge to follow this through so I can actually work out what Cisco models are implemented and how to access them seems to be escaping me.

 

Is this actually a hard thing to do?  Surely it shouldn't be....  Can some kind person please spell it out for me, using really small words as I'm no Dev, how do you determine what YANG models and Data Classes are available for what product, and how do you query them using RESTCONF?

 

Thank you!!!

5 REPLIES 5
Highlighted
Cisco Employee

Hi Richard,

Checkout this beautiful book on network programming which explains different data modelling and programmimg techniques to automate IOS XE devices.

 

https://www.cisco.com/c/dam/en/us/products/collateral/enterprise-networks/nb-06-ios-xe-prog-ebook-cte-en.pdf

 

Let me know if this is helpful. Meanwhile, I will also try out stuffs you have mentioned and see if I can add more to this.

 

Regards,

Jayesh

Highlighted

I have checked the book.
I'm beginner into this, would you provide me an example how to use a sample example using RESTCONF (would be good if it uses ydk-py) in IOS RELEASE XE 16.09?
Highlighted
Beginner

Late answer, but as this post popped up when I was looking at the same issue, so others might benefit:
/restconf/data/netconf-state/capabilities
gives you a nice list of supported YANG models. Works on the platforms I work with.

Highlighted
Beginner

This is late I know, but did you ever find a satisfactory answer to your question in a way that made sense? I've been trawling programmability guides, command reference documents, forums, and have found the information to be contradictory and patchy.

Highlighted

In my opinion, the main problem with netconf-yang is grouping. For example, I have https://{{ip}}:{{port}}/restconf/data/Cisco-IOS-XE-eigrp-oper. In the yang model (Cisco-IOS-XE-eigrp-oper), there are many gripping with containers and only one container without grouping named "eigrp-oper-data". When I try https://{{ip}}:{{port}}/restconf/data/Cisco-IOS-XE-eigrp-oper:eigrp-oper-data its working fine but using any other container for example "nbr-sw-ver" returns error 404.

Content for Community-Ad
Cisco Community October 2020 Spotlight Award Winners
This widget could not be displayed.