From: Anton Arefiev Date: Wed, 24 Jun 2015 15:45:35 +0000 (+0300) Subject: Fix cinder-manage volume delete cmd X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=8076457cd069cfd734976c544f4aed49c38b4fc9;p=openstack-build%2Fcinder-build.git Fix cinder-manage volume delete cmd Since pools was introduced in cinder, field 'host' in resources contains pool part. So when we are trying to delete volume with cinder-manage, 'host' with pool part passed to rpc target. As result message isn't delivered to host, and we can't delete volume. Change-Id: Ie6dcbbfe28dcc5b6dc838490b351a13b43936da9 Closes-Bug: 1468401 --- diff --git a/cinder/cmd/manage.py b/cinder/cmd/manage.py index 51287a628..28690e5d9 100644 --- a/cinder/cmd/manage.py +++ b/cinder/cmd/manage.py @@ -81,6 +81,7 @@ from cinder import objects from cinder import rpc from cinder import utils from cinder import version +from cinder.volume import utils as vutils CONF = cfg.CONF @@ -285,7 +286,7 @@ class VolumeCommands(object): """ ctxt = context.get_admin_context() volume = db.volume_get(ctxt, param2id(volume_id)) - host = volume['host'] + host = vutils.extract_host(volume['host']) if volume['host'] else None if not host: print(_("Volume not yet assigned to host.")) diff --git a/cinder/tests/unit/test_cmd.py b/cinder/tests/unit/test_cmd.py index a309c6ecb..1cd592de5 100644 --- a/cinder/tests/unit/test_cmd.py +++ b/cinder/tests/unit/test_cmd.py @@ -439,7 +439,10 @@ class TestCinderManageCmd(test.TestCase): mock_client.prepare.return_value = cctxt get_client.return_value = mock_client volume_id = '123' - volume = {'id': volume_id, 'host': 'fake-host', 'status': 'available'} + host = 'fake@host' + volume = {'id': volume_id, + 'host': host + '#pool1', + 'status': 'available'} volume_get.return_value = volume volume_cmds = cinder_manage.VolumeCommands() @@ -447,7 +450,8 @@ class TestCinderManageCmd(test.TestCase): volume_cmds.delete(volume_id) volume_get.assert_called_once_with(ctxt, 123) - mock_client.prepare.assert_called_once_with(server=volume['host']) + # NOTE prepare called w/o pool part in host + mock_client.prepare.assert_called_once_with(server=host) cctxt.cast.assert_called_once_with(ctxt, 'delete_volume', volume_id=volume['id'])