04-10-2017 01:18 AM
Hi Experts
I found two errors when try to delete config:
1.
When I tried to delete a neighbor in router BGP, an error occured:
File "/Users/Muyiwhy/Documents/workspace/ydk_bgp/backend/util.py", line 56, in delete
crud.delete(provider, object)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/services/crud_service.py", line 87, in delete
self._execute_crud_operation_on_provider(provider, entity, 'DELETE', False)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/services/crud_service.py", line 166, in _execute_crud_operation_on_provider
only_config
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/providers/netconf_provider.py", line 88, in encode
return self.sp_instance.encode(entity, operation, only_config)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 112, in encode
root = self._encode_edit_request(root, entity, operation)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 432, in _encode_edit_request
root = self._create_preamble(entity, root)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 496, in _create_preamble
return self._encode_parents_of_root(root, parent_meta_tuple_list, parent_ns)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 506, in _encode_parents_of_root
root = self._encode_items(root, parent, meta_info)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 542, in _encode_items
self._encode_empty(root, entity, member)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/providers/_provider_plugin.py", line 546, in _encode_empty
entity_ns = entity.i_meta.namespaces
AttributeError: '_MetaInfoClass' object has no attribute 'namespaces'
I've tried XRV6.1.2 with YDK6.1.2 and XRV6.1.3 with YDK6.2.1. The error come up in both enviroment.
I change the code in _provider_plugin.py line 546 to
def _encode_empty(self, root, entity, member):
try:
entity_ns = entity.i_meta.namespaces
except:
entity_ns = None
empty_ns = _yang_ns._namespaces[member.module_name]
NSMAP = {}
if entity_ns is not None and entity_ns != empty_ns:
NSMAP[None] = empty_ns
member_elem = etree.SubElement(root, member.name, nsmap=NSMAP)
and the error disappered. I'm not sure if there are any risk in this.
2.
When I try to delete a community-set, an error occured:
File "/Users/Muyiwhy/Documents/workspace/ydk_bgp/backend/util.py", line 56, in delete
crud.delete(provider, object)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/services/crud_service.py", line 86, in delete
MetaService.normalize_meta(provider._get_capabilities(), entity)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/services/meta_service.py", line 67, in normalize_meta
deviation_tables = MetaService.get_active_deviation_tables(capabilities, entity)
File "/Users/Muyiwhy/virtualenv/ydk_new/lib/python2.7/site-packages/ydk/services/meta_service.py", line 87, in get_active_deviation_tables
module = importlib.import_module('ydk.models._deviate._%s' % pname)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
This error only happend in XRV6.1.3 with YDK6.2.1, didn't happend in XRV6.1.2 with YDK6.1.2.
I change the code in meta_service.py line 87 to
def get_active_deviation_tables(cls, capabilities, entity):
""" Return active deviation tables
Args:
cls: First argument for class method
capabilities: List of capabilities get from provider
enttiy: An instance of YDk object
Returns:
deviation_tables: A dictionary for deviation tables
"""
active_pmodule_names = _get_active_deviation_module_names(capabilities, entity)
deviation_tables = {}
for pname in active_pmodule_names:
try:
module = importlib.import_module('ydk.models._deviate._%s' % pname)
deviation_table = getattr(module, '_deviation_table')
deviation_tables[pname] = deviation_table
except:
continue
return deviation_tables
and the error disappered.
Is there a way to solve these error without changing the source code?
04-10-2017 09:29 AM
Hi Haoyu,
For the first error, I think it is a bug(maybe a typo, see here), sorry about that.
For the second error:
This error only happend in XRV6.1.3 with YDK6.2.1, didn't happend in XRV6.1.2 with YDK6.1.2.
I guess YDK6.2.1(I guess you are referring to this pypi package) is missing deviation models advertised in XRV6.1.3, maybe a better way to solve this issue is to generate and install a Python package for XRV6.1.3 with a profile file specific for this device(for example 6.2.1 profile file is for XRV6.2.1, and it uses YANG models published for XRV6.2.1, and is used to generate YDK6.2.1). Once you have a 6.1.3 profile, you could follow steps in ydk-gen repository, generate package then install package for 6.1.3(maybe in a different environment):
ydk-gen $ ./generate.py --bundle profiles/bundle/cisco-ios-xr_6_1_3.json
ydk-gen $ pip install gen-api/python/cisco_ios_xr-bundle/dist/ydk*.gz
Let me know if it works for two errors above.
04-10-2017 06:27 PM
Thanks for your response. I will test the solution and see if it works for us.
04-10-2017 12:28 PM
The second issue should correspond to:
04-10-2017 06:27 PM
Thanks for your response. I will test the solution and see if it works for us.
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