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 f017145cde6..fa3d07eed90 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -8426,6 +8426,32 @@ class StorwizeHelpersTestCase(test.TestCase): self.storwize_svc_common.pretreatment_before_revert(vol) stopfcmap.assert_called_once_with('4', split=True) + def test_storwize_check_flashcopy_rate_invalid1(self): + with mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_system_info') as get_system_info: + fake_system_info = {'code_level': (7, 6, 0, 0), + 'topology': 'standard', + 'system_name': 'storwize-svc-sim', + 'system_id': '0123456789ABCDEF'} + get_system_info.return_value = fake_system_info + flashcopy_rate = 120 + self.assertRaises(exception.VolumeDriverException, + self.storwize_svc_common.check_flashcopy_rate, + flashcopy_rate) + + def test_storwize_check_flashcopy_rate_invalid2(self): + with mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_system_info') as get_system_info: + fake_system_info = {'code_level': (7, 8, 1, 2), + 'topology': 'standard', + 'system_name': 'storwize-svc-sim', + 'system_id': '0123456789ABCDEF'} + get_system_info.return_value = fake_system_info + flashcopy_rate = 200 + self.assertRaises(exception.InvalidInput, + self.storwize_svc_common.check_flashcopy_rate, + flashcopy_rate) + @ddt.ddt class StorwizeSSHTestCase(test.TestCase): 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 417dfc31455..2e9c3399570 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -754,6 +754,7 @@ class StorwizeHelpers(object): def __init__(self, run_ssh): self.ssh = StorwizeSSH(run_ssh) self.check_fcmapping_interval = 3 + self.code_level = None @staticmethod def handle_keyerror(cmd, out): @@ -1960,18 +1961,20 @@ class StorwizeHelpers(object): return volume_model_updates def check_flashcopy_rate(self, flashcopy_rate): - sys_info = self.get_system_info() - code_level = sys_info['code_level'] + if not self.code_level: + sys_info = self.get_system_info() + self.code_level = sys_info['code_level'] + if flashcopy_rate not in range(1, 151): raise exception.InvalidInput( reason=_('The configured flashcopy rate should be ' 'between 1 and 150.')) - elif code_level < (7, 8, 1, 0) and flashcopy_rate > 100: + elif self.code_level < (7, 8, 1, 0) and flashcopy_rate > 100: msg = (_('The configured flashcopy rate is %(fc_rate)s, The ' 'storage code level is %(code_level)s, the flashcopy_rate' ' range is 1-100 if the storwize code level ' 'below 7.8.1.') % {'fc_rate': flashcopy_rate, - 'code_level': code_level}) + 'code_level': self.code_level}) LOG.error(msg) raise exception.VolumeDriverException(message=msg) diff --git a/releasenotes/notes/bug-1890586-storwize-check_flashcopy_rate-fix-571e6e182b604725.yaml b/releasenotes/notes/bug-1890586-storwize-check_flashcopy_rate-fix-571e6e182b604725.yaml new file mode 100644 index 00000000000..76a5eddacee --- /dev/null +++ b/releasenotes/notes/bug-1890586-storwize-check_flashcopy_rate-fix-571e6e182b604725.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + `Bug #1890586 `_: + IBM Storwize: Fixed issues in check_flashcopy_rate that impacts + the performance during Group Snapshot/Clone operations for bulk + volumes.