]> 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>
Mon, 28 Sep 2015 11:01:15 +0000 (19:01 +0800)
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

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

index 04ee21d08b8a7c60f2d25b0c1a0d02f134317c88..a7327132a3e28f2293fe24ad7e5c2394abd982ee 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',
@@ -1476,9 +1462,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
@@ -1608,7 +1591,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)
@@ -1624,6 +1613,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)
@@ -1877,9 +1871,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 e2db78ead4b4ad4f8794d9076c85bcec006745a8..6a94a77995c8eadd896e15bbe5ee9221bc674275 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