]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Dell Eqlx: Support over subscription in thin provisioning
authorrajinir <rajini_ram@dell.com>
Mon, 5 Oct 2015 20:56:40 +0000 (15:56 -0500)
committerrajinir <rajini_ram@dell.com>
Tue, 6 Oct 2015 15:28:51 +0000 (10:28 -0500)
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

cinder/tests/unit/test_eqlx.py
cinder/volume/drivers/eqlx.py

index ab911c645161f233951dee65b87f3aa3176e5c0b..092131453254378001750715813384c5fc38e529 100644 (file)
@@ -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):
index 31137fa524b4fbca2675cb8a1da05fdb7ca49227..3e01f50f615c225fd6bb23a6e0831e963d29e222 100644 (file)
@@ -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