Skip to content

Commit

Permalink
Fix property validation function
Browse files Browse the repository at this point in the history
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 c98f514)
  • Loading branch information
Sachin Bansal committed Dec 7, 2016
1 parent 16da7c1 commit eaa45c0
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/config/api-server/vnc_cfg_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def _validate_props_in_request(self, resource_class, obj_dict):
if not prop_value:
continue

if is_simple and (not is_list_prop) and (not is_map_prop):
if is_simple:
try:
obj_dict[prop_name] = self._validate_simple_type(prop_name,
prop_type, simple_type,
Expand All @@ -354,20 +354,6 @@ def _validate_props_in_request(self, resource_class, obj_dict):
prop_name, prop_value)
err_msg += str(e)
return False, err_msg
elif isinstance(prop_value, list):
for elem in prop_value:
try:
if is_simple:
self._validate_simple_type(prop_name, prop_type,
simple_type, elem,
restrictions)
else:
self._validate_complex_type(prop_cls, elem)
except Exception as e:
err_msg = 'Error validating property %s elem %s ' %(
prop_name, elem)
err_msg += str(e)
return False, err_msg
else: # complex-type + value isn't dict or wrapped in list or map
err_msg = 'Error in property %s type %s value of %s ' %(
prop_name, prop_cls, prop_value)
Expand Down

0 comments on commit eaa45c0

Please sign in to comment.