summaryrefslogtreecommitdiffstats
path: root/storage/udev.py
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2009-05-27 10:49:23 -0400
committerPeter Jones <pjones@redhat.com>2009-08-06 15:37:26 -0400
commit883d99a856ee36c8dcb5e5dfc50fa0cf181bec70 (patch)
tree1084cb2acf1c88cbeff233a4c4858b211f9c42b0 /storage/udev.py
parentd8b635d3e2cfd1af7c95b246a6428adeb78fecee (diff)
downloadanaconda-883d99a856ee36c8dcb5e5dfc50fa0cf181bec70.tar.gz
anaconda-883d99a856ee36c8dcb5e5dfc50fa0cf181bec70.tar.xz
anaconda-883d99a856ee36c8dcb5e5dfc50fa0cf181bec70.zip
Recognize mpath devices when we see them.
This identifies that a device is part of a multipath, and builds an mpath device for partitioning.
Diffstat (limited to 'storage/udev.py')
-rw-r--r--storage/udev.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/storage/udev.py b/storage/udev.py
index 450b54aa6..a8024ddfb 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -134,6 +134,10 @@ def udev_device_get_label(udev_info):
""" Get the label from the device's format as reported by udev. """
return udev_info.get("ID_FS_LABEL")
+def udev_device_is_multipath_member(info):
+ """ Return True if the device is part of a multipath. """
+ return info.get("ID_FS_TYPE") == "multipath_member"
+
def udev_device_is_dm(info):
""" Return True if the device is a device-mapper device. """
return info.has_key("DM_NAME")
@@ -158,6 +162,10 @@ def udev_device_is_partition(info):
has_start = os.path.exists("/sys/%s/start" % info['sysfs_path'])
return info.get("DEVTYPE") == "partition" or has_start
+def udev_device_get_serial(udev_info):
+ """ Get the serial number/UUID from the device as reported by udev. """
+ return udev_info.get("ID_SERIAL_SHORT")
+
def udev_device_get_sysfs_path(info):
return info['sysfs_path']
@@ -276,6 +284,34 @@ def udev_device_is_dmraid_partition(info, devicetree):
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"):
+ 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
+
+def udev_device_get_multipath_partition_disk(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"):
+ return False
+ diskname = udev_device_get_dmraid_partition_disk(info)
+ return diskname
+
# iscsi disks have ID_PATH in the form of:
# ip-${iscsi_address}:${iscsi_port}-iscsi-${iscsi_tgtname}-lun-${lun}
def udev_device_is_iscsi(info):