diff options
author | shangxdy <shang.xiaodong@zte.com.cn> | 2017-07-13 17:51:42 +0800 |
---|---|---|
committer | shangxdy <shang.xiaodong@zte.com.cn> | 2017-07-13 17:51:42 +0800 |
commit | e1ad31691ea4249a7dd33e9280dd6d0df8bc9475 (patch) | |
tree | 30ff99d37dedf93f3474ba3fddfcdf035ee04579 /tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py | |
parent | 5b3f19f30ff02faa80ad02762ae23ad020b04218 (diff) |
Add getting custom node by capability
Currently _get_node_type_by_cap in nodetype definition is only concerned
standard node, not consider custom node, the patch will support to get
node by custom node.
JIRA: PARSER-126
Change-Id: I822acc8bfb747562dc084783d863adf31603e794
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py')
-rw-r--r-- | tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py index 54cd9fe..5fa9661 100644 --- a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py +++ b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py @@ -81,3 +81,16 @@ class CapabilityTypeDef(StatefulEntityType): if pnode: return CapabilityTypeDef(self.name, pnode, self.nodetype, self.custom_def) + + def inherits_from(self, type_names): + '''Check this capability is in type_names + + Check if this capability or some of its parent types + are in the list of types: type_names + ''' + if self.type in type_names: + return True + elif self.parent_type: + return self.parent_type.inherits_from(type_names) + else: + return False |