From: rajinir Date: Mon, 5 Oct 2015 20:56:40 +0000 (-0500) Subject: Dell Eqlx: Support over subscription in thin provisioning X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=845255127c540189d8f9f70ed98afb48b7086663;p=openstack-build%2Fcinder-build.git Dell Eqlx: Support over subscription in thin provisioning Dell eqlx driver reports the following new stats: * provisioned_capacity * max_over_subscription_ratio * thin_provisioning_support (True or False) * thick_provisioning_support (True or False) Change-Id: I09176259840eb5b52a5f4ec1942db2bf152667d0 Implements: blueprint dell-eqlx-over-subscription-thin-provisioning --- diff --git a/cinder/tests/unit/test_eqlx.py b/cinder/tests/unit/test_eqlx.py index ab911c645..092131453 100644 --- a/cinder/tests/unit/test_eqlx.py +++ b/cinder/tests/unit/test_eqlx.py @@ -55,6 +55,11 @@ class DellEQLSanISCSIDriverTestCase(test.TestCase): self.configuration.chap_username = 'admin' self.configuration.chap_password = 'password' + self.configuration.max_over_subscription_ratio = 1.0 + + self.driver_stats_output = ['TotalCapacity: 111GB', + 'FreeSpace: 11GB', + 'VolumeReserve: 80GB'] self.cmd = 'this is dummy command' self._context = context.get_admin_context() self.driver = eqlx.DellEQLSanISCSIDriver( @@ -233,29 +238,64 @@ class DellEQLSanISCSIDriverTestCase(test.TestCase): self.driver.do_setup(self._context) self.assertEqual(fake_group_ip, self.driver._group_ip) - def test_update_volume_stats(self): + def test_update_volume_stats_thin(self): mock_attrs = {'args': ['pool', 'select', self.configuration.eqlx_pool, 'show']} + self.configuration.san_thin_provision = True with mock.patch.object(self.driver, '_eql_execute') as mock_eql_execute: mock_eql_execute.configure_mock(**mock_attrs) - mock_eql_execute.return_value = ['TotalCapacity: 111GB', - 'FreeSpace: 11GB'] + mock_eql_execute.return_value = self.driver_stats_output self.driver._update_volume_stats() - self.assertEqual(111.0, self.driver._stats['total_capacity_gb']) - self.assertEqual(11.0, self.driver._stats['free_capacity_gb']) + self.assert_volume_stats(self.driver._stats) - def test_get_volume_stats(self): + def test_update_volume_stats_thick(self): mock_attrs = {'args': ['pool', 'select', self.configuration.eqlx_pool, 'show']} + self.configuration.san_thin_provision = False with mock.patch.object(self.driver, '_eql_execute') as mock_eql_execute: mock_eql_execute.configure_mock(**mock_attrs) - mock_eql_execute.return_value = ['TotalCapacity: 111GB', - 'FreeSpace: 11GB'] + mock_eql_execute.return_value = self.driver_stats_output + self.driver._update_volume_stats() + self.assert_volume_stats(self.driver._stats) + + def test_get_volume_stats_thin(self): + mock_attrs = {'args': ['pool', 'select', + self.configuration.eqlx_pool, 'show']} + self.configuration.san_thin_provision = True + with mock.patch.object(self.driver, + '_eql_execute') as mock_eql_execute: + mock_eql_execute.configure_mock(**mock_attrs) + mock_eql_execute.return_value = self.driver_stats_output stats = self.driver.get_volume_stats(refresh=True) + self.assert_volume_stats(stats) + + def test_get_volume_stats_thick(self): + mock_attrs = {'args': ['pool', 'select', + self.configuration.eqlx_pool, 'show']} + self.configuration.san_thin_provision = False + with mock.patch.object(self.driver, + '_eql_execute') as mock_eql_execute: + mock_eql_execute.configure_mock(**mock_attrs) + mock_eql_execute.return_value = self.driver_stats_output + stats = self.driver.get_volume_stats(refresh=True) + self.assert_volume_stats(stats) + + def assert_volume_stats(self, stats): + thin_enabled = self.configuration.san_thin_provision self.assertEqual(float('111.0'), stats['total_capacity_gb']) self.assertEqual(float('11.0'), stats['free_capacity_gb']) + + if thin_enabled: + self.assertEqual(80.0, stats['provisioned_capacity_gb']) + else: + space = stats['total_capacity_gb'] - stats['free_capacity_gb'] + self.assertEqual(space, stats['provisioned_capacity_gb']) + + self.assertEqual(thin_enabled, stats['thin_provisioning_support']) + self.assertEqual(not thin_enabled, + stats['thick_provisioning_support']) self.assertEqual('Dell', stats['vendor_name']) def test_get_space_in_gb(self): diff --git a/cinder/volume/drivers/eqlx.py b/cinder/volume/drivers/eqlx.py index 31137fa52..3e01f50f6 100644 --- a/cinder/volume/drivers/eqlx.py +++ b/cinder/volume/drivers/eqlx.py @@ -327,6 +327,8 @@ class DellEQLSanISCSIDriver(san.SanISCSIDriver): data['total_capacity_gb'] = 0 data['free_capacity_gb'] = 0 + provisioned_capacity = 0 + for line in self._eql_execute('pool', 'select', self.configuration.eqlx_pool, 'show'): if line.startswith('TotalCapacity:'): @@ -335,6 +337,22 @@ class DellEQLSanISCSIDriver(san.SanISCSIDriver): if line.startswith('FreeSpace:'): out_tup = line.rstrip().partition(' ') data['free_capacity_gb'] = self._get_space_in_gb(out_tup[-1]) + if line.startswith('VolumeReserve:'): + out_tup = line.rstrip().partition(' ') + provisioned_capacity = self._get_space_in_gb(out_tup[-1]) + + global_capacity = data['total_capacity_gb'] + global_free = data['free_capacity_gb'] + + thin_enabled = self.configuration.san_thin_provision + if not thin_enabled: + provisioned_capacity = round(global_capacity - global_free, 2) + + data['provisioned_capacity_gb'] = provisioned_capacity + data['max_over_subscription_ratio'] = ( + self.configuration.max_over_subscription_ratio) + data['thin_provisioning_support'] = thin_enabled + data['thick_provisioning_support'] = not thin_enabled self._stats = data