Handle AttributeError when creating a profile

When creating a profile with a invalid yaml file, AttributeError
will happen, the exception is not handled. This patch fixes this
bug.

Change-Id: I4c08d2e9edf240a5b5e6c9fdc2f666b62a35e722
Closes-bug: #1465154
This commit is contained in:
Haiwei Xu
2015-06-15 16:23:05 +09:00
parent 8e9272e4a2
commit 826c3ac83a

View File

@@ -149,7 +149,11 @@ def get_spec_content(filename):
def process_stack_spec(spec):
# Heat stack is a headache, because it demands for client side file
# content processing
tmplfile = spec.get('template', None)
try:
tmplfile = spec.get('template', None)
except AttributeError as ex:
raise exc.FileFormatError(_('The specified file is not a valid '
'YAML file: %s') % six.text_type(ex))
if not tmplfile:
raise exc.FileFormatError(_('No template found in the given '
'spec file'))