]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix error casting value to float in lvm.py
authorHaomai Wang <haomai@unitedstack.com>
Fri, 6 Sep 2013 13:37:01 +0000 (21:37 +0800)
committerHaomai Wang <haomai@unitedstack.com>
Fri, 6 Sep 2013 15:01:24 +0000 (23:01 +0800)
Special locale setting may result in that "vgs" command output different
results. Such as:

$ LC_NUMERIC='es_ES.UTF-8' sudo vgs
VG #PV #LV #SN Attr VSize VFree
vg_eharney 1 6 1 wz--n- 465,25g 12,97g

Fix bug 1219963

Change-Id: Ibe79d5ce673738d8e37f86de9106ab347c21bd52

cinder/brick/local_dev/lvm.py
cinder/volume/drivers/lvm.py

index c55975fb6b7cb91de4c512a13971c8a0780c0b11..bee80ba20583f600d96dee378c865d059b45ff8b 100644 (file)
@@ -250,10 +250,8 @@ class LVM(executor.Executor):
         :returns: List of Dictionaries with VG info
 
         """
-        cmd = ['vgs', '--noheadings',
-               '--unit=g', '-o',
-               'name,size,free,lv_count,uuid',
-               '--separator', ':']
+        cmd = ['env', 'LC_ALL=C', 'LANG=C', 'vgs', '--noheadings', '--unit=g',
+               '-o', 'name,size,free,lv_count,uuid', '--separator', ':']
 
         if no_suffix:
             cmd.append('--nosuffix')
index afd9ad5a39e7789b29f67e7e911af32e417bb2c3..b951467ae48c2e104796821b86590e40f0022e18 100644 (file)
@@ -341,9 +341,8 @@ class LVMVolumeDriver(driver.VolumeDriver):
         data["driver_version"] = self.VERSION
         data["storage_protocol"] = 'local'
 
-        data['total_capacity_gb'] = float(self.vg.vg_size.replace(',', '.'))
-        data['free_capacity_gb'] =\
-            float(self.vg.vg_free_space.replace(',', '.'))
+        data['total_capacity_gb'] = float(self.vg.vg_size)
+        data['free_capacity_gb'] = float(self.vg.vg_free_space)
         data['reserved_percentage'] = self.configuration.reserved_percentage
         data['QoS_support'] = False
         data['location_info'] =\
@@ -686,7 +685,7 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver):
         data["driver_version"] = self.VERSION
         data["storage_protocol"] = 'iSCSI'
 
-        data['total_capacity_gb'] = float(self.vg.vg_size.replace(',', '.'))
+        data['total_capacity_gb'] = float(self.vg.vg_size)
         data['free_capacity_gb'] = float(self.vg.vg_free_space)
         data['reserved_percentage'] = self.configuration.reserved_percentage
         data['QoS_support'] = False
@@ -871,9 +870,8 @@ class LVMISERDriver(LVMISCSIDriver, driver.ISERDriver):
         data["vendor_name"] = 'Open Source'
         data["driver_version"] = self.VERSION
         data["storage_protocol"] = 'iSER'
-        data['total_capacity_gb'] = float(self.vg.vg_size.replace(',', '.'))
-        data['free_capacity_gb'] =\
-            float(self.vg.vg_free_space.replace(',', '.'))
+        data['total_capacity_gb'] = float(self.vg.vg_size)
+        data['free_capacity_gb'] = float(self.vg.vg_free_space)
 
         data['reserved_percentage'] = self.configuration.reserved_percentage
         data['QoS_support'] = False