commit 8d7a98b3e7c2dd4f7dfd028d7f3af313ff410677 Author: sharathkacham Date: Thu Sep 3 07:47:04 2020 +0000 [SVF]: Support for retype operation on GM volumes IBM Spectrum Virtualize Family: Support for retype operation on Global Mirror volumes. Change-Id: Ibee86b4865e59bf0b4e492bc29e664ca473f8564 diff --git a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py index 31e9c3d..e8995f1 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -1860,6 +1860,8 @@ port_speed!N/A 'type', 'se_copy', 'easy_tier', 'easy_tier_status', 'compressed_copy']) for copy in vol['copies'].values(): + if 'compressed_copy' not in copy: + copy['compressed_copy'] = 'False' rows.append([vol['id'], vol['name'], copy['id'], copy['status'], copy['sync'], copy['primary'], copy['mdisk_grp_id'], copy['mdisk_grp_name'], @@ -4723,7 +4725,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): mock_ssh_pool.side_effect = [ paramiko.SSHException, mock.MagicMock( - ip = self._driver.configuration.storwize_san_secondary_ip), + ip=self._driver.configuration.storwize_san_secondary_ip), mock.MagicMock()] mock_ssh_execute.side_effect = [processutils.ProcessExecutionError, mock.MagicMock()] @@ -7356,8 +7358,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): self._assert_vol_exists(vol.name, True) vol2 = testutils.create_volume(self.ctxt, - host = 'openstack@svc#hyperswap1', - volume_type_id = vol.volume_type_id) + host='openstack@svc#hyperswap1', + volume_type_id=vol.volume_type_id) with mock.patch.object(storwize_svc_common.StorwizeHelpers, 'get_vdisk_attributes') as vdisk_attr: vdisk_attr.return_value = None @@ -9016,8 +9018,27 @@ class StorwizeSVCReplicationTestCase(test.TestCase): ({'replication_enabled': ' True', 'replication_type': ' metro'}, {'replication_enabled': ' True', - 'replication_type': ' global'}), - ({'replication_enabled': ' True', + 'replication_type': ' global'})) + @ddt.unpack + def test_storwize_retype_invalid_replication(self, old_opts, new_opts): + # Set replication target + self.driver.configuration.set_override('replication_device', + [self.rep_target]) + self.driver.do_setup(self.ctxt) + host = {'host': 'openstack@svc#openstack'} + old_type = self._create_replica_volume_type( + False, opts=old_opts, vol_type_name='test_old_type') + + volume, model_update = self._create_test_volume(old_type) + new_type = self._create_replica_volume_type( + False, opts=new_opts, vol_type_name='test_new_type') + diff, _equal = volume_types.volume_types_diff( + self.ctxt, new_type['id'], old_type['id']) + self.assertRaises(exception.VolumeDriverException, + self.driver.retype, self.ctxt, + volume, new_type, diff, host) + + @ddt.data(({'replication_enabled': ' True', 'replication_type': ' metro'}, {'mirror_pool': 'openstack1'}), ({'mirror_pool': 'openstack1'}, @@ -9029,7 +9050,7 @@ class StorwizeSVCReplicationTestCase(test.TestCase): 'replication_enabled': ' True', 'replication_type': ' metro'})) @ddt.unpack - def test_storwize_retype_invalid_replication(self, old_opts, new_opts): + def test_storwize_retype_valid_replication(self, old_opts, new_opts): # Set replication target self.driver.configuration.set_override('replication_device', [self.rep_target]) @@ -9043,8 +9064,94 @@ class StorwizeSVCReplicationTestCase(test.TestCase): False, opts=new_opts, vol_type_name='test_new_type') diff, _equal = volume_types.volume_types_diff( self.ctxt, new_type['id'], old_type['id']) - self.assertRaises(exception.VolumeDriverException, self.driver.retype, - self.ctxt, volume, new_type, diff, host) + self.driver.retype(self.ctxt, volume, + new_type, diff, host) + + def test_storwize_svc_retype_global_mirror_volume_to_thin(self): + self.driver.do_setup(self.ctxt) + loc = ('StorwizeSVCDriver:' + self.driver._state['system_id'] + + ':openstack') + cap = {'location_info': loc, 'extent_size': '128'} + self.driver._stats = {'location_info': loc} + host = {'host': 'openstack@svc#openstack', + 'capabilities': cap} + ctxt = context.get_admin_context() + + type_name = 'rep_global_none' + spec = {'replication_enabled': ' True', + 'replication_type': ' global', + 'drivers:rsize': '-1', + 'compression': 'False'} + type_ref = volume_types.create(self.ctxt, type_name, spec) + vol_type1 = objects.VolumeType.get_by_id(self.ctxt, type_ref['id']) + + type_name = 'rep_global_thin' + spec = {'replication_enabled': ' True', + 'replication_type': ' global', + 'drivers:rsize': '2', + 'compression': 'False'} + type_ref = volume_types.create(self.ctxt, type_name, spec) + vol_type2 = objects.VolumeType.get_by_id(self.ctxt, + type_ref['id']) + + diff, _equal = volume_types.volume_types_diff(ctxt, vol_type1.id, + vol_type2.id) + + # Create test volume with volume type with rsize as -1 + vol1, model_update = self._create_test_volume(vol_type1) + self.assertEqual(fields.ReplicationStatus.ENABLED, + model_update['replication_status']) + vol1['status'] = 'available' + + copies = self.driver._helpers.lsvdiskcopy(vol1.name) + self.assertEqual(1, len(copies)) + self.driver.retype(self.ctxt, vol1, vol_type2, diff, host) + copies = self.driver._helpers.lsvdiskcopy(vol1.name) + self.assertEqual(2, len(copies)) + self.driver.delete_volume(vol1) + + def test_storwize_svc_retype_global_mirror_volume_to_none(self): + self.driver.do_setup(self.ctxt) + loc = ('StorwizeSVCDriver:' + self.driver._state['system_id'] + + ':openstack') + cap = {'location_info': loc, 'extent_size': '128'} + self.driver._stats = {'location_info': loc} + host = {'host': 'openstack@svc#openstack', + 'capabilities': cap} + ctxt = context.get_admin_context() + + type_name = 'rep_global_thin' + spec = {'replication_enabled': ' True', + 'replication_type': ' global', + 'drivers:rsize': '2', + 'compression': 'False'} + type_ref = volume_types.create(self.ctxt, type_name, spec) + vol_type1 = objects.VolumeType.get_by_id(self.ctxt, type_ref['id']) + + type_name = 'rep_global_none' + spec = {'replication_enabled': ' True', + 'replication_type': ' global', + 'drivers:rsize': '-1', + 'compression': 'False'} + type_ref = volume_types.create(self.ctxt, type_name, spec) + vol_type2 = objects.VolumeType.get_by_id(self.ctxt, + type_ref['id']) + + diff, _equal = volume_types.volume_types_diff(ctxt, vol_type1.id, + vol_type2.id) + + # Create test volume with volume type with rsize as 2 + vol1, model_update = self._create_test_volume(vol_type1) + self.assertEqual(fields.ReplicationStatus.ENABLED, + model_update['replication_status']) + vol1['status'] = 'available' + + copies = self.driver._helpers.lsvdiskcopy(vol1.name) + self.assertEqual(1, len(copies)) + self.driver.retype(self.ctxt, vol1, vol_type2, diff, host) + copies = self.driver._helpers.lsvdiskcopy(vol1.name) + self.assertEqual(2, len(copies)) + self.driver.delete_volume(vol1) def test_storwize_retype_from_mirror_to_none_replication(self): # Set replication target diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index 26c3e9e..ea3d546 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -4583,15 +4583,6 @@ class StorwizeSVCCommonDriver(san.SanDriver, if not old_opts['mirror_pool'] and new_opts['mirror_pool']: need_check_dr_pool_param = True - # There are four options for rep_type: None, metro, global, gmcv - if new_rep_type or old_rep_type: - # If volume is replicated, can't copy - if need_copy or new_opts['mirror_pool'] or old_opts['mirror_pool']: - msg = (_('Unable to retype: current action needs volume-copy, ' - 'it is not allowed for replication type. ' - 'Volume = %s') % volume.id) - raise exception.VolumeDriverException(message=msg) - if new_rep_type != old_rep_type: old_io_grp = self._helpers.get_volume_io_group(volume.name) if (old_io_grp not in diff --git a/releasenotes/notes/support-retype-operation-for-global-mirror-volumes-e7091ac130e41cbd.yaml b/releasenotes/notes/support-retype-operation-for-global-mirror-volumes-e7091ac130e41cbd.yaml new file mode 100644 index 0000000..9608b0c --- /dev/null +++ b/releasenotes/notes/support-retype-operation-for-global-mirror-volumes-e7091ac130e41cbd.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + IBM Spectrum Virtualize: Adds support for retype operation on + global mirror volumes.