โ12-08-2017 02:08 PM
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
Solved! Go to Solution.
โ12-14-2017 11:55 AM
Guan,
Regarding your original question, the NANOG 68 YDK talk will give you a bit of a tutorial:
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!
โ12-11-2017 02:50 PM
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
โ12-11-2017 04:33 PM
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
โ12-12-2017 12:57 AM
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
โ12-12-2017 02:47 AM
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?
โ12-12-2017 04:17 AM
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
โ12-14-2017 11:55 AM
Guan,
Regarding your original question, the NANOG 68 YDK talk will give you a bit of a tutorial:
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!
โ12-14-2017 02:25 PM
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
โ12-14-2017 04:56 PM
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.
โ12-18-2017 10:40 AM
thanks Santiago, really appreciated
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