summaryrefslogtreecommitdiff
path: root/nova/compute/flavors.py
diff options
context:
space:
mode:
authorTrung Trinh <trung.t.trinh@dektech.com.au>2015-02-16 21:30:27 +1400
committerTrung Trinh <trung.t.trinh@dektech.com.au>2015-03-05 22:54:34 +1400
commit202a777ae097d1374e81a3c53b34de685746df2b (patch)
treeb44beaa3677fb209ef483f737dc40ed848908e35 /nova/compute/flavors.py
parentf3fadb5a2b66a0fdcabfca212f835c887b8f73b4 (diff)
downloadnova-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.py4
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])