]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix cinder-manage volume delete cmd
authorAnton Arefiev <aarefiev@mirantis.com>
Wed, 24 Jun 2015 15:45:35 +0000 (18:45 +0300)
committerAnton Arefiev <aarefiev@mirantis.com>
Wed, 24 Jun 2015 15:45:35 +0000 (18:45 +0300)
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

cinder/cmd/manage.py
cinder/tests/unit/test_cmd.py

index 51287a6288de524058863a35b8a89c5b05d06d07..28690e5d9edda1485fe987f62ea2fb258471ecf3 100644 (file)
@@ -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."))
index a309c6ecb2d9c247ba40b1fd95f627161a39c56d..1cd592de571435f00c98974c8fe9b4272f2a565c 100644 (file)
@@ -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'])