From 826c3ac83ae1f7063a00c4e54e29213c36ccdc5f Mon Sep 17 00:00:00 2001 From: Haiwei Xu Date: Mon, 15 Jun 2015 16:23:05 +0900 Subject: [PATCH] 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 --- senlinclient/common/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/senlinclient/common/utils.py b/senlinclient/common/utils.py index 3945cda7..eca86ca6 100644 --- a/senlinclient/common/utils.py +++ b/senlinclient/common/utils.py @@ -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'))