01-29-2018 10:08 AM
Trying to encode the BGP operational object returned from a XRv device but it fails with the below YPYModelError
ydk.errors.YPYModelError: Invalid path: af-data : Failed to resolve uses "DEFAULT-VRF".. Path: /Cisco-IOS-XR-ipv4-bgp-oper:bgp/instances/instance/instance-standby/DEFAULT-VRF
Disconnected from device
The crud.read operation is successful as evident from the ydk.logs (attached).
I am using Yfilter.read to read the full BGP neighbor table in the Cisco_IOS_XR_ipv4_bgp_oper class.
Encode works fine when i read the neighbor object partially by simply reading the neighbor-address or other neighbor properties. Output omitted for brevity.
I have also attached the python snippet for retrieving the neighbor table.
{
"Cisco-IOS-XR-ipv4-bgp-oper:bgp": {
"instances": {
"instance": [
{
"instance-name": "default",
"instance-active": {
"default-vrf": {
"afs": {
"af": [
{
"af-name": "ipv4-unicast",
"neighbor-af-table": {
"neighbor": [
{
"neighbor-address": "172.16.17.7",
"connection-state": "bgp-st-estab"
},
{
"neighbor-address": "172.16.18.8",
"connection-state": "bgp-st-active"
},
{
"neighbor-address": "192.168.0.6",
"connection-state": "bgp-st-estab"
}
]
}
}
]
}
}
}
}
]
}
}
}
Solved! Go to Solution.
02-01-2018 02:25 PM
This looks like a bug.. Opened an issue: XR BGP Oper error with XR 6.1.2 model · Issue #676 · CiscoDevNet/ydk-gen · GitHub
01-29-2018 10:42 AM
Hi Mufaddal,
Can you please let me know your ydk version (output of 'pip list|grep ydk') & XR version?
Thanks
01-29-2018 02:19 PM
Sure, the XRv version is 6.1.2
ydk (0.6.3)
ydk-models-cisco-ios-xr (6.3.1)
ydk-models-ietf (0.1.4)
01-31-2018 11:17 AM
Thanks, Mufaddal. I think the issue maybe because:
from ydk.path import Repository
repo = Repository('<your-home-dir>/.ydk/<your-device-hostname:port>')
codec_provider = CodecServiceProvider(repo=repo, type='json')
codec = CodecService()
print(codec.encode(codec_provider, bgp_obj, pretty=True))
02-01-2018 11:59 AM
Never noticed the .ydk directory in my home dir.
Receiving the same error with the above changes.
Invalid path: af-data
Traceback (most recent call last):
File "lib/bgp/oper.py", line 47, in <module>
print(codec.encode(codec_provider, bgp_obj, pretty=True))
File "/home/ubuntu/.virtualenvs/ydk-py/lib/python3.5/site-packages/ydk/errors/error_handler.py", line 112, in helper
return func(self, provider, entity, *args, **kwargs)
File "/home/ubuntu/.virtualenvs/ydk-py/lib/python3.5/site-packages/ydk/services/codec_service.py", line 74, in encode
return self._encode(provider, entity_holder, pretty, subtree)
File "/home/ubuntu/.virtualenvs/ydk-py/lib/python3.5/site-packages/ydk/services/codec_service.py", line 105, in _encode
return result
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/home/ubuntu/.virtualenvs/ydk-py/lib/python3.5/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
_raise(_exc)
File "/home/ubuntu/.virtualenvs/ydk-py/lib/python3.5/site-packages/ydk/errors/error_handler.py", line 54, in _raise
exec("raise exc from None")
File "<string>", line 1, in <module>
ydk.errors.YPYModelError: Invalid path: af-data : Failed to resolve uses "DEFAULT-VRF".. Path: /Cisco-IOS-XR-ipv4-bgp-oper:bgp/instances/instance/instance-standby/DEFAULT-VRF
Disconnected from device
shell returned 1
02-01-2018 02:25 PM
This looks like a bug.. Opened an issue: XR BGP Oper error with XR 6.1.2 model · Issue #676 · CiscoDevNet/ydk-gen · GitHub
02-02-2018 02:45 AM
Thank you abhirame
04-23-2018 02:39 PM
It looks like the XR 6.1.2 model has an invalid pattern using double quotes, which is causing the error you are seeing. This was fixed in the 621/631 model where it was changed to use single quote. YDK 0.7.1
cannot be used with XR 612. The issue should be fixed if you use a XR 612 or newer device after clearing the cache (rm -rf ~/.ydk). Closed the issue
05-01-2018 08:49 AM
As a workaround, you could try editing the model located in /root/.ydk/*/Cisco-IOS-XR-types.yang
to change the pattern from double quote to single quote
08-27-2018 03:56 AM
you can use command:
for XE
sed -i "s/\"/\'/g" /root/.ydk/*/Cisco-IOS-XE-types.yang
for XR
sed -i "s/\"/\'/g" /root/.ydk/*/Cisco-IOS-XR-types.yang
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