Fixes Congress model validation

Change-Id: I8293996b936503b10f67ce428c0a17dc059e6481
This commit is contained in:
Stan Lagun 2015-08-25 18:43:33 +03:00 committed by Filip Blaha
parent 9ac9ad538d
commit 75afcd238b
2 changed files with 10 additions and 10 deletions

View File

@ -160,10 +160,11 @@ class TaskExecutor(object):
except Exception as e:
return self.exception_result(e, None, '<load>')
try:
self._validate_model(obj, self.action, class_loader)
except Exception as e:
return self.exception_result(e, obj, '<validate>')
if obj is not None:
try:
self._validate_model(obj.object, self.action, class_loader)
except Exception as e:
return self.exception_result(e, obj, '<validate>')
try:
LOG.info(_LI('Invoking pre-cleanup hooks'))
@ -230,10 +231,9 @@ class TaskExecutor(object):
def _validate_model(self, obj, action, class_loader):
if CONF.engine.enable_model_policy_enforcer:
if obj is not None:
if action is not None and action['method'] == 'deploy':
self._model_policy_enforcer.validate(obj.to_dictionary(),
class_loader)
if action is not None and action['method'] == 'deploy':
self._model_policy_enforcer.validate(obj.to_dictionary(),
class_loader)
def _invoke(self, mpl_executor):
obj = mpl_executor.object_store.get(self.action['object_id'])

View File

@ -91,7 +91,7 @@ class CongressRulesManager(object):
obj = self._to_dict(obj)
new_owner = self._process_item(obj, owner_id, path) or owner_id
if isinstance(obj, list):
if isinstance(obj, list) or isinstance(obj, tuple):
for v in obj:
self._walk(v, new_owner, path)
elif isinstance(obj, dict):
@ -150,7 +150,7 @@ class CongressRulesManager(object):
if isinstance(value, dict):
rules.extend(self._create_propety_rules(
obj_id, value, prefix + key + "."))
elif isinstance(value, list):
elif isinstance(value, list) or isinstance(obj, tuple):
for v in value:
v = self._to_dict(v)
if not isinstance(v, dict):