cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1256
Views
1
Helpful
5
Replies

get_config error

kegrozis
Level 4
Level 4

Hi,

I'm a newbie to YDK.  I'm trying to pull the configurations from XRv instances using ydk.services.NetconfService.get_config.  However, I'm not correctly entering my attributes.  Provider is self explanatory, but I keep getting errors on 'source' and 'get_filter'.  Can you provide additional details on this method or an example?

get_config(provider, source, get_filter, with_defaults_option=None)

Execute a get-config operation to retrieve all or part of a specified configuration.

Parameters:
  • get_filter – Subtree or XPath filter to use
  • source – Particular configuration to retrieve
  • with_defaults – The explicit defaults processing mode requested

Thanks,

-Kevin

1 Accepted Solution

Accepted Solutions

saalvare
Cisco Employee
Cisco Employee

Kevin,

You can find an example at:

nc-get-config-xr-ip-domain-cfg-99-ydk.py · GitHub

That app uses NETCONF service to get DNS config.  Currently, you have to retrieve the configuration one model at a time. We're already tracking the enhancement to allow users to read the entire config (no filter):

Proposal for YDK read/write API · Issue #255 · CiscoDevNet/ydk-gen · GitHub

We were also tracking improvements to the documentation of services.  Several enhancements have been committed and will be generally available in the next YDK-PY release:

Revise service documentation · Issue #239 · CiscoDevNet/ydk-gen · GitHub

If you're new to YDK, you may want to consider the CRUD service first.  You also have to retrieve the configuration one model at a time, but that service will abstract a lot of the NETCONF details for you.  You can find the CRUD equivalent to read DNS config at:

ydk-py-samples/nc-read-xr-ip-domain-cfg-10-ydk.py at master · CiscoDevNet/ydk-py-samples · GitHub

That app is a boilerplate, you need to uncomment line 78 and implement 'process_ip_domain'.  You can find an example of an app using the CRUD service to read hostname configuration and processing the object to provide human-readable output at:

ydk-py-samples/nc-read-xr-shellutil-cfg-20-ydk.py at master · CiscoDevNet/ydk-py-samples · GitHub

Hope that helps!

View solution in original post

5 Replies 5

saalvare
Cisco Employee
Cisco Employee

Kevin,

You can find an example at:

nc-get-config-xr-ip-domain-cfg-99-ydk.py · GitHub

That app uses NETCONF service to get DNS config.  Currently, you have to retrieve the configuration one model at a time. We're already tracking the enhancement to allow users to read the entire config (no filter):

Proposal for YDK read/write API · Issue #255 · CiscoDevNet/ydk-gen · GitHub

We were also tracking improvements to the documentation of services.  Several enhancements have been committed and will be generally available in the next YDK-PY release:

Revise service documentation · Issue #239 · CiscoDevNet/ydk-gen · GitHub

If you're new to YDK, you may want to consider the CRUD service first.  You also have to retrieve the configuration one model at a time, but that service will abstract a lot of the NETCONF details for you.  You can find the CRUD equivalent to read DNS config at:

ydk-py-samples/nc-read-xr-ip-domain-cfg-10-ydk.py at master · CiscoDevNet/ydk-py-samples · GitHub

That app is a boilerplate, you need to uncomment line 78 and implement 'process_ip_domain'.  You can find an example of an app using the CRUD service to read hostname configuration and processing the object to provide human-readable output at:

ydk-py-samples/nc-read-xr-shellutil-cfg-20-ydk.py at master · CiscoDevNet/ydk-py-samples · GitHub

Hope that helps!

Hi Santiago,

I tried nc-get-config-xr-ip-domain-99-ydk.py, but I am not able to get this script to run properly.

I condensed the script to the following:

from ydk.services import NetconfService, Datastore

from ydk.providers import NetconfServiceProvider

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ip_domain_cfg \

    as xr_ip_domain_cfg

provider = NetconfServiceProvider(address="10.82.79.35",

                                      port=830,

                                      username="cisco",

                                      password="cisco",

                                      protocol="ssh")

netconf = NetconfService()

ip_domain = xr_ip_domain_cfg.IpDomain() 

ip_domain = netconf.get_config(provider, Datastore.running, ip_domain)

provider.close()

exit()

======

I'm getting the following traceback:

Traceback (most recent call last):

  File "/Users/kgrozis/Docker/netconf/bin/get-config-xr-ip-domain", line 15, in <module>

    ip_domain = netconf.get_config(provider, Datastore.running, ip_domain)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ydk/services/netconf_service.py", line 311, in get_config

    return provider.decode(payload_convert(payload), None)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ydk/services/netconf_service.py", line 469, in payload_convert

    return etree.tostring(chchs[0], pretty_print=True, encoding='utf-8').decode('utf-8')

IndexError: list index out of range

=======

I'm using the following software:

- XRv9K: 6.1.1

- YDK: .5.1

- python: 2.7.11

- MacOS

I am able to get other scripts to run like hello-ydk.py.

Any suggestions?

Thanks,

Kevin

Kevin,

this seems like a bug in YDK. Apparently, it tries to validate the config even though it is non-existant.  Try adding some config with any of the nc-create* apps at

ydk-py-samples/samples/basic/crud/models/cisco-ios-xr/Cisco-IOS-XR-ip-domain-cfg at master · CiscoDevNet/ydk-py-samples …

Then, nc-get-config-xr-ip-domain-99-ydk.py should run fine. I'll confirm the bug and file the YDK.  Thanks.

Kevin,

YDK issue tracked at:

https://github.com/CiscoDevNet/ydk-gen/issues/305

Thanks for bringing attention to this.

kegrozis
Level 4
Level 4

Thanks Santiago for the quick response!  This is great information, and will help me get up to speed quickly.

Kevin