cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
774
Views
0
Helpful
9
Replies
Cisco Employee

YDK tutorial

hi people,

How can i find any good tutorial for if i want to put the following YANG Oper data from cisco XR devices?

yang/Cisco-IOS-XR-plat-chas-invmgr-oper.yang at master · YangModels/yang · GitHub

what i want to do is to get the inventory data in XML format and put them in a file...

Cheers

Guan

Everyone's tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Cisco Employee

Re: YDK tutorial

Guan,

Regarding your original question, the NANOG 68 YDK talk will give you a bit of a tutorial:

NANOG 68: YDK overview / demo

You can find a sample app to read the inventory, validate the data, encode it in XML and print output at:

nc-read-xr-plat-chas-invmgr-oper-99-ydk.py · GitHub

You can invoke it using:

$ ./nc-read-xr-plat-chas-invmgr-oper-99-ydk.py ssh://user:password@host

Hope that help!

View solution in original post

9 REPLIES 9
Highlighted
Cisco Employee

Re: YDK tutorial

Guan,

We don’t currently support a version of the YDK that has IOS-XR 5.3.4 models in it. Have you tried direct a direct NETCONF get? You might try the utility ncc.py, found here (recommend pulling entire git repo):

https://github.com/CiscoDevNet/ncc/blob/master/ncc.py

Something like this should work once you’ve downloaded it and installed its dependencies:

python ncc.py --host=your-device-ip -u your-username -p your-password --get-oper \

-f ‘<platform-inventory xmlns=“http://cisco.com/ns/yang/Cisco-IOS-XR-plat-chas-invmgr-oper">'

This will dump XML to your console, and you can either use this as a CLI utility, or copy the use of the python ncclient library to your own code.

Cheers,

Einar

Highlighted
Cisco Employee

Re: YDK tutorial

hi Nilsen,

many thanks!

I got the packet installed, but i am getting this:

(v)vagrant@vagrant-ubuntu-trusty-64:~/ncc$ python ncc.py --host=1.1.1.1 -u vagrant -p vagrant --get-oper  -f ‘<platform-inventory xmlns=“http://cisco.com/ns/yang/Cisco-IOS-XR-plat-chas-invmgr-oper">'

> °°

> <<

> >>>

> >ff

> >

>

>

seems the command is not finished and i was stuck in >

Cheers

Guan

Highlighted
Cisco Employee

Re: YDK tutorial

Guan,

If you copied & pasted from your web browser or email, please make sure that no unicode quote characters got copied from the website. That can mess things up when ingested by the shell and provide bad input to Python.

Looking at what I see in the email below, there is two wrong characters, and they may have come from my original posting, apologies.

Cheers,

Einar

Highlighted
Cisco Employee

Re: YDK tutorial

hi Einar,

my filter is still not correct:

python ncc.py --host=1.1.1.1 -u vagrant -p vagrant --get-oper -f <platform-inventory xmlns=“http://cisco.com/ns/yang/Cisco-IOS-XR-plat-chas-invmgr-oper">

>

where do i do wrong?

Highlighted
Cisco Employee

Re: YDK tutorial

Put single quotes around the whole XML tag for platform inventory:

python ncc.py --host=1.1.1.1 -u vagrant -p vagrant --get-oper -f '<platform-inventory xmlns=“http://cisco.com/ns/yang/Cisco-IOS-XR-plat-chas-invmgr-oper”/>'

Without that single quotes, the parameter given to -f isn’t correctly formed.

Cheers,

Einar

Highlighted
Cisco Employee

Re: YDK tutorial

Guan,

Regarding your original question, the NANOG 68 YDK talk will give you a bit of a tutorial:

NANOG 68: YDK overview / demo

You can find a sample app to read the inventory, validate the data, encode it in XML and print output at:

nc-read-xr-plat-chas-invmgr-oper-99-ydk.py · GitHub

You can invoke it using:

$ ./nc-read-xr-plat-chas-invmgr-oper-99-ydk.py ssh://user:password@host

Hope that help!

View solution in original post

Highlighted
Cisco Employee

Re: YDK tutorial

Hi Santiago,

Thanks a lot, this helps.

We figured it out at the end the filter was wrong, it should be looking like this:

(v)vagrant@vagrant-ubuntu-trusty-64:~/ncc$ python ncc.py --host=1.1.1.1 -u vagrant -p vagrant --get-oper -f '<platform xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-plat-chas-invmgr-oper">'

For BGP Oper as example:

(v)vagrant@vagrant-ubuntu-trusty-64:~/ncc$ python ncc.py --host=1.1.1.1 -u vagrant -p vagrant --get-oper -f "<bgp xmlns='http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-oper'><instances><instance><instance-name>default</instance-name><instance-active><default-vrf><neighbors><neighbor><neighbor-address/></neighbor></neighbors></default-vrf></instance-active></instance></instances></bgp>"

This is much more tedious of cause, but i think it helps to understand how to build a filter.

Cheers

Guan

Highlighted
Cisco Employee

Re: YDK tutorial

IMHO, if you're having to handcraft filters, you're doing it wrong.  The whole YDK purpose is to abstract as much as possible these details.  I agree that at the end it all comes to personal preference.  Glad you got it working.

Highlighted
Cisco Employee

Re: YDK tutorial

thanks Santiago, really appreciated

This widget could not be displayed.