Creating a network route table with empty prefix list throws schema error

Bug #1647261 reported by Shashikiran H
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Juniper Openstack
Status tracked in Trunk
R3.2
Fix Committed
High
Sachin Bansal
Trunk
Fix Committed
High
Sachin Bansal

Bug Description

Version: 3.0.3.1-4~kilo and 3.2.0.0-3~mitaka

Creating a network route table with empty prefix list throws the below error. Creating it with prefixes in the table works fine.

From /var/log/contrail/schema.err

<type 'exceptions.TypeError'>
Python 2.7.6: /usr/bin/python
Mon Dec 5 11:17:55 2016

A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.

 /usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py in _vnc_subscribe_callback(self=<schema_transformer.to_bgp.SchemaTransformer object>, oper_info={u'imid': u'contrail:route-table:default-domain:ctest-Test...RouteTables-37902384:network_table_left_to_right', u'obj_dict': {u'display_name': u'network_table_left_to_right', u'fq_name': [u'default-domain', u'ctest-TestStaticRouteTables-37902384', u'network_table_left_to_right'], u'id_perms': {u'created': u'2016-12-05T05:47:55.805996', u'creator': None, u'description': None, u'enable': True, u'last_modified': u'2016-12-05T05:47:55.805996', u'permissions': {u'group': u'admin', u'group_access': 7, u'other_access': 7, u'owner': u'ctest-TestStaticRouteTables-37902384', u'owner_access': 7}, u'user_visible': True, u'uuid': {u'uuid_lslong': 11265472265026901802L, u'uuid_mslong': 10827130449067788800L}}, u'parent_type': u'project', u'perms2': {u'global_access': 0, u'owner': u'9cb41e2547af4874a6144ecda23f5c47', u'owner_access': 7, u'share': []}, u'routes': [], u'uuid': u'9641b1c7-6180-4a00-9c56-ff5687f1972a'}, u'oper': u'CREATE', u'parent_imid': u'contrail:project:default-domain:ctest-TestStaticRouteTables-37902384', u'request-id': u'req-04ba033e-e586-4b06-b3a6-ad0d95bd103c', u'type': u'route-table', u'uuid': u'9641b1c7-6180-4a00-9c56-ff5687f1972a'})
  257 self._cassandra.cache_uuid_to_fq_name_add(
  258 obj_id, obj_dict['fq_name'], obj_type)
  259 obj = obj_class.locate(obj_fq_name)
  260 if obj is None:
  261 self.config_log('%s id %s fq_name %s not found' % (
obj undefined
obj_class = <class 'schema_transformer.config_db.RouteTableST'>
obj_class.locate = <bound method __metaclass__.locate of <class 'schema_transformer.config_db.RouteTableST'>>
obj_fq_name = u'default-domain:ctest-TestStaticRouteTables-37902384:network_table_left_to_right'

 /usr/lib/python2.7/dist-packages/schema_transformer/config_db.py in locate(cls=<class 'schema_transformer.config_db.RouteTableST'>, key=u'default-domain:ctest-TestStaticRouteTables-37902384:network_table_left_to_right', *args=())
  102 @classmethod
  103 def locate(cls, key, *args):
  104 obj = super(DBBaseST, cls).locate(key, *args)
  105 if obj and obj.obj.uuid not in cls._uuid_fq_name_map:
  106 cls._uuid_fq_name_map[obj.obj.uuid] = key
obj undefined
builtinsuper = <type 'super'>
global DBBaseST = <class 'schema_transformer.config_db.DBBaseST'>
cls = <class 'schema_transformer.config_db.RouteTableST'>
).locate = <bound method __metaclass__.locate of <class 'schema_transformer.config_db.RouteTableST'>>
key = u'default-domain:ctest-TestStaticRouteTables-37902384:network_table_left_to_right'
args = ()

 /usr/lib/python2.7/dist-packages/cfgm_common/vnc_db.py in locate(cls=<class 'schema_transformer.config_db.RouteTableST'>, key=u'default-domain:ctest-TestStaticRouteTables-37902384:network_table_left_to_right', *args=())
   62 if key not in cls._dict:
   63 try:
   64 obj = cls(key, *args)
   65 cls._dict[key] = obj
   66 return obj
obj undefined
cls = <class 'schema_transformer.config_db.RouteTableST'>
key = u'default-domain:ctest-TestStaticRouteTables-37902384:network_table_left_to_right'
args = ()

 /usr/lib/python2.7/dist-packages/schema_transformer/config_db.py in __init__(self=<schema_transformer.config_db.RouteTableST object>, name=u'default-domain:ctest-TestStaticRouteTables-37902384:network_table_left_to_right', obj=None)
 1485 self.service_instances = set()
 1486 self.routes = []
 1487 self.update(obj)
 1488 self.update_multiple_refs('virtual_network', self.obj)
 1489 # end __init__
self = <schema_transformer.config_db.RouteTableST object>
self.update = <bound method RouteTableST.update of <schema_transformer.config_db.RouteTableST object>>
obj = None

 /usr/lib/python2.7/dist-packages/schema_transformer/config_db.py in update(self=<schema_transformer.config_db.RouteTableST object>, obj=None)
 1490
 1491 def update(self, obj=None):
 1492 self.obj = obj or self.read_vnc_obj(fq_name=self.name)
 1493 self.routes = []
 1494 routes = self.obj.get_routes()
self = <schema_transformer.config_db.RouteTableST object>
self.obj undefined
obj = None
self.read_vnc_obj = <bound method __metaclass__.read_vnc_obj of <class 'schema_transformer.config_db.RouteTableST'>>
fq_name undefined
self.name = u'default-domain:ctest-TestStaticRouteTables-37902384:network_table_left_to_right'

 /usr/lib/python2.7/dist-packages/cfgm_common/vnc_db.py in read_vnc_obj(cls=<class 'schema_transformer.config_db.RouteTableST'>, uuid='9641b1c7-6180-4a00-9c56-ff5687f1972a', fq_name=[u'default-domain', u'ctest-TestStaticRouteTables-37902384', u'network_table_left_to_right'], obj_type='route_table')
  257 uuid = cls._cassandra.fq_name_to_uuid(obj_type, fq_name)
  258 obj_dict = cls.read_obj(uuid, obj_type)
  259 obj = cls.vnc_obj_from_dict(obj_type, obj_dict)
  260 obj.clear_pending_updates()
  261 return obj
obj undefined
cls = <class 'schema_transformer.config_db.RouteTableST'>
cls.vnc_obj_from_dict = <bound method __metaclass__.vnc_obj_from_dict of...ass 'schema_transformer.config_db.RouteTableST'>>
obj_type = 'route_table'
obj_dict = {'display_name': u'network_table_left_to_right', 'fq_name': [u'default-domain', u'ctest-TestStaticRouteTables-37902384', u'network_table_left_to_right'], 'id_perms': {u'created': u'2016-12-05T05:47:55.805996', u'creator': None, u'description': None, u'enable': True, u'last_modified': u'2016-12-05T05:47:55.805996', u'permissions': {u'group': u'admin', u'group_access': 7, u'other_access': 7, u'owner': u'ctest-TestStaticRouteTables-37902384', u'owner_access': 7}, u'user_visible': True, u'uuid': {u'uuid_lslong': 11265472265026901802L, u'uuid_mslong': 10827130449067788800L}}, 'parent_href': '', 'parent_type': u'project', 'parent_uuid': '9cb41e25-47af-4874-a614-4ecda23f5c47', 'perms2': {u'global_access': 0, u'owner': u'9cb41e2547af4874a6144ecda23f5c47', u'owner_access': 7, u'share': []}, 'routes': [], 'uuid': '9641b1c7-6180-4a00-9c56-ff5687f1972a'}

 /usr/lib/python2.7/dist-packages/cfgm_common/vnc_db.py in vnc_obj_from_dict(cls=<class 'vnc_api.gen.resource_client.RouteTable'>, obj_type='route_table', obj_dict={'display_name': u'network_table_left_to_right', 'fq_name': [u'default-domain', u'ctest-TestStaticRouteTables-37902384', u'network_table_left_to_right'], 'id_perms': {u'created': u'2016-12-05T05:47:55.805996', u'creator': None, u'description': None, u'enable': True, u'last_modified': u'2016-12-05T05:47:55.805996', u'permissions': {u'group': u'admin', u'group_access': 7, u'other_access': 7, u'owner': u'ctest-TestStaticRouteTables-37902384', u'owner_access': 7}, u'user_visible': True, u'uuid': {u'uuid_lslong': 11265472265026901802L, u'uuid_mslong': 10827130449067788800L}}, 'parent_href': '', 'parent_type': u'project', 'parent_uuid': '9cb41e25-47af-4874-a614-4ecda23f5c47', 'perms2': {u'global_access': 0, u'owner': u'9cb41e2547af4874a6144ecda23f5c47', u'owner_access': 7, u'share': []}, 'routes': [], 'uuid': '9641b1c7-6180-4a00-9c56-ff5687f1972a'})
  245 def vnc_obj_from_dict(cls, obj_type, obj_dict):
  246 cls = obj_type_to_vnc_class(obj_type, __name__)
  247 return cls.from_dict(**obj_dict)
  248
  249 @classmethod
cls = <class 'vnc_api.gen.resource_client.RouteTable'>
cls.from_dict = <bound method type.from_dict of <class 'vnc_api.gen.resource_client.RouteTable'>>
obj_dict = {'display_name': u'network_table_left_to_right', 'fq_name': [u'default-domain', u'ctest-TestStaticRouteTables-37902384', u'network_table_left_to_right'], 'id_perms': {u'created': u'2016-12-05T05:47:55.805996', u'creator': None, u'description': None, u'enable': True, u'last_modified': u'2016-12-05T05:47:55.805996', u'permissions': {u'group': u'admin', u'group_access': 7, u'other_access': 7, u'owner': u'ctest-TestStaticRouteTables-37902384', u'owner_access': 7}, u'user_visible': True, u'uuid': {u'uuid_lslong': 11265472265026901802L, u'uuid_mslong': 10827130449067788800L}}, 'parent_href': '', 'parent_type': u'project', 'parent_uuid': '9cb41e25-47af-4874-a614-4ecda23f5c47', 'perms2': {u'global_access': 0, u'owner': u'9cb41e2547af4874a6144ecda23f5c47', u'owner_access': 7, u'share': []}, 'routes': [], 'uuid': '9641b1c7-6180-4a00-9c56-ff5687f1972a'}

 /usr/lib/python2.7/dist-packages/vnc_api/gen/resource_client.py in from_dict(cls=<class 'vnc_api.gen.resource_client.RouteTable'>, **kwargs={'display_name': u'network_table_left_to_right', 'fq_name': [u'default-domain', u'ctest-TestStaticRouteTables-37902384', u'network_table_left_to_right'], 'id_perms': {u'created': u'2016-12-05T05:47:55.805996', u'creator': None, u'description': None, u'enable': True, u'last_modified': u'2016-12-05T05:47:55.805996', u'permissions': {u'group': u'admin', u'group_access': 7, u'other_access': 7, u'owner': u'ctest-TestStaticRouteTables-37902384', u'owner_access': 7}, u'user_visible': True, u'uuid': {u'uuid_lslong': 11265472265026901802L, u'uuid_mslong': 10827130449067788800L}}, 'parent_href': '', 'parent_type': u'project', 'parent_uuid': '9cb41e25-47af-4874-a614-4ecda23f5c47', 'perms2': {u'global_access': 0, u'owner': u'9cb41e2547af4874a6144ecda23f5c47', u'owner_access': 7, u'share': []}, 'routes': [], 'uuid': '9641b1c7-6180-4a00-9c56-ff5687f1972a'})
 6257 props_dict['routes'] = None
 6258 else:
 6259 props_dict['routes'] = vnc_api.gen.resource_xsd.RouteTableType(**kwargs['routes'])
 6260 if 'id_perms' in kwargs:
 6261 if kwargs['id_perms'] is None:
props_dict = {}
global vnc_api = <module 'vnc_api' from '/usr/lib/python2.7/dist-packages/vnc_api/__init__.pyc'>
vnc_api.gen = <module 'vnc_api.gen' from '/usr/lib/python2.7/dist-packages/vnc_api/gen/__init__.pyc'>
vnc_api.gen.resource_xsd = <module 'vnc_api.gen.resource_xsd' from '/usr/li...n2.7/dist-packages/vnc_api/gen/resource_xsd.pyc'>
vnc_api.gen.resource_xsd.RouteTableType = <class 'vnc_api.gen.resource_xsd.RouteTableType'>
kwargs = {'display_name': u'network_table_left_to_right', 'fq_name': [u'default-domain', u'ctest-TestStaticRouteTables-37902384', u'network_table_left_to_right'], 'id_perms': {u'created': u'2016-12-05T05:47:55.805996', u'creator': None, u'description': None, u'enable': True, u'last_modified': u'2016-12-05T05:47:55.805996', u'permissions': {u'group': u'admin', u'group_access': 7, u'other_access': 7, u'owner': u'ctest-TestStaticRouteTables-37902384', u'owner_access': 7}, u'user_visible': True, u'uuid': {u'uuid_lslong': 11265472265026901802L, u'uuid_mslong': 10827130449067788800L}}, 'parent_href': '', 'parent_type': u'project', 'parent_uuid': '9cb41e25-47af-4874-a614-4ecda23f5c47', 'perms2': {u'global_access': 0, u'owner': u'9cb41e2547af4874a6144ecda23f5c47', u'owner_access': 7, u'share': []}, 'routes': [], 'uuid': '9641b1c7-6180-4a00-9c56-ff5687f1972a'}
<type 'exceptions.TypeError'>: type object argument after ** must be a mapping, not list
    __class__ = <type 'exceptions.TypeError'>
    __delattr__ = <method-wrapper '__delattr__' of exceptions.TypeError object>
    __dict__ = {}
    __doc__ = 'Inappropriate argument type.'
    __format__ = <built-in method __format__ of exceptions.TypeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of exceptions.TypeError object>
    __getitem__ = <method-wrapper '__getitem__' of exceptions.TypeError object>
    __getslice__ = <method-wrapper '__getslice__' of exceptions.TypeError object>
    __hash__ = <method-wrapper '__hash__' of exceptions.TypeError object>
    __init__ = <method-wrapper '__init__' of exceptions.TypeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of exceptions.TypeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of exceptions.TypeError object>
    __repr__ = <method-wrapper '__repr__' of exceptions.TypeError object>
    __setattr__ = <method-wrapper '__setattr__' of exceptions.TypeError object>
    __setstate__ = <built-in method __setstate__ of exceptions.TypeError object>
    __sizeof__ = <built-in method __sizeof__ of exceptions.TypeError object>
    __str__ = <method-wrapper '__str__' of exceptions.TypeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __unicode__ = <built-in method __unicode__ of exceptions.TypeError object>
    args = ('type object argument after ** must be a mapping, not list',)
    message = 'type object argument after ** must be a mapping, not list'

The above is a description of an error in a Python program. Here is
the original traceback:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/schema_transformer/to_bgp.py", line 259, in _vnc_subscribe_callback
    obj = obj_class.locate(obj_fq_name)
  File "/usr/lib/python2.7/dist-packages/schema_transformer/config_db.py", line 104, in locate
    obj = super(DBBaseST, cls).locate(key, *args)
  File "/usr/lib/python2.7/dist-packages/cfgm_common/vnc_db.py", line 64, in locate
    obj = cls(key, *args)
  File "/usr/lib/python2.7/dist-packages/schema_transformer/config_db.py", line 1487, in __init__
    self.update(obj)
  File "/usr/lib/python2.7/dist-packages/schema_transformer/config_db.py", line 1492, in update
    self.obj = obj or self.read_vnc_obj(fq_name=self.name)
  File "/usr/lib/python2.7/dist-packages/cfgm_common/vnc_db.py", line 259, in read_vnc_obj
    obj = cls.vnc_obj_from_dict(obj_type, obj_dict)
  File "/usr/lib/python2.7/dist-packages/cfgm_common/vnc_db.py", line 247, in vnc_obj_from_dict
    return cls.from_dict(**obj_dict)
  File "/usr/lib/python2.7/dist-packages/vnc_api/gen/resource_client.py", line 6259, in from_dict
    props_dict['routes'] = vnc_api.gen.resource_xsd.RouteTableType(**kwargs['routes'])
TypeError: type object argument after ** must be a mapping, not list

Tags: config schema
Shashikiran H (skiranh)
description: updated
description: updated
Revision history for this message
Sachin Bansal (sbansal) wrote :

How are you setting the empty prefix list? Could you please point me to your test script?

Jeba Paulaiyan (jebap)
tags: added: config
Revision history for this message
Shashikiran H (skiranh) wrote :

route_table = RouteTableType(name)
parent_obj = self.project.project_obj
nw_route_table=RouteTable(name, parent_obj)
nw_route_table.set_routes([])
uuid=self._vnc.route_table_create(nw_route_table)

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : [Review update] master

Review in progress for https://review.opencontrail.org/26966
Submitter: Sachin Bansal (<email address hidden>)

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : [Review update] R3.2

Review in progress for https://review.opencontrail.org/26967
Submitter: Sachin Bansal (<email address hidden>)

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : A change has been merged

Reviewed: https://review.opencontrail.org/26967
Committed: http://github.org/Juniper/contrail-controller/commit/eaa45c0df9012aba8e658043b18d47003df7014c
Submitter: Zuul (<email address hidden>)
Branch: R3.2

commit eaa45c0df9012aba8e658043b18d47003df7014c
Author: Sachin Bansal <email address hidden>
Date: Wed Dec 7 09:51:09 2016 -0800

Fix property validation function

Properties can either be simple type or complex type, but not
lists. We should not allow them to be set to lists.

Change-Id: I74c107f9abbcc7ac1a536408cf8fe0203d0fd3c9
Closes-Bug: 1647261
(cherry picked from commit c98f514cb20db97987db8a34c407cdb0b075869f)

Revision history for this message
OpenContrail Admin (ci-admin-f) wrote :

Reviewed: https://review.opencontrail.org/26966
Committed: http://github.org/Juniper/contrail-controller/commit/c98f514cb20db97987db8a34c407cdb0b075869f
Submitter: Zuul (<email address hidden>)
Branch: master

commit c98f514cb20db97987db8a34c407cdb0b075869f
Author: Sachin Bansal <email address hidden>
Date: Wed Dec 7 09:51:09 2016 -0800

Fix property validation function

Properties can either be simple type or complex type, but not
lists. We should not allow them to be set to lists.

Change-Id: I74c107f9abbcc7ac1a536408cf8fe0203d0fd3c9
Closes-Bug: 1647261

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.