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 cd919107279..44ff507486c 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -11160,7 +11160,10 @@ class StorwizeSVCReplicationTestCase(test.TestCase): self.driver.retype(self.ctxt, volume, new_type, diff, host) - def test_storwize_svc_retype_global_mirror_volume_to_thin(self): + @mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_volume_io_group') + def test_storwize_svc_retype_global_mirror_volume_to_thin(self, + get_vol_io_grp): self.driver.do_setup(self.ctxt) loc = ('StorwizeSVCDriver:' + self.driver._state['system_id'] + ':openstack') @@ -11170,6 +11173,8 @@ class StorwizeSVCReplicationTestCase(test.TestCase): 'capabilities': cap} ctxt = context.get_admin_context() + get_vol_io_grp.return_value = 0 + type_name = 'rep_global_none' spec = {'replication_enabled': ' True', 'replication_type': ' global', @@ -11201,6 +11206,7 @@ class StorwizeSVCReplicationTestCase(test.TestCase): self.driver.retype(self.ctxt, vol1, vol_type2, diff, host) copies = self.driver._helpers.lsvdiskcopy(vol1.name) self.assertEqual(2, len(copies)) + get_vol_io_grp.assert_called_once_with(vol1.name) self.driver.delete_volume(vol1) def test_storwize_svc_retype_global_mirror_volume_to_none(self): 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 a2e95c5128a..2037f74081b 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -5142,7 +5142,7 @@ class StorwizeSVCCommonDriver(san.SanDriver, def _verify_retype_params(self, volume, new_opts, old_opts, need_copy, change_mirror, new_rep_type, old_rep_type, - vdisk_changes, old_pool, new_pool): + vdisk_changes, old_pool, new_pool, old_io_grp): # Some volume parameters can not be changed or changed at the same # time during volume retype operation. This function checks the # retype parameters. @@ -5195,7 +5195,6 @@ class StorwizeSVCCommonDriver(san.SanDriver, need_check_dr_pool_param = True if new_rep_type != old_rep_type: - old_io_grp = self._helpers.get_volume_io_group(volume.name) if (old_io_grp not in StorwizeHelpers._get_valid_requested_io_groups( self._state, new_opts)): @@ -5401,10 +5400,10 @@ class StorwizeSVCCommonDriver(san.SanDriver, old_io_grp = self._helpers.get_volume_io_group(volume['name']) new_io_grp = self._helpers.select_io_group(self._state, new_opts, new_pool) - self._verify_retype_params(volume, new_opts, old_opts, need_copy, change_mirror, new_rep_type, old_rep_type, - vdisk_changes, old_pool, new_pool) + vdisk_changes, old_pool, new_pool, + old_io_grp) if old_opts['volume_topology'] or new_opts['volume_topology']: self._check_hyperswap_retype_params(volume, new_opts, old_opts, diff --git a/releasenotes/notes/bug-1951250-storwize-fix-multiple-ssh-calls-for-retype-d3b56379b7d8b049.yaml b/releasenotes/notes/bug-1951250-storwize-fix-multiple-ssh-calls-for-retype-d3b56379b7d8b049.yaml new file mode 100644 index 00000000000..9eecdaf305d --- /dev/null +++ b/releasenotes/notes/bug-1951250-storwize-fix-multiple-ssh-calls-for-retype-d3b56379b7d8b049.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + IBM Spectrum Virtualize Family driver + `Bug #1920870 `_: + Reduce multiple lsiogrp, lsvdisk calls in Retype operaton + to optimize the code.