cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
890
Views
0
Helpful
2
Replies

Data is invalid according to the yang model.

IBMeR
Level 1
Level 1

I'm tring to create IPIP or GRE tunnel:
tunnel=native.interface.Tunnel()
tunnel.name=999
tunnel.description="test123"
tunnel.vrf.forwarding="Stateful"
tunnel.ip.address.primary.address="192.168.206.206"
tunnel.ip.address.primary.mask="255.255.255.252"
tunnel.ip.tcp.adjust_mss=1360
tunnel.tunnel.source="Loopback0"
destination=tunnel.Tunnel_.Destination()
destination.ipaddress_or_host="8.8.8.8"

tunnel.tunnel.destination=destination
tunnel.tunnel.mode.ipip=tunnel.tunnel.mode.Ipip()
native.interface.tunnel.append(tunnel)
crud.create(provider,tunnel)

 

And receive error like it:

 

2019-01-09 19:49:28,180 - ydk - INFO - Path where models are to be downloaded: /xxx/
2019-01-09 19:49:28,189 - ydk - INFO - Connected to x.x.x.x on port 830 using ssh with timeout of -1
2019-01-09 19:49:28,607 - ydk - INFO - Executing CRUD create operation on [Tunnel[name='999']]
2019-01-09 19:49:28,712 - ydk - ERROR - Data is invalid according to the yang model. Libyang error: Invalid value "" in "destination" element. Path: '/Cisco-IOS-XE-native:native/interface/Tunnel[name='999']/Cisco-IOS-XE-tunnel:tunnel/destination'
Traceback (most recent call last):
File "./createtunnel.py", line 66, in <module>
crud.create(provider,tunnel)
File "/usr/local/lib/python2.7/dist-packages/ydk/errors/error_handler.py", line 112, in helper
return func(self, provider, entity, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/ydk/services/crud_service.py", line 49, in create
return self._crud.create(provider, entity)
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python2.7/dist-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
_raise(_exc)
File "/usr/local/lib/python2.7/dist-packages/ydk/errors/error_handler.py", line 56, in _raise
raise exc
ydk.errors.YModelError: Invalid value "" in "destination" element. Path: /Cisco-IOS-XE-native:native/interface/Tunnel[name='999']/Cisco-IOS-XE-tunnel:tunnel/destination

Am I doing anything wrong or is it bug?

 

libyang=0.8.0

models for ios_xe=16.9.1

ios_xe=16.06.04

1 Accepted Solution

Accepted Solutions

ygorelik
Cisco Employee
Cisco Employee
Hello IBMeR
I built a test based on your script, but could not reproduce the issue with YDK-0.8.0 and cisco-ios-xe 16.8.1 model bundle. I only can assume that model bundle that you are using and device are not fully compatible. I need more details of your environment to make the judgement.
FYI
My test script
from __future__ import absolute_import
import logging
from argparse import ArgumentParser
from ydk.providers import CodecServiceProvider
from ydk.services import CodecService

from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native

def enable_logging(level):
log = logging.getLogger('ydk')
log.setLevel(level)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
handler.setFormatter(formatter)
log.addHandler(handler)

def build_tunnel(native):
tunnel=native.interface.Tunnel()
tunnel.name=999
tunnel.description="test123"
tunnel.vrf.forwarding="Stateful"
tunnel.ip.address.primary.address="192.168.206.206"
tunnel.ip.address.primary.mask="255.255.255.252"
tunnel.ip.tcp.adjust_mss=1360
tunnel.tunnel.source="Loopback0"

destination=tunnel.Tunnel_.Destination()
destination.ipaddress_or_host="8.8.8.8"
tunnel.tunnel.destination=destination

tunnel.tunnel.mode.ipip=tunnel.tunnel.mode.Ipip()
native.interface.tunnel.append(tunnel)

if __name__ == "__main__":
"""Execute main program."""
parser = ArgumentParser()
parser.add_argument("-v", "--verbose", help="print debugging messages", action="store_true")
args = parser.parse_args()

# log debug messages if verbose argument specified
if args.verbose:
enable_logging(logging.DEBUG)

# create codec provider and service
provider = CodecServiceProvider(type="xml")
codec = CodecService()

The run results
yan@ubuntu-yan:~/ydk-workspace/ydk-gen$ python ./scripts/tests/test_xe_tunnel.py



999
test123

Stateful




192.168.206.206

255.255.255.252



1360



Loopback0

8.8.8.8









Initial and Decoded entities are equal
yan@ubuntu-yan:~/ydk-workspace/ydk-gen$ pip list | grep ydk
ydk (0.8.1)
ydk-models-cisco-ios-xe (16.9.1)
ydk-models-cisco-ios-xr (6.5.1.post1)
ydk-models-ietf (0.1.5.post2)

View solution in original post

2 Replies 2

ygorelik
Cisco Employee
Cisco Employee
Hello IBMeR
I built a test based on your script, but could not reproduce the issue with YDK-0.8.0 and cisco-ios-xe 16.8.1 model bundle. I only can assume that model bundle that you are using and device are not fully compatible. I need more details of your environment to make the judgement.
FYI
My test script
from __future__ import absolute_import
import logging
from argparse import ArgumentParser
from ydk.providers import CodecServiceProvider
from ydk.services import CodecService

from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native

def enable_logging(level):
log = logging.getLogger('ydk')
log.setLevel(level)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
handler.setFormatter(formatter)
log.addHandler(handler)

def build_tunnel(native):
tunnel=native.interface.Tunnel()
tunnel.name=999
tunnel.description="test123"
tunnel.vrf.forwarding="Stateful"
tunnel.ip.address.primary.address="192.168.206.206"
tunnel.ip.address.primary.mask="255.255.255.252"
tunnel.ip.tcp.adjust_mss=1360
tunnel.tunnel.source="Loopback0"

destination=tunnel.Tunnel_.Destination()
destination.ipaddress_or_host="8.8.8.8"
tunnel.tunnel.destination=destination

tunnel.tunnel.mode.ipip=tunnel.tunnel.mode.Ipip()
native.interface.tunnel.append(tunnel)

if __name__ == "__main__":
"""Execute main program."""
parser = ArgumentParser()
parser.add_argument("-v", "--verbose", help="print debugging messages", action="store_true")
args = parser.parse_args()

# log debug messages if verbose argument specified
if args.verbose:
enable_logging(logging.DEBUG)

# create codec provider and service
provider = CodecServiceProvider(type="xml")
codec = CodecService()

The run results
yan@ubuntu-yan:~/ydk-workspace/ydk-gen$ python ./scripts/tests/test_xe_tunnel.py



999
test123

Stateful




192.168.206.206

255.255.255.252



1360



Loopback0

8.8.8.8









Initial and Decoded entities are equal
yan@ubuntu-yan:~/ydk-workspace/ydk-gen$ pip list | grep ydk
ydk (0.8.1)
ydk-models-cisco-ios-xe (16.9.1)
ydk-models-cisco-ios-xr (6.5.1.post1)
ydk-models-ietf (0.1.5.post2)

Thank you.

You was right.

After upgrade IOS on router problem has solved.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: