summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2013-06-05 19:13:06 +0000
committerChris Behrens <cbehrens@codestud.com>2013-06-21 18:58:45 +0000
commit967e9675874fc2a02a585cc6f9b99175f9cd656c (patch)
tree131581c6b0df0a5f07dc6eb6a1b611e192ed1c35 /nova/compute
parent022bd8d6c16a1a06a3996f1fa827bc17b4272af7 (diff)
downloadnova-967e9675874fc2a02a585cc6f9b99175f9cd656c.tar.gz
nova-967e9675874fc2a02a585cc6f9b99175f9cd656c.tar.xz
nova-967e9675874fc2a02a585cc6f9b99175f9cd656c.zip
Fix sys_meta access in prep for instance object
Fix various places that access instance['system_metadata'] as if it's a list of sqlalchemy models. A helper util method was created in a previous patch set in nova/utils... so this patch converts things to use it. Left one use in _init_instance() in compute/manager.py because it's being addressed with a different patch set. Related to blueprint unified-object-model Change-Id: I876a6c57f64d61d64069c884bf0414c3596e1aa0
Diffstat (limited to 'nova/compute')
-rwxr-xr-xnova/compute/manager.py13
-rw-r--r--nova/compute/utils.py3
2 files changed, 7 insertions, 9 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 0a6a9d08d..f7aba992c 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1447,7 +1447,7 @@ class ComputeManager(manager.SchedulerDependentManager):
vm_state=vm_states.DELETED,
task_state=None,
terminated_at=timeutils.utcnow())
- system_meta = utils.metadata_to_dict(instance['system_metadata'])
+ system_meta = utils.instance_sys_meta(instance)
self.conductor_api.instance_destroy(context, instance)
except Exception:
with excutils.save_and_reraise_exception():
@@ -2072,7 +2072,7 @@ class ComputeManager(manager.SchedulerDependentManager):
def _get_rescue_image_ref(self, context, instance):
"""Determine what image should be used to boot the rescue VM."""
- system_meta = utils.metadata_to_dict(instance['system_metadata'])
+ system_meta = utils.instance_sys_meta(instance)
rescue_image_ref = system_meta.get('image_base_image_ref')
@@ -2174,7 +2174,7 @@ class ComputeManager(manager.SchedulerDependentManager):
Returns the updated system_metadata as a dict, as well as the
post-cleanup current instance type.
"""
- sys_meta = utils.metadata_to_dict(instance['system_metadata'])
+ sys_meta = utils.instance_sys_meta(instance)
if restore_old:
instance_type = flavors.extract_flavor(instance, 'old_')
sys_meta = flavors.save_flavor_info(sys_meta, instance_type)
@@ -2428,9 +2428,8 @@ class ComputeManager(manager.SchedulerDependentManager):
# NOTE(danms): Stash the new instance_type to avoid having to
# look it up in the database later
- sys_meta = utils.metadata_to_dict(instance['system_metadata'])
- flavors.save_flavor_info(sys_meta, instance_type,
- prefix='new_')
+ sys_meta = utils.instance_sys_meta(instance)
+ flavors.save_flavor_info(sys_meta, instance_type, prefix='new_')
# NOTE(mriedem): Stash the old vm_state so we can set the
# resized/reverted instance back to the same state later.
vm_state = instance['vm_state']
@@ -2600,7 +2599,7 @@ class ComputeManager(manager.SchedulerDependentManager):
old_instance_type_id = migration['old_instance_type_id']
new_instance_type_id = migration['new_instance_type_id']
old_instance_type = flavors.extract_flavor(instance)
- sys_meta = utils.metadata_to_dict(instance['system_metadata'])
+ sys_meta = utils.instance_sys_meta(instance)
# NOTE(mriedem): Get the old_vm_state so we know if we should
# power on the instance. If old_vm_sate is not set we need to default
# to ACTIVE for backwards compatibility
diff --git a/nova/compute/utils.py b/nova/compute/utils.py
index 9637d8773..3db4a14f2 100644
--- a/nova/compute/utils.py
+++ b/nova/compute/utils.py
@@ -203,8 +203,7 @@ def notify_usage_exists(context, instance_ref, current_period=False,
ignore_missing_network_data)
if system_metadata is None:
- system_metadata = utils.metadata_to_dict(
- instance_ref['system_metadata'])
+ system_metadata = utils.instance_sys_meta(instance_ref)
# add image metadata to the notification:
image_meta = notifications.image_meta(system_metadata)