cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
464
Views
1
Helpful
3
Replies
jaadelma
Cisco Employee

Issue with YDK openconfig-network-instances: the escape sequence "\." is unsafe in double quoted strings

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:


  1. # Cisco Imports
  2. from ydk.models.openconfig import openconfig_bgp
  3. from ydk.services import CRUDService
  4. from ydk.providers import NetconfServiceProvider
  5. from ydk.models.openconfig import openconfig_bgp as oc_bgp
  6. from ydk.models.openconfig import openconfig_bgp_types as oc_bgp_types
  7. from ydk.models.openconfig import openconfig_network_instance as oc_net
  8. from ydk.models.openconfig import openconfig_policy_types
  9. from ydk.path import Repository
  10. # Attach to the YDK Logger
  11. import logging
  12. logger = logging.getLogger("ydk")
  13. logger.setLevel(logging.DEBUG)
  14. handler = logging.StreamHandler()
  15. formatter = logging.Formatter(
  16.     ("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
  17. handler.setFormatter(formatter)
  18. logger.addHandler(handler)
  19. # Populate the instance model for BGP
  20. instances = oc_net.NetworkInstances()
  21. instance = instances.NetworkInstance()
  22. instance.name = 'default'
  23. protocol = instance.protocols.Protocol()
  24. protocol.config.name = 2
  25. protocol.config.identifier = openconfig_policy_types.BGP()
  26. protocol.bgp.global_.config.router_id = '3.3.3.2'
  27. protocol.bgp.global_.config.as_ = 65002
  28. instance.protocols.protocol.append(protocol)
  29. instances.network_instance.append(instance)
  30. # Create provider
  31. provider = NetconfServiceProvider(address=ip, port=830, username='admin', password='<whatever>', protocol='ssh')
  32. # Create CRUD
  33. crud = CRUDService()
  34. # Apply the model
  35. result = crud.create(provider, instances)
  36. print("Done!")
1 ACCEPTED SOLUTION

Accepted Solutions
abhirame
Cisco Employee

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]|'

View solution in original post

3 REPLIES 3
abhirame
Cisco Employee

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]|'

View solution in original post

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?

The yang models are owned by the openconfig project. You could check there:

https://github.com/openconfig/public

Create
Recognize Your Peers
Content for Community-Ad