summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-10-13 16:23:14 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-10-15 16:16:00 -1000
commitafde152b88a270ce5db3057a385be1bfff491631 (patch)
tree12146791c69fde71d70bff32278fee09f3be6646 /storage
parent8549a36d4b22171992951a272b82f0aa14234dc4 (diff)
downloadanaconda-afde152b88a270ce5db3057a385be1bfff491631.tar.gz
anaconda-afde152b88a270ce5db3057a385be1bfff491631.tar.xz
anaconda-afde152b88a270ce5db3057a385be1bfff491631.zip
Add dracutSetupString() method to ZFCPDiskDevice (#526354).
Collect CCW bus ID, WWPN, and FCP LUN values for zFCP devices when building the device tree. Store these in the ZFCPDiskDevice object and use them to generate the rd_ZFCP= string for dracut. Expand storage/udev.py with functions to determine if a device is zFCP and to get arbitrary attribute values.
Diffstat (limited to 'storage')
-rw-r--r--storage/devices.py25
-rw-r--r--storage/devicetree.py7
-rw-r--r--storage/udev.py42
3 files changed, 62 insertions, 12 deletions
diff --git a/storage/devices.py b/storage/devices.py
index 9fafeb611..9166b6cf6 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -3135,23 +3135,24 @@ class ZFCPDiskDevice(DiskDevice):
""" A mainframe ZFCP disk. """
_type = "zfcp"
- def __init__(self, name, size=None, major=None, minor=None,
- devnum=None, wwpn=None, fcplun=None,
- parents=None, sysfsPath=''):
- self.devnum = devnum
- self.wwpn = wwpn
- self.fcplun = fcplun
- name = "zfcp://%s/%s/%s" % (self.devnum, self.wwpn, self.fcplun)
- DiskDevice.__init__(self, name, size=size,
- major=major, minor=minor,
- parents=parents, sysfsPath=sysfsPath)
+ def __init__(self, name, **kwargs):
+ self.hba_id = kwargs.get("hba_id")
+ self.wwpn = kwargs.get("wwpn")
+ self.fcp_lun = kwargs.get("fcp_lun")
+ name = "zfcp://%s/%s/%s" % (self.hba_id, self.wwpn, self.fcplun,)
+ DiskDevice.__init__(self, name, **kwargs)
def __str__(self):
s = DiskDevice.__str__(self)
- s += (" devnum = %(devnum)s wwpn = %(wwpn)s fcplun = %(fcplun)s" %
- {"devnum": self.devnum, "wwpn": self.wwpn, "fcplun": self.fcplun})
+ s += (" hba_id = %(hba_id)s wwpn = %(wwpn)s fcp_lun = %(fcp_lun)s" %
+ {"hba_id": self.hba_id,
+ "wwpn": self.wwpn,
+ "fcp_lun": self.fcp_lun})
return s
+ def dracutSetupString(self):
+ return "rd_ZFCP=%s,%s,%s" % (self.hba_id, self.wwpn, self.fcp_lun,)
+
class DASDDevice(DiskDevice):
""" A mainframe DASD. """
diff --git a/storage/devicetree.py b/storage/devicetree.py
index d35580434..d117f4c79 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1193,6 +1193,13 @@ class DeviceTree(object):
elif udev_device_is_dasd(info):
diskType = DASDDevice
log.debug("%s is a dasd device" % name)
+ elif udev_device_is_zfcp(info):
+ diskType = ZFCPDiskDevice
+
+ for attr in ['hba_id', 'wwpn', 'fcp_lun']:
+ kwargs[attr] = udev_device_get_zfcp_attribute(info, attr=attr)
+
+ log.debug("%s is a zfcp device" % name)
else:
diskType = DiskDevice
log.debug("%s is a disk" % name)
diff --git a/storage/udev.py b/storage/udev.py
index d051157b5..bd89007bc 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -165,6 +165,48 @@ def udev_device_is_dasd(info):
else:
return False
+def udev_device_is_zfcp(info):
+ """ Return True if the device is a zfcp device. """
+ if info.get("DEVTYPE") != "disk":
+ return False
+
+ subsystem = "/sys" + info.get("sysfs_path")
+
+ while True:
+ topdir = os.path.realpath(os.path.dirname(subsystem))
+ driver = "%s/driver" % (topdir,)
+
+ if os.path.islink(driver):
+ subsystemname = os.path.basename(os.readlink(subsystem))
+ drivername = os.path.basename(os.readlink(driver))
+
+ if subsystemname == 'ccw' and drivername == 'zfcp':
+ return True
+
+ newsubsystem = os.path.dirname(topdir)
+
+ if newsubsystem == topdir:
+ break
+
+ subsystem = newsubsystem + "/subsystem"
+
+ return False
+
+def udev_device_get_zfcp_attribute(info, attr=None):
+ """ Return the value of the specified attribute of the zfcp device. """
+ if not attr:
+ log.debug("udev_device_get_zfcp_attribute() called with attr=None")
+ return None
+
+ attribute = "/sys%s/devices/%s" % (info.get("sysfs_path"), attr,)
+ attribute = os.path.realpath(attribute)
+
+ if not os.path.isfile(attribute):
+ log.warning("%s is not a valid zfcp attribute" % (attribute,))
+ return None
+
+ return open(attribute, "r").read().strip()
+
def udev_device_is_cdrom(info):
""" Return True if the device is an optical drive. """
# FIXME: how can we differentiate USB drives from CD-ROM drives?