From 01985dd44d1b29c7ad7cb0932a1d30f7b6fe1911 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 26 Jul 2012 18:45:51 -0400 Subject: Send a full instance in pre_live_migration. Change the pre_live_migration method of the compute rpc API to take a full instance over rpc instead of just the instance UUID. This cuts down on database access needed by nova-compute. Part of blueprint no-db-messaging. Change-Id: Ib628d375254fc1539cd79ceaaad83c1c326863b4 --- nova/compute/manager.py | 25 ++++++++++++------------- nova/compute/rpcapi.py | 8 ++++++-- 2 files changed, 18 insertions(+), 15 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index ef1bdbcc6..ff0fafcce 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -295,7 +295,7 @@ def _get_additional_capabilities(): class ComputeManager(manager.SchedulerDependentManager): """Manages the running instances from creation to destruction.""" - RPC_API_VERSION = '1.22' + RPC_API_VERSION = '1.23' def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" @@ -2159,7 +2159,7 @@ class ComputeManager(manager.SchedulerDependentManager): self.driver.check_can_live_migrate_source(ctxt, instance, dest_check_data) - def pre_live_migration(self, context, instance_id, + def pre_live_migration(self, context, instance=None, instance_id=None, block_migration=False, disk=None): """Preparations for live migration at dest host. @@ -2168,16 +2168,17 @@ class ComputeManager(manager.SchedulerDependentManager): :param block_migration: if true, prepare for block migration """ - # Getting instance info - instance_ref = self.db.instance_get(context, instance_id) + if not instance: + # Getting instance info + instance = self.db.instance_get(context, instance_id) # If any volume is mounted, prepare here. block_device_info = self._get_instance_volume_block_device_info( - context, instance_ref['uuid']) + context, instance['uuid']) if not block_device_info['block_device_mapping']: - LOG.info(_('Instance has no volume.'), instance=instance_ref) + LOG.info(_('Instance has no volume.'), instance=instance) - network_info = self._get_instance_nw_info(context, instance_ref) + network_info = self._get_instance_nw_info(context, instance) # TODO(tr3buchet): figure out how on the earth this is necessary fixed_ips = network_info.fixed_ips() @@ -2185,12 +2186,12 @@ class ComputeManager(manager.SchedulerDependentManager): raise exception.FixedIpNotFoundForInstance( instance_id=instance_id) - self.driver.pre_live_migration(context, instance_ref, + self.driver.pre_live_migration(context, instance, block_device_info, self._legacy_nw_info(network_info)) # NOTE(tr3buchet): setup networks on destination host - self.network_api.setup_networks_on_host(context, instance_ref, + self.network_api.setup_networks_on_host(context, instance, self.host) # Creating filters to hypervisors and firewalls. @@ -2199,14 +2200,12 @@ class ComputeManager(manager.SchedulerDependentManager): # This nwfilter is necessary on the destination host. # In addition, this method is creating filtering rule # onto destination host. - self.driver.ensure_filtering_rules_for_instance(instance_ref, + self.driver.ensure_filtering_rules_for_instance(instance, self._legacy_nw_info(network_info)) # Preparation for block migration if block_migration: - self.driver.pre_block_migration(context, - instance_ref, - disk) + self.driver.pre_block_migration(context, instance, disk) def live_migration(self, context, instance_id, dest, block_migration=False): diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index a99c8f492..5def90cd2 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -88,6 +88,8 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): power_off_instance() and stop_instance() 1.22 - Remove instance_uuid, add instance argument to power_on_instance() and start_instance() + 1.23 - Remove instance_id, add instance argument to + pre_live_migration() ''' BASE_RPC_API_VERSION = '1.0' @@ -270,9 +272,11 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): def pre_live_migration(self, ctxt, instance, block_migration, disk, host): + instance_p = jsonutils.to_primitive(instance) return self.call(ctxt, self.make_msg('pre_live_migration', - instance_id=instance['id'], block_migration=block_migration, - disk=disk), _compute_topic(self.topic, ctxt, host, None)) + instance=instance_p, block_migration=block_migration, + disk=disk), _compute_topic(self.topic, ctxt, host, None), + version='1.23') def reboot_instance(self, ctxt, instance, reboot_type): instance_p = jsonutils.to_primitive(instance) -- cgit