Skip to content

Commit

Permalink
Add rollback_live_migration_at_destination() to compute rpcapi.
Browse files Browse the repository at this point in the history
Part of bug 1006467.

This patch adds rollback_live_migration_at_destination() to the compute
rpcapi.  This method is used by the compute manager.

Change-Id: Iadbb50fc5cb0f7b5ad483d48666bc81e033ac5f4
  • Loading branch information
russellb committed May 31, 2012
1 parent 18108a0 commit 3a829e3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 2 additions & 4 deletions nova/compute/manager.py
Expand Up @@ -2214,10 +2214,8 @@ def rollback_live_migration(self, context, instance_ref,
# before migration starts, so if any failure occurs,
# any empty images has to be deleted.
if block_migration:
rpc.cast(context,
rpc.queue_get_for(context, FLAGS.compute_topic, dest),
{"method": "rollback_live_migration_at_destination",
"args": {'instance_id': instance_ref['id']}})
self.compute_rpcapi.rollback_live_migration_at_destination(context,
instance_ref, dest)

def rollback_live_migration_at_destination(self, context, instance_id):
""" Cleaning up image directory that is created pre_live_migration.
Expand Down
5 changes: 5 additions & 0 deletions nova/compute/rpcapi.py
Expand Up @@ -244,6 +244,11 @@ def revert_resize(self, ctxt, instance, migration_id, host):
instance_uuid=instance['uuid'], migration_id=migration_id),
topic=self._compute_topic(ctxt, host, instance))

def rollback_live_migration_at_destination(self, ctxt, instance, host):
self.cast(ctxt, self.make_msg('rollback_live_migration_at_destination',
instance_id=instance['id']),
topic=self._compute_topic(ctxt, host, None))

def set_admin_password(self, ctxt, instance, new_pass):
self.cast(ctxt, self.make_msg('set_admin_password',
instance_uuid=instance['uuid'], new_pass=new_pass),
Expand Down
19 changes: 17 additions & 2 deletions nova/tests/compute/test_rpcapi.py
Expand Up @@ -31,7 +31,12 @@
class ComputeRpcAPITestCase(test.TestCase):

def setUp(self):
self.fake_instance = {'uuid': 'fake_uuid', 'host': 'fake_host'}
self.fake_instance = {
'uuid': 'fake_uuid',
'host': 'fake_host',
'name': 'fake_name',
'id': 'fake_id',
}
super(ComputeRpcAPITestCase, self).setUp()

def tearDown(self):
Expand All @@ -41,6 +46,7 @@ def _test_compute_api(self, method, rpc_method, **kwargs):
ctxt = context.RequestContext('fake_user', 'fake_project')
rpcapi = compute_rpcapi.ComputeAPI()
expected_retval = 'foo' if method == 'call' else None

expected_msg = rpcapi.make_msg(method, **kwargs)
if 'host_param' in expected_msg['args']:
host_param = expected_msg['args']['host_param']
Expand All @@ -51,8 +57,13 @@ def _test_compute_api(self, method, rpc_method, **kwargs):
if 'instance' in expected_msg['args']:
instance = expected_msg['args']['instance']
del expected_msg['args']['instance']
expected_msg['args']['instance_uuid'] = instance['uuid']
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['version'] = rpcapi.RPC_API_VERSION

cast_and_call = ['confirm_resize', 'stop_instance']
if rpc_method == 'call' and method in cast_and_call:
kwargs['cast'] = False
Expand Down Expand Up @@ -207,6 +218,10 @@ def test_revert_resize(self):
self._test_compute_api('revert_resize', 'cast',
instance=self.fake_instance, migration_id='id', host='host')

def test_rollback_live_migration_at_destination(self):
self._test_compute_api('rollback_live_migration_at_destination',
'cast', instance=self.fake_instance, host='host')

def test_set_admin_password(self):
self._test_compute_api('set_admin_password', 'cast',
instance=self.fake_instance, new_pass='pw')
Expand Down

0 comments on commit 3a829e3

Please sign in to comment.