03-13-2018 01:37 PM
I have been playing with YDK for a few hours. Going through the hello world examples, etc. So far, all I have been able to accomplish is to query the hostname and the system uptime. I’m fumbling a bit through the API docs and need some guidance.
For example, I found these sample apps:
https://github.com/CiscoDevNet/ydk-py-samples
Good stuff! Specifically, I’m trying this one:
My assumption is that this script will retrieve the ARP table. When I run it:
(ydk-demo) <username removed>@dev01:~/ydk-demo/ydk-py-samples/samples/basic/crud/models/cisco-ios-xr/Cisco-IOS-XR-ipv4-arp-cfg$ ./nc-read-xr-ipv4-arp-cfg-10-ydk.py ssh://<username removed>:<password removed>@10.238.69.81 -v
2018-03-13 15:59:26,748 - ydk - INFO - Path where models are to be downloaded: /home/<username removed>/.ydk/10.238.69.81:830
2018-03-13 15:59:26,757 - ydk - INFO - Connected to 10.238.69.81 on port 830 using ssh with timeout of -1
2018-03-13 15:59:26,758 - ydk - INFO - Disconnected from device
Ok, so I now have 2 yang files downloaded in my .ydk directory:
But, if I am reading the YDK documentation correctly, I don’t have to know the underlying YANG…and I it’s all abstracted away correct? I should only really need to understand the Python API. For example:
http://ydk.cisco.com/py/docs/gen_doc_1ee0ee77c880dbc1fb38340e87116a2112e2860f.html
I sorta get the CRUD service….it creates the object after you import the Python module for what you want to do, etc. The NetconfServiceProvider is used for connectivity to the end device. After I run this app, I have an arp object…and this function allows me to manipulate it.
def process_arp(arp):
"""Process data in arp object."""
Pass
So it’s probably more a of Python question perhaps, but I’d like to view the contents of that arp Python object. How do I do that? Any light you can shed would be great.
Thanks!
Solved! Go to Solution.
03-13-2018 01:47 PM
You can walk through the data structure returned by the CRUD read. I think the sample you are trying has the CRUD read commented out (line 78) as it is meant to be a sort of template.
This is a different example which actually reads the data from CRUD read and process the output. Please refer to this sample and combine it with looking at the documentation for this model.
Hope this helps
03-13-2018 01:47 PM
You can walk through the data structure returned by the CRUD read. I think the sample you are trying has the CRUD read commented out (line 78) as it is meant to be a sort of template.
This is a different example which actually reads the data from CRUD read and process the output. Please refer to this sample and combine it with looking at the documentation for this model.
Hope this helps
03-13-2018 04:59 PM
If you want to retrieve the ARP table, you should be looking at the operational model (Cisco-IOS-XR-ipv4-arp-oper). Here's a boilerplate app you can use to read and process the ARP table:
https://gist.github.com/111pontes/c5d17f561f735626eda5ceba0523bee4
You can read the data with logging enabled:
$ ./nc-read-xr-ipv4-arp-oper-30-ydk.py ssh://user:pass@host -v
and use the API documentation for that model to figure out the fields you're interested in.
You can find an example of an app that reproduces an ISIS show command at:
The app needs to be patched to work with the latest YDK version, but it'd give you an idea of how to start. Let us know if you need further help.bv
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: