cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1003
Views
1
Helpful
7
Replies

BGP Oper Path error

crench92
Spotlight
Spotlight

>>> from ydk.providers import NetconfServiceProvider

>>> from ydk.services import CRUDService

>>> from ydk.models.cisco_ios_xe import Cisco_IOS_XE_bgp_oper as bgp_oper

>>> provider = NetconfServiceProvider(address="192.168.229.250",port=10000,username="admin",password="admin")

>>> crud = CRUDService()

>>> bgp_oper = bgp_oper.BgpStateData.Neighbors()

>>> bgp_oper

<ydk.models.cisco_ios_xe.Cisco_IOS_XE_bgp_oper.Neighbors object at 0x7f8a7eb7b110>

>>> crud.read(provider,bgp_oper)

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/lib64/python2.7/site-packages/ydk/errors/error_handler.py", line 112, in helper

    return func(self, provider, entity, *args, **kwargs)

  File "/usr/lib64/python2.7/site-packages/ydk/services/crud_service.py", line 35, in read

    return self._crud.read(provider, read_filter)

  File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__

    self.gen.throw(type, value, traceback)

  File "/usr/lib64/python2.7/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error

    _raise(_exc)

  File "/usr/lib64/python2.7/site-packages/ydk/errors/error_handler.py", line 56, in _raise

    raise exc

ydk.errors.YPYInvalidArgumentError:  Path is invalid: Cisco-IOS-XE-bgp-oper:bgp-state-data/neighbors

Anyone have any idea what I'm doing wrong here?  I think I have the path correct according to this:

http://ydk.cisco.com/py/docs/gen_doc_ed0e7f5cd40f3bc80e0adca92a7c5a80bb92a26f.html#ydk.models.cisco_ios_xe.Cisco_IOS_XE_…

1 Accepted Solution

Accepted Solutions

I'm able to reproduce your issue on XE 16.5.1. It appears YDK (via libyang) has detected there has been a backward incompatible change in the yang model Cisco-IOS-XE-bgp-oper.yang between XE 16.6.1 and 16.5.1

#sh ve

Cisco IOS XE Software, Version 16.05.01b

Cisco IOS

Software [Everest], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.5.1b, RELEASE SOFTWARE (fc1)

The latest ydk XE bundle is generated for 16.6.1. YDK APIs are purely based on the yang models. So, when a model contains a backward incompatible change, you get such an error. To fix this, you need to generate & use the XE 16.5.1 YDK bundle.

pip uninstall ydk-models-cisco-ios-xe

git clone https://github.com/ciscodevnet/ydk-gen.git -b 0.6.1

cd ydk-gen

./generate --bundle profiles/bundles/cisco-ios-xe_16_5_1.json

pip install gen-api/python/cisco_ios_xe*/dist/ydk*.tar.gz

The incompatible change in the models can be seen here:

  1. yang/Cisco-IOS-XE-bgp-oper.yang at master · YangModels/yang · GitHub
  2. yang/Cisco-IOS-XE-bgp-oper.yang at master · YangModels/yang · GitHub

View solution in original post

7 Replies 7

abhirame
Cisco Employee
Cisco Employee

Hi Brandon,

It looks like you are passing a non-top level container to the crud service. For ydk >0.6.0, when using CRUDService and other services, using a child container or list, which is not the top-level node in a yang model is no longer supported.

For example:

from ydk.models.cisco_ios_xe import Cisco_IOS_XE_bgp_oper as bgp_oper

from ydk.services import CRUDService

from ydk.providers import NetconfServiceProvider

... # connect to provider etc

neighbors = bgp_oper.BgpStateData.Neighbors()

crud.read(provider, neighbors)

now has to be changed to:

from ydk.models.cisco_ios_xe import Cisco_IOS_XE_bgp_oper as bgp_oper

from ydk.services import CRUDService

from ydk.providers import NetconfServiceProvider

... # connect to provider etc

bgp_state = bgp_oper.BgpStateData()

