From cead51cea86166a59c3301799c6e5294f4bc863b Mon Sep 17 00:00:00 2001 From: venkatakrishnathumu Date: Mon, 7 Sep 2020 15:39:16 +0000 Subject: [PATCH] [Storwize] Provide IOPS based storage offering Added fucntionality that returns throttle rate of maximum IOPS and bandwidth of all VDisks of a specified storage pool. Change-Id: I01ccc1acedb776cd4e2344cdc6adad167023c4f9 --- .../volume/drivers/ibm/test_storwize_svc.py | 45 +++++++++++++++++++ .../ibm/storwize_svc/storwize_svc_common.py | 26 +++++++++++ ...sed-storage-offering-1b7532f42fd6d76e.yaml | 6 +++ 3 files changed, 77 insertions(+) create mode 100644 releasenotes/notes/ibm-svf-provide-IOPs-based-storage-offering-1b7532f42fd6d76e.yaml 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 31e9c3d4053..188896ee2a2 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -5410,6 +5410,51 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): if 'CMMVC7050E' not in e.stderr: raise + @ddt.data(('IOPs_limit', "50"), ('bandwidth_limit_MB', "100")) + @mock.patch.object(storwize_svc_common.StorwizeHelpers, 'get_pool_volumes') + @mock.patch.object(storwize_svc_common.StorwizeSSH, 'lsthrottle') + @ddt.unpack + def test_storwize_svc_max_pool_throttle_rate(self, fake_throttle_name, + fake_throttle_value, + io_throttles, + get_pool_volumes): + pools = _get_test_pool(get_all=True) + for pool in pools: + vol_throttles = [] + expected_throttle_value = 0 + if 'openstack' == pool: + # Create volumes in the pool 'openstack' + host = 'openstack@svc#%s' % pool + vol1 = testutils.create_volume( + self.ctxt, host=host, + volume_type_id=self.vt['id']) + self.driver.create_volume(vol1) + self._assert_vol_exists(vol1['name'], True) + + vol2 = testutils.create_volume( + self.ctxt, host=host, + volume_type_id=self.vt['id']) + self.driver.create_volume(vol2) + self._assert_vol_exists(vol1['name'], True) + + # Set io_throttle values to volumes + vol_throttles = [ + {'object_name': vol1.name, 'IOPs_limit': '20', + 'bandwidth_limit_MB': '40'}, + {'object_name': vol2.name, 'IOPs_limit': '30', + 'bandwidth_limit_MB': '60'}] + expected_throttle_value = int(fake_throttle_value) + + get_pool_volumes.return_value = [vol1, vol2] + io_throttles.return_value = vol_throttles + iothrottle_value = ( + self.driver._helpers.get_pool_max_throttle_rate_vdisk( + pool, fake_throttle_name)) + # Check the sum of throttle values set to volumes from a pool + self.assertEqual(expected_throttle_value, iothrottle_value) + self.assertTrue(get_pool_volumes.called) + self.assertTrue(io_throttles.called) + def test_storwize_svc_unicode_host_and_volume_names(self): # We'll check with iSCSI only - nothing protocol-dependent here self.driver.do_setup(None) 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 26c3e9eaaa3..7783f144bb8 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -536,6 +536,13 @@ class StorwizeSSH(object): '-filtervalue', '%s=%s' % (filter_name, value)] return self.run_ssh_info(ssh_cmd, with_header=True) + def lsthrottle(self): + """Returns throttle objects for all vdisks.""" + ssh_cmd = ['svcinfo', 'lsthrottle', '-delim', '!', '-filtervalue', + 'throttle_type=vdisk'] + throttles = self.run_ssh_info(ssh_cmd, with_header=True) + return throttles.result + def chvdisk(self, vdisk, params): ssh_cmd = ['svctask', 'chvdisk'] + params + ['"%s"' % vdisk] self.run_ssh_assert_no_output(ssh_cmd) @@ -904,6 +911,25 @@ class StorwizeHelpers(object): LOG.debug("Selected io_group is %d", selected_iog) return selected_iog + def get_pool_max_throttle_rate_vdisk(self, pool, throttle_rate_type): + """Returns the IOPs or Bandwidth throttle rate. + + Throttle rate of all vdisks for the specified pool. + """ + max_throttle_rate_vdisk = 0 + vdisks = self.get_pool_volumes(pool) + if vdisks: + throttles = self.ssh.lsthrottle() + if throttles: + vdisk_names = [ + vdisk['name'] for vdisk in vdisks if vdisk['name']] + for throttle in throttles: + if (throttle['object_name'] in vdisk_names and + throttle[throttle_rate_type]): + max_throttle_rate_vdisk += int( + throttle[throttle_rate_type]) + return max_throttle_rate_vdisk + def get_volume_io_group(self, vol_name): vdisk = self.ssh.lsvdisk(vol_name) if vdisk: diff --git a/releasenotes/notes/ibm-svf-provide-IOPs-based-storage-offering-1b7532f42fd6d76e.yaml b/releasenotes/notes/ibm-svf-provide-IOPs-based-storage-offering-1b7532f42fd6d76e.yaml new file mode 100644 index 00000000000..21e29388e15 --- /dev/null +++ b/releasenotes/notes/ibm-svf-provide-IOPs-based-storage-offering-1b7532f42fd6d76e.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + IBM Spectrum Virtualize Family driver: Added fucntionality + that returns throttle rate of maximum IOPS and bandwidth of + all VDisks of a specified storage pool.