diff options
author | huangtianhua <huangtianhua@huawei.com> | 2014-01-29 15:25:14 +0800 |
---|---|---|
committer | huangtianhua <huangtianhua@huawei.com> | 2014-02-11 11:07:10 +0800 |
commit | ce02d917f745da52764c85dd02a48c539eb62782 (patch) | |
tree | cf26d9497591746d13addf3bda272d1262573b1f /heatclient/common/environment_format.py | |
parent | 62cd3154c5ee0380f9ae848f63c60d48fccb6c2e (diff) | |
download | python-heatclient-ce02d917f745da52764c85dd02a48c539eb62782.tar.gz |
Fixes environment file using correct YAML format
An internal unexpected exception is raised while create a stack with an
environment file which only has string content. We should handle the case
and raise the correct error message such as "environment file is not Yaml
format".
Change-Id: I4e124db6a8dca9cf811f151ae95058cdaae16a01
Closes-Bug: #1273974
Diffstat (limited to 'heatclient/common/environment_format.py')
-rw-r--r-- | heatclient/common/environment_format.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/heatclient/common/environment_format.py b/heatclient/common/environment_format.py index 136c0ae..d3c002e 100644 --- a/heatclient/common/environment_format.py +++ b/heatclient/common/environment_format.py @@ -26,7 +26,7 @@ def parse(env_str): '''Takes a string and returns a dict containing the parsed structure. This includes determination of whether the string is using the - JSON or YAML format. + YAML format. ''' try: env = yaml.load(env_str, Loader=yaml_loader) @@ -35,6 +35,9 @@ def parse(env_str): else: if env is None: env = {} + elif not isinstance(env, dict): + raise ValueError('The environment is not a valid ' + 'YAML mapping data type.') for param in env: if param not in SECTIONS: |