]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Change the type of "free_capacity_gb" to be float
authorzhangchao010 <zhangchao010@huawei.com>
Fri, 10 May 2013 12:25:53 +0000 (20:25 +0800)
committerGerrit Code Review <review@openstack.org>
Sat, 11 May 2013 02:30:44 +0000 (02:30 +0000)
Change the type of "free_capacity_gb" from string to float
in function _get_free_capacity.

Fix bug: 1177678
Change-Id: If2654fc3ad6b3dbea6a8cc0be7ae041ad30bf876

cinder/tests/test_huawei.py
cinder/volume/drivers/huawei/huawei_iscsi.py

index fd3914b9277a53e6f1d2f3c9146b58d7b7103650..0ff2c0115a98dea9ffc39f82cd38b82b58f20f8f 100644 (file)
@@ -390,7 +390,7 @@ class HuaweiVolumeTestCase(test.TestCase):
     def _test_get_get_volume_stats(self):
         stats = self.driver.get_volume_stats(True)
 
-        fakecapacity = str(int(float(FakePoolInfo['Free Capacity']) / 1024))
+        fakecapacity = float(FakePoolInfo['Free Capacity']) / 1024
         self.assertEqual(stats['free_capacity_gb'], fakecapacity)
 
 
index 617f52358003aa27deadd56238f3dad130506166..869552d0304f2839ce8d7524e16c4d09412bfea5 100644 (file)
@@ -1525,7 +1525,7 @@ class HuaweiISCSIDriver(driver.ISCSIDriver):
             lun_type = 'Thick'
         poolinfo_dev = self._find_pool_info(lun_type)
         pools_conf = root.findall('LUN/StoragePool')
-        total_free_capacity = 0
+        total_free_capacity = 0.0
         for poolinfo in poolinfo_dev:
             if self.device_type['type'] == 'Dorado2100 G2':
                 total_free_capacity += float(poolinfo[2])
@@ -1544,4 +1544,4 @@ class HuaweiISCSIDriver(driver.ISCSIDriver):
                         total_free_capacity += float(poolinfo[4])
                         break
 
-        return str(int(total_free_capacity / 1024))
+        return total_free_capacity / 1024