From 27176ea58c08c126d1cfd28a453ff8ff95497107 Mon Sep 17 00:00:00 2001 From: kushal Date: Thu, 18 Jan 2018 02:47:31 -0800 Subject: [PATCH] 3PAR: fix volume migration for "in-use" volume. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3par driver does not support cross protocol level “In use” volume migration, for such cases we are returning False and then after that cinder framework takes care of same. But we were doing same for same protocol level and Hence volume migration was failing. This patch resolve this issue and if same protocol level “in use” volume migration case is there then 3par driver takes care of such migration. Change-Id: I0aba3760cd8f22dd0b19a45ecde06919af4a2447 Closes-Bug: #1744021 --- .../unit/volume/drivers/hpe/test_hpe3par.py | 30 +++++++++++++++++++ cinder/volume/drivers/hpe/hpe_3par_base.py | 15 ++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py index ab0547110bd..79ed60e07e2 100644 --- a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py +++ b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py @@ -7720,6 +7720,36 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver): self.assertEqual(self.FAKE_HOST, host['name']) self.assertEqual(3, len(host['FCPaths'])) + @mock.patch.object(volume_types, 'get_volume_type') + def test_migrate_fc_volume_attached_to_iscsi_protocol(self, + _mock_volume_types): + _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 + mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) + + protocol = "iSCSI" + + volume = {'name': HPE3PARBaseDriver.VOLUME_NAME, + 'volume_type_id': None, + 'id': HPE3PARBaseDriver.CLONE_ID, + 'display_name': 'Foo Volume', + 'size': 2, + 'status': 'in-use', + 'host': HPE3PARBaseDriver.FAKE_HOST, + 'source_volid': HPE3PARBaseDriver.VOLUME_ID} + + loc_info = 'HPE3PARDriver:1234567:CPG-FC1' + host = {'host': 'stack@3parfc1', + 'capabilities': {'location_info': loc_info, + 'storage_protocol': protocol}} + + result = self.driver.migrate_volume(context.get_admin_context(), + volume, host) + + self.assertIsNotNone(result) + self.assertEqual((False, None), result) + expected = [] + mock_client.assert_has_calls(expected) + def test_migrate_volume_attached(self): self.migrate_volume_attached() diff --git a/cinder/volume/drivers/hpe/hpe_3par_base.py b/cinder/volume/drivers/hpe/hpe_3par_base.py index 4469d6e66fc..43dda299d3f 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_base.py +++ b/cinder/volume/drivers/hpe/hpe_3par_base.py @@ -56,10 +56,11 @@ class HPE3PARDriverBase(driver.ManageableVD, 1.0.1 - Adds consistency group capability in generic volume groups. 1.0.2 - Adds capability. 1.0.3 - Added Tiramisu feature on 3PAR. + 1.0.4 - Fixed Volume migration for "in-use" volume. bug #1744021 """ - VERSION = "1.0.3" + VERSION = "1.0.4" def __init__(self, *args, **kwargs): super(HPE3PARDriverBase, self).__init__(*args, **kwargs) @@ -303,10 +304,14 @@ class HPE3PARDriverBase(driver.ManageableVD, @utils.trace def migrate_volume(self, context, volume, host): if volume['status'] == 'in-use': - LOG.debug("3PAR %(protocol)s driver cannot migrate in-use volume " - "to a host with storage_protocol=%(protocol)s", - {'protocol': self.protocol}) - return False, None + protocol = host['capabilities']['storage_protocol'] + if protocol != self.protocol: + LOG.debug("3PAR %(protocol)s driver cannot migrate in-use " + "volume to a host with " + "storage_protocol=%(storage_protocol)s", + {'protocol': self.protocol, + 'storage_protocol': protocol}) + return False, None common = self._login() try: