CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
137 stars 74 forks source link

Better error message for type mismatch #241

Closed ganesh-karthick closed 8 years ago

ganesh-karthick commented 8 years ago

Assigning wrong type to enum generates a cryptic error message from ydk

code :

from ydk.models.Cisco_IOS_XR_telemetry_model_driven_cfg import TelemetryModelDriven import mdt_cfg

        dg = mdt_cfg.DestinationGroups.DestinationGroup()
        dg.destination_id = destgroupid
        d = mdt_cfg.DestinationGroups.DestinationGroup.Destinations.Destination()
        d.address_family = AfEnum.IPV4
        a = .Destinations.Destination.Ipv4()
        a.encoding = enc
        a.destination_port = dest_port
        a.ipv4_address = dest_addr
        a.protocol = <anystring>

Log:

Traceback (most recent call last):
  File "/Users/ganeraje/Documents/git/TelemetryConfig/test/xr_telemetry_test.py", line 47, in test_1create_destinationgroup
    destination_transport)
  File "/Users/ganeraje/Documents/git/TelemetryConfig/src/telemetry/ydk/native/xr_telemetry.py", line 96, in xr_create_destination_group
    self.crudService.create(self.serviceProvider,dg)
  File "/Users/ganeraje/Documents/git/ydk-mdt/python/ydk-py/lib/python2.7/site-packages/ydk/services/crud_service.py", line 61, in create
    MetaService.normalize_meta(provider._get_capabilities(), entity)
  File "/Users/ganeraje/Documents/git/ydk-mdt/python/ydk-py/lib/python2.7/site-packages/ydk/services/meta_service.py", line 52, in normalize_meta
    MetaService.inject_imeta(entity, deviation_tables)
  File "/Users/ganeraje/Documents/git/ydk-mdt/python/ydk-py/lib/python2.7/site-packages/ydk/services/meta_service.py", line 96, in inject_imeta
    inject_imeta_helper(entity, deviation_tables)
  File "/Users/ganeraje/Documents/git/ydk-mdt/python/ydk-py/lib/python2.7/site-packages/ydk/services/meta_service.py", line 241, in inject_imeta_helper
    inject_imeta_helper(value, deviation_table, entity.i_meta)
  File "/Users/ganeraje/Documents/git/ydk-mdt/python/ydk-py/lib/python2.7/site-packages/ydk/services/meta_service.py", line 239, in inject_imeta_helper
    inject_imeta_helper(v, deviation_table, entity.i_meta)
  File "/Users/ganeraje/Documents/git/ydk-mdt/python/ydk-py/lib/python2.7/site-packages/ydk/services/meta_service.py", line 239, in inject_imeta_helper
    inject_imeta_helper(v, deviation_table, entity.i_meta)
  File "/Users/ganeraje/Documents/git/ydk-mdt/python/ydk-py/lib/python2.7/site-packages/ydk/services/meta_service.py", line 241, in inject_imeta_helper
    inject_imeta_helper(value, deviation_table, entity.i_meta)
  File "/Users/ganeraje/Documents/git/ydk-mdt/python/ydk-py/lib/python2.7/site-packages/ydk/services/meta_service.py", line 191, in inject_imeta_helper
    new_meta = copy_meta(meta)
  File "/Users/ganeraje/Documents/git/ydk-mdt/python/ydk-py/lib/python2.7/site-packages/ydk/services/meta_service.py", line 263, in copy_meta
    for member in meta.meta_info_class_members:
AttributeError: '_MetaInfoEnum' object has no attribute ‘meta_info_class_members'
psykokwak4 commented 8 years ago

Hi Ganesh,

Could you provide more info about destgroupid, enc, dest_port and dest_addr? Not able to reproduce this issue.

Thanks,

Xiaoqin

Edit: Was able to reproduce by assiging Enum to entity, sorry about that.