[PATCH 2/3] Use dm subsystem functions to identify dmraid, mpath partitions.

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

 



Reimplements udev_device_is_dmraid_partition and
udev_device_is_multipath_partition so they no longer require a
DeviceTree instance.
---
 pyanaconda/storage/devicetree.py |    8 +++---
 pyanaconda/storage/udev.py       |   43 ++++++++-----------------------------
 2 files changed, 14 insertions(+), 37 deletions(-)

diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py
index 4caddf5..ab88305 100644
--- a/pyanaconda/storage/devicetree.py
+++ b/pyanaconda/storage/devicetree.py
@@ -1016,12 +1016,12 @@ class DeviceTree(object):
             device = self.getDeviceByName(name)
 
             if device is None:
-                if udev_device_is_multipath_partition(info, self):
-                    diskname = udev_device_get_multipath_partition_disk(info)
+                if udev_device_is_multipath_partition(info):
+                    diskname = udev_device_get_dm_partition_disk(info)
                     disk = self.getDeviceByName(diskname)
                     return self.addUdevPartitionDevice(info, disk=disk)
-                elif udev_device_is_dmraid_partition(info, self):
-                    diskname = udev_device_get_dmraid_partition_disk(info)
+                elif udev_device_is_dmraid_partition(info):
+                    diskname = udev_device_get_dm_partition_disk(info)
                     disk = self.getDeviceByName(diskname)
                     return self.addUdevPartitionDevice(info, disk=disk)
 
diff --git a/pyanaconda/storage/udev.py b/pyanaconda/storage/udev.py
index e978543..fc34914 100644
--- a/pyanaconda/storage/udev.py
+++ b/pyanaconda/storage/udev.py
@@ -440,7 +440,7 @@ def udev_device_is_biosraid(info):
 
     return False
 
-def udev_device_get_dmraid_partition_disk(info):
+def udev_device_get_dm_partition_disk(info):
     try:
         p_index = info["DM_NAME"].rindex("p")
     except (KeyError, AttributeError, ValueError):
@@ -451,43 +451,20 @@ def udev_device_get_dmraid_partition_disk(info):
 
     return info["DM_NAME"][:p_index]
 
-def udev_device_is_dmraid_partition(info, devicetree):
-    diskname = udev_device_get_dmraid_partition_disk(info)
-    dmraid_devices = devicetree.getDevicesByType("dm-raid array")
-
-    for device in dmraid_devices:
-        if diskname == device.name:
-            return True
-
-    return False
-
-def udev_device_is_multipath_partition(info, devicetree):
-    """ Return True if the device is a partition of a multipath device. """
-    if not udev_device_is_dm(info):
-        return False
-    if not info["DM_NAME"].startswith("mpath"):
+def udev_device_is_dmraid_partition(info):
+    if not udev_device_is_dm_raid(info):
         return False
-    diskname = udev_device_get_dmraid_partition_disk(info)
-    if diskname is None:
-        return False
-
-    # this is sort of a lame check, but basically, if diskname gave us "mpath0"
-    # and we start with "mpath" but we're not "mpath0", then we must be
-    # "mpath0" plus some non-numeric crap.
-    if diskname != info["DM_NAME"]:
-        return True
 
-    return False
+    diskname = udev_device_get_dm_partition_disk(info)
+    return diskname not in ("", None)
 
-def udev_device_get_multipath_partition_disk(info):
+def udev_device_is_multipath_partition(info):
     """ Return True if the device is a partition of a multipath device. """
-    # XXX PJFIX This whole function is crap.
-    if not udev_device_is_dm(info):
-        return False
-    if not info["DM_NAME"].startswith("mpath"):
+    if not udev_device_is_dm_mpath(info):
         return False
-    diskname = udev_device_get_dmraid_partition_disk(info)
-    return diskname
+
+    diskname = udev_device_get_dm_partition_disk(info)
+    return diskname not in ("", None)
 
 def udev_device_is_multipath_member(info):
     """ Return True if the device is part of a multipath. """
-- 
1.7.1.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux