[node-patches] Change in ovirt-node[ovirt-3.5]: Rework detection of multipath disks to remove in the installer

fabiand at redhat.com fabiand at redhat.com
Wed Jun 24 14:40:01 UTC 2015


Fabian Deutsch has uploaded a new change for review.

Change subject: Rework detection of multipath disks to remove in the installer
......................................................................

Rework detection of multipath disks to remove in the installer

Checking whether "somestring" in "somestring" leads to bad
results when we check if "sda" is part of "sdaa sdab...". Don't
spuriously remove valid disks. Use a dict instead and check
against that. Log the original output, just in case it's ever
needed anywhere.

Also, use a set to ensure unique values instead of looping through
and decrementing the count.

Change-Id: I20be68e232e25e9a751516edbaece69c0b81107d
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1203176
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirtnode/storage.py
1 file changed, 14 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/19/42819/1

diff --git a/src/ovirtnode/storage.py b/src/ovirtnode/storage.py
index a690391..a7fcbdb 100644
--- a/src/ovirtnode/storage.py
+++ b/src/ovirtnode/storage.py
@@ -319,7 +319,8 @@
                     devices.append("/dev/cciss/%s" % d)
 
         # include multipath devices
-        devs_to_remove = ""
+        mpath_sets = ""
+        devs_to_remove = {}
         multipath_list_cmd = "dmsetup ls --target=multipath | cut -f1"
         multipath_list = _functions.subprocess_closefds(multipath_list_cmd,
                                              shell=True,
@@ -338,22 +339,23 @@
                                          stdout=subprocess.PIPE,
                                          stderr=subprocess.STDOUT)
             dm_dev_output, dm_dev_err = dm_dev.communicate()
-            devs_to_remove = ("%s %s %s" % (devs_to_remove, sd_devs,
-                                          dm_dev_output))
+            [devs_to_remove.update({d: True}) for d in sd_devs.split()]
+            mpath_sets = ("%s %s %s" % (mpath_sets, sd_devs,
+                                        dm_dev_output))
+
+        logger.debug("Multipath sets are %s" % mpath_sets)
+        logger.debug("Removing the following from the list of disks, because "
+                     "they're part of a multipath set: %s" % sorted(
+                         devs_to_remove))
+
         # Remove /dev/sd* devices that are part of a multipath device
-        dev_list = []
+        dev_list = set()
         for d in devices:
             if (os.path.basename(d) not in devs_to_remove and
                     not "/dev/dm-" in d):
-                dev_list.append(d)
+                dev_list.add(d)
 
-        for dev in dev_list:
-            if dev_list.count(dev) > 1:
-                count = dev_list.count(dev)
-                while (count > 1):
-                    dev_list.remove(dev)
-                    count = count - 1
-        return dev_list
+        return list(dev_list)
 
     def get_udev_devices(self):
         self.disk_dict = {}


-- 
To view, visit https://gerrit.ovirt.org/42819
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I20be68e232e25e9a751516edbaece69c0b81107d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at redhat.com>



More information about the node-patches mailing list