diff options
| author | Dan Smith <danms@us.ibm.com> | 2013-01-02 13:07:04 -0800 |
|---|---|---|
| committer | Dan Smith <danms@us.ibm.com> | 2013-01-04 08:11:36 -0800 |
| commit | e034a126dade15f05014f6a9eb85562f59714f63 (patch) | |
| tree | 68d098f335791e298a565dd4fd4f3d442d6d7c9c /nova/compute | |
| parent | 10daa81057b2cfc0a3e21624b50b0b5d610b4db2 (diff) | |
Remove system_metadata db calls from compute manager
The compute/manager makes several unnecessary db calls to fetch
the instance system_metadata, which is available in the instance
object itself now. This patch replaces those uses, avoiding the
need to farm them out to conductor.
Related to bp/no-db-compute
Related to bp/no-db-compute-manager
Change-Id: I26ff77be17eb538a4fcd238ffe52f8bde4fbe3e0
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 8 | ||||
| -rw-r--r-- | nova/compute/utils.py | 13 |
2 files changed, 12 insertions, 9 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 295125f90..a1595320e 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1048,9 +1048,9 @@ class ComputeManager(manager.SchedulerDependentManager): vm_state=vm_states.DELETED, task_state=None, terminated_at=timeutils.utcnow()) + system_meta = compute_utils.metadata_to_dict( + instance['system_metadata']) self.db.instance_destroy(context, instance_uuid) - system_meta = self.db.instance_system_metadata_get(context, - instance_uuid) # ensure block device mappings are not leaked self.conductor_api.block_device_mapping_destroy(context, bdms) @@ -1537,8 +1537,8 @@ 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 = self.db.instance_system_metadata_get( - context, instance['uuid']) + system_meta = compute_utils.metadata_to_dict( + instance['system_metadata']) rescue_image_ref = system_meta.get('image_base_image_ref') diff --git a/nova/compute/utils.py b/nova/compute/utils.py index a0dfbea8d..8852cb820 100644 --- a/nova/compute/utils.py +++ b/nova/compute/utils.py @@ -37,6 +37,13 @@ CONF.import_opt('host', 'nova.config') LOG = log.getLogger(__name__) +def metadata_to_dict(metadata): + result = {} + for item in metadata: + result[item['key']] = item['value'] + return result + + def add_instance_fault_from_exc(context, instance_uuid, fault, exc_info=None): """Adds the specified fault to the database.""" @@ -153,11 +160,7 @@ def notify_usage_exists(context, instance_ref, current_period=False, ignore_missing_network_data) if system_metadata is None: - try: - system_metadata = db.instance_system_metadata_get( - context, instance_ref['uuid']) - except exception.NotFound: - system_metadata = {} + system_metadata = metadata_to_dict(instance_ref['system_metadata']) # add image metadata to the notification: image_meta = notifications.image_meta(system_metadata) |
