cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2078
Views
0
Helpful
9
Replies

XR BGP Operational

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"

                        }

                      ]

                    }

                  }

                ]

              }

            }

          }

        }

      ]

    }

  }

}

1 Accepted Solution
9 Replies 9

abhirame
Cisco Employee
Cisco Employee

Hi Mufaddal,

Can you please let me know your ydk version (output of 'pip list|grep ydk') & XR version?

Thanks

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)

Thanks, Mufaddal. I think the issue maybe because:

  1. the CRUD read is working because CRUD service connects to the 6.1.2 device and downloads the models. CRUD uses the device models for processing the data
  2. but CODEC is not working, because it is not based on the device models. Instead it is using the models from the ydk-models-cisco-ios-xr python package which is 6.3.1. The models are by default downloaded by CRUD in the directory '<your-home-dir>/.ydk/<your-device-hostname:port>'. So, you could point the CODEC service to these models. Please try the below step to provide the Repository() object pointing to the models from the device:

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))

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

Thank you abhirame

abhirame
Cisco Employee
Cisco Employee

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


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

abhirame
Cisco Employee
Cisco Employee

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

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