05-18-2018 09:51 AM
Issue: Unable to use openconfig-network-instance model in ydk.models on IOSXEv using YDK 0.7.1 and ydk-models-openconfig==0.1.5. It seems to be failing due to usage of "./" in models/yang/vendor/cisco/xe/1681/openconfig-network-instance-types.yang.
Platform / DUT:
Cisco IOS XE Software, Version 16.08.01a
Cisco IOS Software [Fuji], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.8.1a, RELEASE SOFTWARE (fc1)
Error Observed:
2018-05-18 15:21:32,308 - ydk - ERROR - Data is invalid according to the yang model. Error details: Invalid keyword "[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|"".
2018-05-18 15:21:32,308 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module "openconfig-vlan-types" parsing failed.
2018-05-18 15:21:32,308 - ydk - ERROR - Data is invalid according to the yang model. Error details: Importing "openconfig-vlan-types" module into "openconfig-vlan" failed.
2018-05-18 15:21:32,309 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module "openconfig-vlan" parsing failed.
2018-05-18 15:21:32,309 - ydk - ERROR - Data is invalid according to the yang model. Error details: Importing "openconfig-vlan" module into "openconfig-network-instance" failed.
2018-05-18 15:21:32,309 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module "openconfig-network-instance" parsing failed.
2018-05-18 15:21:32,310 - ydk - ERROR - Data is invalid according to the yang model. Error details: Importing "openconfig-network-instance" module into "cisco-xe-openconfig-network-instance-deviation" failed.
2018-05-18 15:21:32,310 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module "cisco-xe-openconfig-network-instance-deviation" parsing failed.
2018-05-18 15:21:32,310 - ydk - DEBUG - Looking to populate schemas for
2018-05-18 15:21:32,310 - ydk - DEBUG - Ready to populate schemas for
2018-05-18 15:21:32,311 - ydk - DEBUG - Getting new modules for
2018-05-18 15:21:32,311 - ydk - DEBUG - Getting new modules for
2018-05-18 15:21:32,311 - ydk - DEBUG - Creating root data node with path '/openconfig-network-instance:network-instances'
2018-05-18 15:21:32,311 - ydk - ERROR - Data is invalid according to the yang model. Error details: Module not found. Path: '/openconfig-network-instance'
2018-05-18 15:21:32,311 - ydk - ERROR - Path 'openconfig-network-instance:network-instances' is invalid
Traceback (most recent call last):
File "lab/src/lab8_m4.py", line 51, in <module>
result = crud.create(provider, instances)
File "/usr/lib64/python3.6/site-packages/ydk/errors/error_handler.py", line 112, in helper
return func(self, provider, entity, *args, **kwargs)
File "/usr/lib64/python3.6/site-packages/ydk/services/crud_service.py", line 49, in create
return self._crud.create(provider, entity)
File "/usr/lib64/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib64/python3.6/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
_raise(_exc)
File "/usr/lib64/python3.6/site-packages/ydk/errors/error_handler.py", line 54, in _raise
exec("raise exc from None")
File "<string>", line 1, in <module>
Script Sample:
- # Cisco Imports
- from ydk.models.openconfig import openconfig_bgp
- from ydk.services import CRUDService
- from ydk.providers import NetconfServiceProvider
- from ydk.models.openconfig import openconfig_bgp as oc_bgp
- from ydk.models.openconfig import openconfig_bgp_types as oc_bgp_types
- from ydk.models.openconfig import openconfig_network_instance as oc_net
- from ydk.models.openconfig import openconfig_policy_types
- from ydk.path import Repository
- # Attach to the YDK Logger
- import logging
- logger = logging.getLogger("ydk")
- logger.setLevel(logging.DEBUG)
- handler = logging.StreamHandler()
- formatter = logging.Formatter(
- ("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
- handler.setFormatter(formatter)
- logger.addHandler(handler)
- # Populate the instance model for BGP
- instances = oc_net.NetworkInstances()
- instance = instances.NetworkInstance()
- instance.name = 'default'
- protocol = instance.protocols.Protocol()
- protocol.config.name = 2
- protocol.config.identifier = openconfig_policy_types.BGP()
- protocol.bgp.global_.config.router_id = '3.3.3.2'
- protocol.bgp.global_.config.as_ = 65002
- instance.protocols.protocol.append(protocol)
- instances.network_instance.append(instance)
- # Create provider
- provider = NetconfServiceProvider(address=ip, port=830, username='admin', password='<whatever>', protocol='ssh')
- # Create CRUD
- crud = CRUDService()
- # Apply the model
- result = crud.create(provider, instances)
- print("Done!")
Solved! Go to Solution.
05-18-2018 10:19 AM
This issue has to be ultimately fixed in the yang model.
As a temporary workaround, you can edit the yang files in the below directory to change these problematic statements to change from using double quote to single quote:
~/.ydk/<hostname_port>
"[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|"
to
'[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|'
05-18-2018 10:19 AM
This issue has to be ultimately fixed in the yang model.
As a temporary workaround, you can edit the yang files in the below directory to change these problematic statements to change from using double quote to single quote:
~/.ydk/<hostname_port>
"[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|"
to
'[1-9][0-9]{1,2}|[1-9])\.\.(409[0-4]|'
05-18-2018 10:27 AM
Ok. So changing that there fixes that issue, but then turns out openconfig-vlan-types.yang has the same problem in about 12 locations. I fixed all those and now am able to move on to different failures.
Do we need to file a bug somewhere, and who should own it?
05-18-2018 10:36 AM
The yang models are owned by the openconfig project. You could check there:
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