summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser/toscaparser/elements
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2016-06-14 17:31:14 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2016-06-15 00:41:56 +0800
commitdc0e2e51304dbc085546ee869617d9c545610667 (patch)
treef0e4bfab08eff9f15b3b9abad7f3273485c7532d /tosca2heat/tosca-parser/toscaparser/elements
parent37c637988622dde3425390fb861800ffdaf2b6cb (diff)
The policytype's parent_type definition is error
1. policy type define parent_type, but it shall be statefulentity, not string, so the method of is_derived_from in policy entity may be error when it's called. 2. The bug will submit to openstack community. Change-Id: I25e1cb04e9c13eea6d47ed0bfeac961f59146842 JIRA: PARSER-52 Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/elements')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/policytype.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/policytype.py b/tosca2heat/tosca-parser/toscaparser/elements/policytype.py
index 04cbab5..8fbb0f0 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/policytype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/policytype.py
@@ -28,6 +28,7 @@ class PolicyType(StatefulEntityType):
super(PolicyType, self).__init__(ptype, self.POLICY_PREFIX,
custom_def)
self.type = ptype
+ self.custom_def = custom_def
self._validate_keys()
self.meta_data = None
@@ -55,7 +56,7 @@ class PolicyType(StatefulEntityType):
def _get_parent_policies(self):
policies = {}
- parent_policy = self.parent_type
+ parent_policy = self.parent_type.type if self.parent_type else None
if parent_policy:
while parent_policy != 'tosca.policies.Root':
policies[parent_policy] = self.TOSCA_DEF[parent_policy]
@@ -64,8 +65,12 @@ class PolicyType(StatefulEntityType):
@property
def parent_type(self):
- '''Return a policy this policy is derived from.'''
- return self.derived_from(self.defs)
+ '''Return a policy statefulentity of this node is derived from.'''
+ if not hasattr(self, 'defs'):
+ return None
+ ppolicy_entity = self.derived_from(self.defs)
+ if ppolicy_entity:
+ return PolicyType(ppolicy_entity, self.custom_def)
def get_policy(self, name):
'''Return the definition of a policy field by name.'''