[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 4/9] Make sure sizes contains only floats in udev_device_get_lv_sizes()



info['LVM2_LV_SIZE'] may contain some entries that are shell
variable syntax, so strip the variable name and equal sign
when building the sizes list.
---
 storage/udev.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/storage/udev.py b/storage/udev.py
index 4f83c2a..d0cf6fb 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -262,12 +262,17 @@ def udev_device_get_lv_uuids(info):
 def udev_device_get_lv_sizes(info):
     # lvm's decmial precision is not configurable, so we tell it to use
     # KB and convert to MB here
+    def _splitVar(var):
+        lst = var.split('=')
+        return lst[len(lst) - 1]
+
     sizes = info['LVM2_LV_SIZE']
     if not sizes:
         sizes = []
     elif not isinstance(sizes, list):
         sizes = [sizes]
 
+    sizes = map(lambda s: _splitVar(s), sizes)
     return [float(s) / 1024 for s in sizes]
 
 
-- 
1.6.1.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]