diff options
author | Trung Trinh <trung.t.trinh@dektech.com.au> | 2015-02-16 21:30:27 +1400 |
---|---|---|
committer | Trung Trinh <trung.t.trinh@dektech.com.au> | 2015-03-05 22:54:34 +1400 |
commit | 202a777ae097d1374e81a3c53b34de685746df2b (patch) | |
tree | b44beaa3677fb209ef483f737dc40ed848908e35 /nova/compute/flavors.py | |
parent | f3fadb5a2b66a0fdcabfca212f835c887b8f73b4 (diff) | |
download | nova-202a777ae097d1374e81a3c53b34de685746df2b.tar.gz |
Avoid KeyError Exception in extract_flavor()
In the function extract_flavor(), if the returned sys_meta
of the instance is empty dict or does not exist then the function
is returned to avoid KeyError Exception.
Change-Id: Ic996cc0ca0303772c4e6a8bbb9f4165ddcdfafff
Closes-Bug: #1226083
Diffstat (limited to 'nova/compute/flavors.py')
-rw-r--r-- | nova/compute/flavors.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/nova/compute/flavors.py b/nova/compute/flavors.py index 4518c8bff3..dab62589a3 100644 --- a/nova/compute/flavors.py +++ b/nova/compute/flavors.py @@ -278,6 +278,10 @@ def extract_flavor(instance, prefix=''): flavor = objects.Flavor() sys_meta = utils.instance_sys_meta(instance) + + if not sys_meta: + return None + for key in system_metadata_flavor_props.keys(): type_key = '%sinstance_type_%s' % (prefix, key) setattr(flavor, key, sys_meta[type_key]) |