summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2017-09-08 16:32:09 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2017-09-08 16:32:09 +0800
commit0e2c3b05b5d788635bba09c19487cf9fa23095ee (patch)
tree4590a71805dda4a673c07041c9bddfa38c196d54 /tosca2heat/tosca-parser
parentdd361d8d9df7a69a4fc7c004db5b959440a024c2 (diff)
Fix StatefulEntityType when entitytype is not define
Currently, if a entity type is not defined, the defs in StatefulEntityType will be none, then the access to self.defs will raise error, finally the parser will be crushed. this patch will enhance it. JIRA: PARSER-153 Change-Id: I5db50102e9c63428298ce6c8ecbf38e3bd8e57f8 Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/tosca-parser')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py2
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py3
2 files changed, 3 insertions, 2 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
index 5fa9661..23c5afc 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
@@ -25,7 +25,7 @@ class CapabilityTypeDef(StatefulEntityType):
self.nodetype = ntype
self.properties = None
self.custom_def = custom_def
- if self.PROPERTIES in self.defs:
+ if self.defs and self.PROPERTIES in self.defs:
self.properties = self.defs[self.PROPERTIES]
self.parent_capabilities = self._get_parent_capabilities(custom_def)
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py b/tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py
index 2f221b3..28ee697 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py
@@ -46,7 +46,8 @@ class StatefulEntityType(EntityType):
elif custom_def and entitytype in list(custom_def.keys()):
self.defs = custom_def[entitytype]
else:
- self.defs = None
+ # avoid errors if self.defs = none
+ self.defs = {}
ExceptionCollector.appendException(
InvalidTypeError(what=entitytype))
self.type = entitytype