From: Haomai Wang Date: Fri, 6 Sep 2013 13:37:01 +0000 (+0800) Subject: Fix error casting value to float in lvm.py X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=9334cc1913a997d462e784429cc491cb0d6c7f76;p=openstack-build%2Fcinder-build.git Fix error casting value to float in lvm.py 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 --- diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index c55975fb6..bee80ba20 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -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') diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index afd9ad5a3..b951467ae 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -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