Trying to pull the configurations from XRv instances using ydk.services.NetconfService.get_config. However,not correctly entering my attributes. Provider is self explanatory, but keep getting errors on 'source' and 'get_filter'.
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: |
|
---|
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
- Tried nc-get-config-xr-ip-domain-99-ydk.py, but not able to get this script to run properly.
- Have 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
=======
using the following software:
- XRv9K: 6.1.1
- YDK: .5.1
- python: 2.7.11
- MacOS
Able to get other scripts to run like hello-ydk.py.
This seems like a bug in YDK. Apparently, it tries to validate the config even though it is non-exist ant. Try adding some config with any of the nc-create* apps at
Then, nc-get-config-xr-ip-domain-99-ydk.py should run fine. I'll confirm the bug and file the YDK. Thanks.
Comments
0 comments
Please sign in to leave a comment.