Skip to content

Commit

Permalink
Merge "Add checks for prop_type and parent types" into R3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed May 20, 2016
2 parents d75311a + e93b2c3 commit da865c0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
10 changes: 3 additions & 7 deletions src/config/api-server/vnc_cfg_api_server.py
Expand Up @@ -247,13 +247,9 @@ def _validate_simple_type(cls, type_name, xsd_type, value, restrictions=None):
def _validate_props_in_request(self, resource_class, obj_dict):
for prop_name in resource_class.prop_fields:
prop_field_types = resource_class.prop_field_types[prop_name]
if isinstance(prop_field_types, dict):
is_simple = not prop_field_types['is_complex']
prop_type = prop_field_types['xsd_type']
restrictions = prop_field_types['restrictions']
else:
is_simple, prop_type = prop_field_types
restrictions = None
is_simple = not prop_field_types['is_complex']
prop_type = prop_field_types['xsd_type']
restrictions = prop_field_types['restrictions']
is_list_prop = prop_name in resource_class.prop_list_fields
is_map_prop = prop_name in resource_class.prop_map_fields

Expand Down
7 changes: 2 additions & 5 deletions src/config/api-server/vnc_cfg_ifmap.py
Expand Up @@ -161,11 +161,8 @@ def object_set(self, res_type, my_imid, existing_metas, obj_dict):
# construct object of xsd-type and get its xml repr
# e.g. virtual_network_properties
prop_field_types = obj_class.prop_field_types[prop_field]
if isinstance(prop_field_types, dict):
is_simple = not prop_field_types['is_complex']
prop_type = prop_field_types['xsd_type']
else:
is_simple, prop_type = prop_field_types
is_simple = not prop_field_types['is_complex']
prop_type = prop_field_types['xsd_type']
# e.g. virtual-network-properties
prop_meta = obj_class.prop_field_metas[prop_field]
if is_simple:
Expand Down
7 changes: 3 additions & 4 deletions src/config/common/vnc_cassandra.py
Expand Up @@ -424,6 +424,8 @@ def object_create(self, res_type, obj_id, obj_dict):
if 'parent_type' in obj_dict:
# non config-root child
parent_type = obj_dict['parent_type']
if parent_type not in obj_class.parent_types:
return False, (400, 'Invalid parent type: %s' % parent_type)
parent_method_type = parent_type.replace('-', '_')
parent_fq_name = obj_dict['fq_name'][:-1]
obj_cols['parent_type'] = json.dumps(parent_type)
Expand Down Expand Up @@ -558,10 +560,7 @@ def object_read(self, res_type, obj_uuids, field_names=None):
obj_class.prop_map_field_has_wrappers[prop_name]
if has_wrapper:
prop_field_types = obj_class.prop_field_types[prop_name]
if isinstance(prop_field_types, dict):
wrapper_type = prop_field_types['xsd_type']
else:
_, wrapper_type = prop_field_types
wrapper_type = prop_field_types['xsd_type']
wrapper_cls = self._get_xsd_class(wrapper_type)
wrapper_field = wrapper_cls.attr_fields[0]
if prop_name not in result:
Expand Down

0 comments on commit da865c0

Please sign in to comment.