crud.read(provider, bgp_state)

If you try the above, it should work

This backward incompatibility has now been noted in the release notes (https://github.com/CiscoDevNet/ydk-py/releases/tag/0.6.0).

same error:

Python 2.7.5 (default, Nov  6 2016, 00:28:07)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> from ydk.models.cisco_ios_xe import Cisco_IOS_XE_bgp_oper as bgp_oper

>>> from ydk.services import CRUDService

>>> from ydk.providers import NetconfServiceProvider

>>> provider = NetconfServiceProvider(address="192.168.229.250",port=10000,username="admin",password="admin")

>>> neighbors = bgp_oper.BgpStateData()

>>> crud.read(provider, neighbors)

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

NameError: name 'crud' is not defined

>>> crud = CRUDService()

>>> crud.read(provider, neighbors)

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/lib64/python2.7/site-packages/ydk/errors/error_handler.py", line 112, in helper

    return func(self, provider, entity, *args, **kwargs)

  File "/usr/lib64/python2.7/site-packages/ydk/services/crud_service.py", line 35, in read

    return self._crud.read(provider, read_filter)

  File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__

    self.gen.throw(type, value, traceback)

  File "/usr/lib64/python2.7/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error

    _raise(_exc)

  File "/usr/lib64/python2.7/site-packages/ydk/errors/error_handler.py", line 56, in _raise

    raise exc

ydk.errors.YPYInvalidArgumentError:  Path is invalid: Cisco-IOS-XE-bgp-oper:bgp-state-data

Can you enable logging <http://ydk.cisco.com/py/docs/guides/introduction.html#logging> before doing the crud.read() and post the logs?

Also, can you verify if your device support this yang model (it should be documented / advertise it in netconf capabilities)?

[root@HTENNOCDDAT01 ~]# python3.6

Python 3.6.2 (default, Jul 18 2017, 22:59:34)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> from ncclient import manager

>>> HOST = '192.168.229.250'

>>> PORT = 10000

>>> USER = 'admin'

>>> PASS = 'admin'

>>> with manager.connect(host=HOST, port=PORT, username=USER, password=PASS, hos                    tkey_verify=False,device_params={'name':'default'}, look_for_keys=False, allow_agent=False) as m:

...     for capability in m.server_capabilities:

...             print(capability.split('?')[0])

...

(output cut)

http://cisco.com/ns/yang/Cisco-IOS-XE-bgp-oper

[root@HTENNOCDDAT01 ~]# python

Python 2.7.5 (default, Nov  6 2016, 00:28:07)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> from ydk.models.cisco_ios_xe import Cisco_IOS_XE_bgp_oper as bgp_oper

>>> from ydk.services import CRUDService

>>> from ydk.providers import NetconfServiceProvider

>>> provider = NetconfServiceProvider(address="192.168.229.250",port=10000,username="admin",password="admin")

>>> import logging

>>> log = logging.getlogger('ydk')

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

AttributeError: 'module' object has no attribute 'getlogger'

>>> log = logging.getLogger('ydk')

>>> log.setLevel(logging.INFO)

>>> handler = logging.StreamHandler()

>>> log.addHandler(handler)

>>> neighbors = bgp_oper.BgpStateData()

>>> crud = CRUDService()

>>> crud.read(provider, neighbors)

Executing CRUD read operation

Libyang ERROR: Schema node not found. Path: '/Cisco-IOS-XE-bgp-oper:bgp-state-data'

Path 'Cisco-IOS-XE-bgp-oper:bgp-state-data' is invalid

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/lib64/python2.7/site-packages/ydk/errors/error_handler.py", line 112, in helper

    return func(self, provider, entity, *args, **kwargs)

  File "/usr/lib64/python2.7/site-packages/ydk/services/crud_service.py", line 35, in read

    return self._crud.read(provider, read_filter)

  File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__

    self.gen.throw(type, value, traceback)

  File "/usr/lib64/python2.7/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error

    _raise(_exc)

  File "/usr/lib64/python2.7/site-packages/ydk/errors/error_handler.py", line 56, in _raise

    raise exc

ydk.errors.YPYInvalidArgumentError:  Path is invalid: Cisco-IOS-XE-bgp-oper:bgp-state-data

>>> exit()

Disconnected from device

Disconnected from device

[root@HTENNOCDDAT01 ~]# pip list | grep ydk

ydk (0.6.1)

ydk-models-cisco-ios-xe (16.6.1.post1)

ydk-models-cisco-ios-xr (6.3.1)

ydk-models-ietf (0.1.4)

ydk-models-openconfig (0.1.4)

Seems to be an issue with Libyang

I'm able to reproduce your issue on XE 16.5.1. It appears YDK (via libyang) has detected there has been a backward incompatible change in the yang model Cisco-IOS-XE-bgp-oper.yang between XE 16.6.1 and 16.5.1

#sh ve

Cisco IOS XE Software, Version 16.05.01b

Cisco IOS

Software [Everest], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.5.1b, RELEASE SOFTWARE (fc1)

The latest ydk XE bundle is generated for 16.6.1. YDK APIs are purely based on the yang models. So, when a model contains a backward incompatible change, you get such an error. To fix this, you need to generate & use the XE 16.5.1 YDK bundle.

pip uninstall ydk-models-cisco-ios-xe

git clone https://github.com/ciscodevnet/ydk-gen.git -b 0.6.1

cd ydk-gen

./generate --bundle profiles/bundles/cisco-ios-xe_16_5_1.json

pip install gen-api/python/cisco_ios_xe*/dist/ydk*.tar.gz

The incompatible change in the models can be seen here:

  1. yang/Cisco-IOS-XE-bgp-oper.yang at master · YangModels/yang · GitHub
  2. yang/Cisco-IOS-XE-bgp-oper.yang at master · YangModels/yang · GitHub

I would like to add that I needed the following modules installed as well:

pip install gitpython

pip install pyang

pip install rstr

pip install jinja2

I also needed to add ".py" to the end of ./generate on line 4 of the solution

I now have the following error:

[root@HTENNOCDDAT01 ydk-gen]# ./generate.py --bundle profiles/bundles/cisco-ios-xe_16_5_1.json

Traceback (most recent call last):

  File "./generate.py", line 369, in <module>

    options.one_class_per_module).generate(options.bundle))

  File "/root/ydk-gen/ydkgen/__init__.py", line 91, in generate

    return self._generate_bundle(description_file)

  File "/root/ydk-gen/ydkgen/__init__.py", line 117, in _generate_bundle

    packages = self._get_packages(curr_bundle.resolved_models_dir)

  File "/root/ydk-gen/ydkgen/__init__.py", line 163, in _get_packages

    packages = ApiModelBuilder(self.iskeyword, self.language).generate(modules)

  File "/root/ydk-gen/ydkgen/builder/_api_model_builder.py", line 70, in generate

    self._resolve_expanded_cross_references(package)

  File "/root/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/root/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/root/ydk-gen/ydkgen/builder/_api_model_builder.py", line 147, in _resolve_expanded_cross_references

    self._resolve_expanded_cross_references(owned_element)

  File "/root/ydk-gen/ydkgen/builder/_api_model_builder.py", line 131, in _resolve_expanded_cross_references

    if not hasattr(identity_ref_type.i_type_spec.base.i_identity, 'i_class'):

AttributeError: 'NoneType' object has no attribute 'i_identity'

EDIT:

I resolved this issue from feedback in this thread - Help needed debugging API compilation errors from ydk-gen by uninstalling pyang1.7 and installing pyang1.6

Glad  you got it to work.  Let me clarify that the README file has the instructions to intsall the requirements using:

$ pip install -r requirements.txt

The requirements are documented at:

ydk-gen/requirements.txt at master · CiscoDevNet/ydk-gen · GitHub

Some of the packages you referenced are actually optional.  If you think the requirements file is missing packages, please let us know. Thanks.