summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2016-07-08 15:15:00 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2016-07-10 00:38:59 +0800
commit0997552722dc4845a854e0e6f8d7f18058e26380 (patch)
treeb90d1e808bb326612211ba56b3b941516493398d /tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
parent7fe3011a67a239f7dc04153c54eaff78ef967eaf (diff)
Synchronise the openstack bugs
When run unittests through tox, some test cases are always error, the errors are already done in openstack community, so it's necessary to synchronise the fixes. Change-Id: Ib29078e6cc138a474e89c6a2cc90ad7a1db1bb46 JIRA: PARSER-63 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.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
index 0413443..865690e 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
@@ -16,6 +16,7 @@ from toscaparser.elements.statefulentitytype import StatefulEntityType
class CapabilityTypeDef(StatefulEntityType):
'''TOSCA built-in capabilities type.'''
+ TOSCA_TYPEURI_CAPABILITY_ROOT = 'tosca.capabilities.Root'
def __init__(self, name, ctype, ntype, custom_def=None):
self.name = name
@@ -23,6 +24,7 @@ class CapabilityTypeDef(StatefulEntityType):
custom_def)
self.nodetype = ntype
self.properties = None
+ self.custom_def = custom_def
if self.PROPERTIES in self.defs:
self.properties = self.defs[self.PROPERTIES]
self.parent_capabilities = self._get_parent_capabilities(custom_def)
@@ -61,7 +63,8 @@ class CapabilityTypeDef(StatefulEntityType):
capabilities = {}
parent_cap = self.parent_type
if parent_cap:
- while parent_cap != 'tosca.capabilities.Root':
+ parent_cap = parent_cap.type
+ while parent_cap != self.TOSCA_TYPEURI_CAPABILITY_ROOT:
if parent_cap in self.TOSCA_DEF.keys():
capabilities[parent_cap] = self.TOSCA_DEF[parent_cap]
elif custom_def and parent_cap in custom_def.keys():
@@ -72,4 +75,9 @@ class CapabilityTypeDef(StatefulEntityType):
@property
def parent_type(self):
'''Return a capability this capability is derived from.'''
- return self.derived_from(self.defs)
+ if not hasattr(self, 'defs'):
+ return None
+ pnode = self.derived_from(self.defs)
+ if pnode:
+ return CapabilityTypeDef(self.name, pnode,
+ self.nodetype, self.custom_def)