diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-08-03 23:11:03 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-08-06 15:09:33 -0400 |
| commit | abe509fae061f7c14d6b02e9718031e90cfb3ffa (patch) | |
| tree | c66549e9ee5cc9fc835f9f852513c10ec0ab7ba4 /nova/compute | |
| parent | 2ed2c411a982e297d6b756f8a21939fadb2a0a93 (diff) | |
Send full instance to compute live_migration.
Remove the instance_id parameter and send a full instance to
live_migration in the compute manager. This cuts down on database
access required by the compute manager.
Part of blueprint no-db-messaging.
Change-Id: Ic21f061702704ddeaa6925aac4ecad69b0e8de18
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 28 | ||||
| -rw-r--r-- | nova/compute/rpcapi.py | 8 |
2 files changed, 23 insertions, 13 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index e57881e88..0da0e7319 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -273,7 +273,7 @@ def _get_image_meta(context, image_ref): class ComputeManager(manager.SchedulerDependentManager): """Manages the running instances from creation to destruction.""" - RPC_API_VERSION = '1.39' + RPC_API_VERSION = '1.40' def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" @@ -2201,48 +2201,50 @@ class ComputeManager(manager.SchedulerDependentManager): if block_migration: self.driver.pre_block_migration(context, instance, disk) - def live_migration(self, context, instance_id, - dest, block_migration=False): + def live_migration(self, context, dest, block_migration=False, + instance=None, instance_id=None): """Executing live migration. :param context: security context - :param instance_id: nova.db.sqlalchemy.models.Instance.Id + :param instance_id: (deprecated) nova.db.sqlalchemy.models.Instance.Id + :param instance: instance dict :param dest: destination host :param block_migration: if true, prepare for block migration """ # Get instance for error handling. - instance_ref = self.db.instance_get(context, instance_id) + if not instance: + instance = self.db.instance_get(context, instance_id) try: # Checking volume node is working correctly when any volumes # are attached to instances. - if self._get_instance_volume_bdms(context, instance_ref['uuid']): + if self._get_instance_volume_bdms(context, instance['uuid']): rpc.call(context, FLAGS.volume_topic, {'method': 'check_for_export', - 'args': {'instance_id': instance_id}}) + 'args': {'instance_id': instance['id']}}) if block_migration: - disk = self.driver.get_instance_disk_info(instance_ref.name) + disk = self.driver.get_instance_disk_info(instance['name']) else: disk = None - self.compute_rpcapi.pre_live_migration(context, instance_ref, + self.compute_rpcapi.pre_live_migration(context, instance, block_migration, disk, dest) except Exception: with excutils.save_and_reraise_exception(): - instance_uuid = instance_ref['uuid'] + instance_uuid = instance['uuid'] LOG.exception(_('Pre live migration failed at %(dest)s'), - locals(), instance=instance_ref) - self.rollback_live_migration(context, instance_ref, dest, + locals(), instance=instance) + self.rollback_live_migration(context, instance, dest, block_migration) # Executing live migration # live_migration might raises exceptions, but # nothing must be recovered in this version. - self.driver.live_migration(context, instance_ref, dest, + self.driver.live_migration(context, instance, dest, self._post_live_migration, self.rollback_live_migration, block_migration) diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index 72babd380..9b98f2ef5 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -118,6 +118,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): - remove instance_type_id, add instance_type - remove topic, it was unused 1.39 - Remove instance_uuid, add instance argument to run_instance() + 1.40 - Remove instance_id, add instance argument to live_migration() ''' BASE_RPC_API_VERSION = '1.0' @@ -275,6 +276,13 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): topic=_compute_topic(self.topic, ctxt, None, instance), version='1.19') + def live_migration(self, ctxt, instance, dest, block_migration, host): + instance_p = jsonutils.to_primitive(instance) + self.cast(ctxt, self.make_msg('live_migration', instance=instance_p, + dest=dest, block_migration=block_migration), + topic=_compute_topic(self.topic, ctxt, host, None), + version='1.40') + def pause_instance(self, ctxt, instance): instance_p = jsonutils.to_primitive(instance) self.cast(ctxt, self.make_msg('pause_instance', |
