summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-07-30 15:20:56 -0400
committerRussell Bryant <rbryant@redhat.com>2012-07-30 20:18:38 -0400
commit36dc58791482d44d63d63e9780451f9499619f05 (patch)
tree7ad32f89238821148dd720bbe3f802937cfd000b
parent3359e31b204c9a3ac0f4d8bc400a3d7c4c3c081f (diff)
Send a full instance in rollback_live_migration_at_destination.
Change the rollback_live_migration_at_destination method of the compute rpc API to take a full instance over rpc instead of just the instance ID. This cuts down on database access needed by nova-compute. This was the last method of this API that was taking an instance ID as an argument. There still some left that take the instance UUID, but I can see the light at the end of the tunnel. Part of blueprint no-db-messaging. Change-Id: Id581d23d36fee5c6fc06d2a655e999fb9aae5ae3
-rw-r--r--nova/compute/manager.py20
-rw-r--r--nova/compute/rpcapi.py8
-rw-r--r--nova/tests/compute/test_compute.py4
-rw-r--r--nova/tests/compute/test_rpcapi.py9
4 files changed, 24 insertions, 17 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index f1de42d61..426577d5c 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -272,7 +272,7 @@ def _get_image_meta(context, image_ref):
class ComputeManager(manager.SchedulerDependentManager):
"""Manages the running instances from creation to destruction."""
- RPC_API_VERSION = '1.31'
+ RPC_API_VERSION = '1.32'
def __init__(self, compute_driver=None, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
@@ -2407,24 +2407,28 @@ class ComputeManager(manager.SchedulerDependentManager):
self.compute_rpcapi.rollback_live_migration_at_destination(context,
instance_ref, dest)
- def rollback_live_migration_at_destination(self, context, instance_id):
+ def rollback_live_migration_at_destination(self, context, instance=None,
+ instance_id=None):
""" Cleaning up image directory that is created pre_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: an Instance dict sent over rpc
"""
- instance_ref = self.db.instance_get(context, instance_id)
- network_info = self._get_instance_nw_info(context, instance_ref)
+ if not instance:
+ instance = self.db.instance_get(context, instance_id)
+
+ network_info = self._get_instance_nw_info(context, instance)
# NOTE(tr3buchet): tear down 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, teardown=True)
# NOTE(vish): The mapping is passed in so the driver can disconnect
# from remote volumes if necessary
block_device_info = self._get_instance_volume_block_device_info(
- context, instance_id)
- self.driver.destroy(instance_ref, self._legacy_nw_info(network_info),
+ context, instance['id'])
+ self.driver.destroy(instance, self._legacy_nw_info(network_info),
block_device_info)
@manager.periodic_task
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index 107bf4d8d..c3b7f068d 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -102,6 +102,8 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.29 - Remove instance_uuid, add instance argument to resize_instance()
1.30 - Remove instance_uuid, add instance argument to resume_instance()
1.31 - Remove instance_uuid, add instance argument to revert_resize()
+ 1.32 - Remove instance_id, add instance argument to
+ rollback_live_migration_at_destination()
'''
BASE_RPC_API_VERSION = '1.0'
@@ -386,9 +388,11 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
version='1.31')
def rollback_live_migration_at_destination(self, ctxt, instance, host):
+ instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('rollback_live_migration_at_destination',
- instance_id=instance['id']),
- topic=_compute_topic(self.topic, ctxt, host, None))
+ instance=instance_p),
+ topic=_compute_topic(self.topic, ctxt, host, None),
+ version='1.32')
def set_admin_password(self, ctxt, instance, new_pass):
self.cast(ctxt, self.make_msg('set_admin_password',
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 36d001966..030314dc5 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -1625,8 +1625,8 @@ class ComputeTestCase(BaseTestCase):
"version": "1.26"}, None)
rpc.cast(c, topic,
{"method": "rollback_live_migration_at_destination",
- "args": {'instance_id': inst_id},
- "version": "1.0"})
+ "args": {'instance': rpcinst},
+ "version": "1.32"})
# start test
self.mox.ReplayAll()
diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py
index 7a1195fe0..9b55bbb97 100644
--- a/nova/tests/compute/test_rpcapi.py
+++ b/nova/tests/compute/test_rpcapi.py
@@ -60,6 +60,7 @@ class ComputeRpcAPITestCase(test.TestCase):
'rebuild_instance', 'remove_fixed_ip_from_instance',
'remove_volume_connection', 'rescue_instance', 'reset_network',
'resize_instance', 'resume_instance', 'revert_resize',
+ 'rollback_live_migration_at_destination',
'start_instance', 'stop_instance', 'suspend_instance',
'unpause_instance'
]
@@ -86,10 +87,7 @@ class ComputeRpcAPITestCase(test.TestCase):
methods_with_instance):
instance = expected_msg['args']['instance']
del expected_msg['args']['instance']
- if method in ['rollback_live_migration_at_destination']:
- expected_msg['args']['instance_id'] = instance['id']
- else:
- expected_msg['args']['instance_uuid'] = instance['uuid']
+ expected_msg['args']['instance_uuid'] = instance['uuid']
expected_msg['version'] = expected_version
cast_and_call = ['confirm_resize', 'stop_instance']
@@ -291,7 +289,8 @@ class ComputeRpcAPITestCase(test.TestCase):
def test_rollback_live_migration_at_destination(self):
self._test_compute_api('rollback_live_migration_at_destination',
- 'cast', instance=self.fake_instance, host='host')
+ 'cast', instance=self.fake_instance, host='host',
+ version='1.32')
def test_set_admin_password(self):
self._test_compute_api('set_admin_password', 'cast',