From 59fc6cbd95ed83f7dfad2ee9317487d3ab0cc285 Mon Sep 17 00:00:00 2001 From: zhangchao010 Date: Fri, 10 May 2013 20:25:53 +0800 Subject: [PATCH] Change the type of "free_capacity_gb" to be float 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 | 2 +- cinder/volume/drivers/huawei/huawei_iscsi.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cinder/tests/test_huawei.py b/cinder/tests/test_huawei.py index fd3914b92..0ff2c0115 100644 --- a/cinder/tests/test_huawei.py +++ b/cinder/tests/test_huawei.py @@ -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) diff --git a/cinder/volume/drivers/huawei/huawei_iscsi.py b/cinder/volume/drivers/huawei/huawei_iscsi.py index 617f52358..869552d03 100644 --- a/cinder/volume/drivers/huawei/huawei_iscsi.py +++ b/cinder/volume/drivers/huawei/huawei_iscsi.py @@ -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 -- 2.45.2