summaryrefslogtreecommitdiff
path: root/heat/engine/hot
diff options
context:
space:
mode:
authorPeter Razumovsky <prazumovsky@mirantis.com>2014-10-27 17:36:22 +0300
committerPeter Razumovsky <prazumovsky@mirantis.com>2014-11-20 16:47:56 +0300
commit5b09e4524a467a4df41ca9e88a571d2bae1ae9b6 (patch)
treec4486157b28118aa27811da5f5d40d76c1b7be26 /heat/engine/hot
parenta4d98f68abb6941528b0589eaec8d6c8b511a122 (diff)
downloadheat-5b09e4524a467a4df41ca9e88a571d2bae1ae9b6.tar.gz
Correct error msg when resource or output are empty
When resource or output body is empty, we get traceback instead of error message. This is wrong, so this patch handle such situation by raising StackValidationFailed exception. Furthermore, if output body is not a mapping, we got traceback too. Change-Id: I27f3a732480a851fd2eceb83e5fcc850ee59bb73 Closes-bug: #1386242
Diffstat (limited to 'heat/engine/hot')
-rw-r--r--heat/engine/hot/template.py49
1 files changed, 33 insertions, 16 deletions
diff --git a/heat/engine/hot/template.py b/heat/engine/hot/template.py
index 262d960ce..21be68e8e 100644
--- a/heat/engine/hot/template.py
+++ b/heat/engine/hot/template.py
@@ -132,16 +132,23 @@ class HOTemplate20130523(template.Template):
for resource_name, attrs in six.iteritems(resources):
cfn_resource = {}
- if isinstance(attrs, six.string_types):
- message = _('"resources" must contain a map of resource maps.')
+ if not attrs:
+ message = _('Each resource must '
+ 'contain a type key.')
+ raise exception.StackValidationFailed(message=message)
+ try:
+ for attr, attr_value in six.iteritems(attrs):
+ cfn_attr = self._translate(attr, HOT_TO_CFN_ATTRS,
+ _('"%s" is not a valid '
+ 'keyword inside a resource '
+ 'definition'))
+ cfn_resource[cfn_attr] = attr_value
+
+ cfn_resources[resource_name] = cfn_resource
+ except AttributeError:
+ message = _('"resources" must contain a map of resource maps. '
+ 'Found a [%s] instead') % type(attrs)
raise exception.StackValidationFailed(message=message)
- for attr, attr_value in six.iteritems(attrs):
- cfn_attr = self._translate(attr, HOT_TO_CFN_ATTRS,
- _('"%s" is not a valid keyword '
- 'inside a resource definition'))
- cfn_resource[cfn_attr] = attr_value
-
- cfn_resources[resource_name] = cfn_resource
return cfn_resources
@@ -155,13 +162,23 @@ class HOTemplate20130523(template.Template):
for output_name, attrs in six.iteritems(outputs):
cfn_output = {}
- for attr, attr_value in six.iteritems(attrs):
- cfn_attr = self._translate(attr, HOT_TO_CFN_ATTRS,
- _('"%s" is not a valid keyword '
- 'inside an output definition'))
- cfn_output[cfn_attr] = attr_value
-
- cfn_outputs[output_name] = cfn_output
+ if not attrs:
+ message = _('Each output must '
+ 'contain a value key.')
+ raise exception.StackValidationFailed(message=message)
+ try:
+ for attr, attr_value in six.iteritems(attrs):
+ cfn_attr = self._translate(attr, HOT_TO_CFN_ATTRS,
+ _('"%s" is not a valid '
+ 'keyword inside an output '
+ 'definition'))
+ cfn_output[cfn_attr] = attr_value
+
+ cfn_outputs[output_name] = cfn_output
+ except AttributeError:
+ message = _('"outputs" must contain a map of output maps. '
+ 'Found a [%s] instead') % type(attrs)
+ raise exception.StackValidationFailed(message=message)
return cfn_outputs