Skip to content

Commit

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

Add the remove_volume_connection method to the compute rpcapi.  This is
used by the compute manager.

Change-Id: I307d85782baa371a16c80bd9ecabf449a60a0876
  • Loading branch information
russellb committed Jun 1, 2012
1 parent 18734e9 commit dc0751f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
7 changes: 2 additions & 5 deletions nova/compute/manager.py
Expand Up @@ -2197,11 +2197,8 @@ def rollback_live_migration(self, context, instance_ref,
instance_ref['uuid']):
volume_id = bdm['volume_id']
volume = self.volume_api.get(context, volume_id)
rpc.call(context,
rpc.queue_get_for(context, FLAGS.compute_topic, dest),
{"method": "remove_volume_connection",
"args": {'instance_id': instance_ref['id'],
'volume_id': volume['id']}})
self.compute_rpcapi.remove_volume_connection(context, instance_ref,
volume['id'], dest)

# Block migration needs empty image at destination host
# before migration starts, so if any failure occurs,
Expand Down
5 changes: 5 additions & 0 deletions nova/compute/rpcapi.py
Expand Up @@ -243,6 +243,11 @@ def remove_fixed_ip_from_instance(self, ctxt, instance, address):
instance_uuid=instance['uuid'], address=address),
topic=self._compute_topic(ctxt, None, instance))

def remove_volume_connection(self, ctxt, instance, volume_id, host):
return self.call(ctxt, self.make_msg('remove_volume_connection',
instance_id=instance['id'], volume_id=volume_id),
topic=self._compute_topic(ctxt, host, None))

def rescue_instance(self, ctxt, instance, rescue_password):
self.cast(ctxt, self.make_msg('rescue_instance',
instance_uuid=instance['uuid'],
Expand Down
8 changes: 5 additions & 3 deletions nova/tests/compute/test_compute.py
Expand Up @@ -1456,9 +1456,11 @@ def test_live_migration_dest_raises_exception(self):
'args': {'instance_id': inst_ref['id'],
'host': self.compute.host,
'teardown': False}})
rpc.call(c, topic, {"method": "remove_volume_connection",
"args": {'instance_id': inst_ref['id'],
'volume_id': volume_id}})
rpc.call(c, topic,
{"method": "remove_volume_connection",
"args": {'instance_id': inst_ref['id'],
'volume_id': volume_id},
"version": compute_rpcapi.ComputeAPI.RPC_API_VERSION}, None)
rpc.cast(c, topic, {"method": "rollback_live_migration_at_destination",
"args": {'instance_id': inst_ref['id']}})

Expand Down
6 changes: 5 additions & 1 deletion nova/tests/compute/test_rpcapi.py
Expand Up @@ -58,7 +58,7 @@ def _test_compute_api(self, method, rpc_method, **kwargs):
instance = expected_msg['args']['instance']
del expected_msg['args']['instance']
if method in ['rollback_live_migration_at_destination',
'pre_live_migration',
'pre_live_migration', 'remove_volume_connection',
'post_live_migration_at_destination']:
expected_msg['args']['instance_id'] = instance['id']
else:
Expand Down Expand Up @@ -221,6 +221,10 @@ def test_remove_fixed_ip_from_instance(self):
self._test_compute_api('remove_fixed_ip_from_instance', 'cast',
instance=self.fake_instance, address='addr')

def test_remove_volume_connection(self):
self._test_compute_api('remove_volume_connection', 'call',
instance=self.fake_instance, volume_id='id', host='host')

def test_rescue_instance(self):
self._test_compute_api('rescue_instance', 'cast',
instance=self.fake_instance, rescue_password='pw')
Expand Down

0 comments on commit dc0751f

Please sign in to comment.