summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser/toscaparser
diff options
context:
space:
mode:
authorjulien zhang <zhang.jun3g@zte.com.cn>2016-07-04 10:16:29 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-07-04 10:16:29 +0000
commitabb85f971f797e7db6c1737862b53ab4fee2a12e (patch)
treee9808e0b4274bb1b82237477f240780bcd754f0c /tosca2heat/tosca-parser/toscaparser
parentf532963362db840edbce7f647c851562b15e125f (diff)
parentb41406e9eead948744645720db0c49c3998488cd (diff)
Merge "The grouptype's parent_type definition is error"
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/grouptype.py11
-rw-r--r--tosca2heat/tosca-parser/toscaparser/tests/test_toscadef.py1
2 files changed, 12 insertions, 0 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/grouptype.py b/tosca2heat/tosca-parser/toscaparser/elements/grouptype.py
index ec5571c..5587f05 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/grouptype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/grouptype.py
@@ -52,6 +52,17 @@ class GroupType(StatefulEntityType):
self._validate_metadata(self.meta_data)
@property
+ def parent_type(self):
+ '''Return a group statefulentity of this entity is derived from.'''
+ if not hasattr(self, 'defs'):
+ return None
+ pgroup_entity = self.derived_from(self.defs)
+ if pgroup_entity:
+ return GroupType(pgroup_entity, self.custom_def)
+ else:
+ return None
+
+ @property
def description(self):
return self.group_description
diff --git a/tosca2heat/tosca-parser/toscaparser/tests/test_toscadef.py b/tosca2heat/tosca-parser/toscaparser/tests/test_toscadef.py
index 7c29e67..358bf28 100644
--- a/tosca2heat/tosca-parser/toscaparser/tests/test_toscadef.py
+++ b/tosca2heat/tosca-parser/toscaparser/tests/test_toscadef.py
@@ -60,6 +60,7 @@ class ToscaDefTest(TestCase):
def test_group(self):
self.assertEqual(group_type.type, "tosca.groups.Root")
+ self.assertEqual(group_type.parent_type, None)
self.assertIn(ifaces.LIFECYCLE_SHORTNAME, group_type.interfaces)
def test_capabilities(self):