]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Report *real* free capacity in Huawei driver
authorWilson Liu <liuxinguo@huawei.com>
Thu, 24 Sep 2015 08:52:31 +0000 (16:52 +0800)
committerWilson Liu <liuxinguo@huawei.com>
Tue, 29 Sep 2015 07:12:14 +0000 (07:12 +0000)
When we query capacity of a storage pool on Huawei storage,
there are two items in the result: one is "USERFREECAPACITY"
and the another one is "DATASPACE". In fact the "DATASPACE"
is the *real* space we can use to create LUN, the
"USERFREECAPACITY" contains some metadata that we can not use
to store user data.

Closes-Bug: #1499227
Change-Id: I34a8c67dea2a7b7f5a2a693a65c9303b2cc3d972
(cherry picked from commit e28e87258351c4c0d261d7c04ce495ef73e1520c)

cinder/tests/unit/test_huawei_drivers.py
cinder/volume/drivers/huawei/rest_client.py

index 17e91969093cd6e1578339a5385c6f9a579add5c..1cf0eb6224da0037a2bbde8c46ac254b0c563cf3 100644 (file)
@@ -59,20 +59,6 @@ fake_smartx_value = {'smarttier': 'true',
                      'partitionname': 'partition-test',
                      }
 
-error_volume = {'name': 'volume-21ec7341-9256-497b-97d9-ef48edcf0637',
-                'size': 2,
-                'volume_name': 'vol2',
-                'id': '21ec7341-9256-497b-97d9-ef48edcf0637',
-                'volume_id': '21ec7341-9256-497b-97d9-ef48edcf0637',
-                'provider_auth': None,
-                'project_id': 'project',
-                'display_name': 'vol2',
-                'display_description': 'test error_volume',
-                'volume_type_id': None,
-                'host': 'ubuntu@huawei#OpenStack_Pool_error',
-                'provider_location': '12',
-                }
-
 test_snap = {'name': 'volume-21ec7341-9256-497b-97d9-ef48edcf0635',
              'size': 1,
              'volume_name': 'vol1',
@@ -1475,9 +1461,6 @@ class Huawei18000ISCSIDriverTestCase(test.TestCase):
         self.assertRaises(exception.VolumeBackendAPIException,
                           self.driver.create_volume, test_volume)
 
-        self.assertRaises(exception.VolumeBackendAPIException,
-                          self.driver.create_volume, error_volume)
-
     def test_delete_volume_fail(self):
         self.driver.restclient.login()
         self.driver.restclient.test_fail = True
@@ -1607,7 +1590,13 @@ class Huawei18000ISCSIDriverTestCase(test.TestCase):
                  "ID": "1",
                  "USERFREECAPACITY": "37",
                  "USERTOTALCAPACITY": "49",
-                 "USAGETYPE": constants.FILE_SYSTEM_POOL_TYPE}]}
+                 "USAGETYPE": constants.FILE_SYSTEM_POOL_TYPE},
+                {"NAME": "test003",
+                 "ID": "0",
+                 "USERFREECAPACITY": "36",
+                 "DATASPACE": "35",
+                 "USERTOTALCAPACITY": "48",
+                 "USAGETYPE": constants.BLOCK_STORAGE_POOL_TYPE}]}
         pool_name = 'test001'
         test_info = {'CAPACITY': '36', 'ID': '0', 'TOTALCAPACITY': '48'}
         pool_info = self.driver.restclient.find_pool_info(pool_name, pools)
@@ -1623,6 +1612,11 @@ class Huawei18000ISCSIDriverTestCase(test.TestCase):
         pool_info = self.driver.restclient.find_pool_info(pool_name, pools)
         self.assertEqual(test_info, pool_info)
 
+        pool_name = 'test003'
+        test_info = {'CAPACITY': '35', 'ID': '0', 'TOTALCAPACITY': '48'}
+        pool_info = self.driver.restclient.find_pool_info(pool_name, pools)
+        self.assertEqual(test_info, pool_info)
+
     def test_get_smartx_specs_opts(self):
         self.driver.restclient.login()
         smartx_opts = smartx.SmartX().get_smartx_specs_opts(smarttier_opts)
@@ -1838,9 +1832,6 @@ class Huawei18000FCDriverTestCase(test.TestCase):
         self.assertRaises(exception.VolumeBackendAPIException,
                           self.driver.create_volume, test_volume)
 
-        self.assertRaises(exception.VolumeBackendAPIException,
-                          self.driver.create_volume, error_volume)
-
     def test_delete_volume_fail(self):
         self.driver.restclient.login()
         self.driver.restclient.test_fail = True
index f04814806a3e9e79794a59754673aefd0384ec6e..36b1523a5b4da9b29157d02b6de4579ccf30c8ab 100644 (file)
@@ -216,7 +216,8 @@ class RestClient(object):
                        item['USAGETYPE'] == constants.FILE_SYSTEM_POOL_TYPE):
                         break
                     pool_info['ID'] = item['ID']
-                    pool_info['CAPACITY'] = item['USERFREECAPACITY']
+                    pool_info['CAPACITY'] = item.get('DATASPACE',
+                                                     item['USERFREECAPACITY'])
                     pool_info['TOTALCAPACITY'] = item['USERTOTALCAPACITY']
                     break
         return pool_info