Add the ability to identify if a disk is an FCoE device and to get the identifier of the disk and the name of the NIC used to connect to an FCoE disk --- storage/udev.py | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/storage/udev.py b/storage/udev.py index af3ee12..d057cf2 100644 --- a/storage/udev.py +++ b/storage/udev.py @@ -386,3 +386,30 @@ def udev_device_get_iscsi_port(info): path_components = info["ID_PATH"].split("-")
return path_components[1].split(":")[1] + +# fcoe disks have ID_PATH in the form of: +# pci-eth#-fc-${id} +# fcoe parts look like this: +# pci-eth#-fc-${id}-part# +def udev_device_is_fcoe(info): + try: + path_components = info["ID_PATH"].split("-") + + if info["ID_BUS"] == "scsi" and len(path_components) >= 4 and \ + path_components[0] == "pci" and path_components[2] == "fc" and \ + path_components[1][0:3] == "eth": + return True + except KeyError: + pass + + return False + +def udev_device_get_fcoe_nic(info): + path_components = info["ID_PATH"].split("-") + + return path_components[1] + +def udev_device_get_fcoe_identifier(info): + path_components = info["ID_PATH"].split("-") + + return path_components[3]
--- storage/devices.py | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/storage/devices.py b/storage/devices.py index c2d4ec9..40501d7 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -359,7 +359,7 @@ class Device(object): class NetworkStorageDevice(object): """ Virtual base class for network backed storage devices """
- def __init__(self, host_address): + def __init__(self, host_address=None, nic=None): """ Create a NetworkStorage Device instance. Note this class is only to be used as a baseclass and then only with multiple inheritance. The only correct use is: @@ -369,13 +369,15 @@ class NetworkStorageDevice(object): 1) Be able to check if a StorageDevice is network backed (using isinstance). 2) To be able to get the host address of the host (server) backing - the storage. + the storage *or* the NIC through which the storage is connected
Arguments:
host_address -- host address of the backing server + nic -- nic to which the storage is bound """ self.host_address = host_address + self.nic = nic
class StorageDevice(Device): @@ -2927,10 +2929,23 @@ class iScsiDiskDevice(DiskDevice, NetworkStorageDevice): self.iscsi_address = kwargs.pop("iscsi_address") self.iscsi_port = int(kwargs.pop("iscsi_port")) DiskDevice.__init__(self, device, **kwargs) - NetworkStorageDevice.__init__(self, self.iscsi_address) + NetworkStorageDevice.__init__(self, host_address=self.iscsi_address) log.debug("created new iscsi disk %s %s:%d" % (self.iscsi_name, self.iscsi_address, self.iscsi_port))
+class FcoeDiskDevice(DiskDevice, NetworkStorageDevice): + """ An FCoE disk. """ + _type = "fcoe" + _packages = ["fcoe-utils"] + + def __init__(self, device, **kwargs): + self.nic = kwargs.pop("nic") + self.identifier = kwargs.pop("identifier") + DiskDevice.__init__(self, device, **kwargs) + NetworkStorageDevice.__init__(self, nic=self.nic) + log.debug("created new fcoe disk %s @ %s" % (device, self.nic)) + + class OpticalDevice(StorageDevice): """ An optical drive, eg: cdrom, dvd+r, &c.
Add FCoE disks to the devicetree with a type of FcoeDiskDevice instead of DiskDevice --- storage/devicetree.py | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/storage/devicetree.py b/storage/devicetree.py index 9ffe726..08846f3 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -1152,6 +1152,11 @@ class DeviceTree(object): kwargs["iscsi_address"] = udev_device_get_iscsi_address(info) kwargs["iscsi_port"] = udev_device_get_iscsi_port(info) log.debug("%s is an iscsi disk" % name) + elif udev_device_is_fcoe(info): + diskType = FcoeDiskDevice + kwargs["nic"] = udev_device_get_fcoe_nic(info) + kwargs["identifier"] = udev_device_get_fcoe_identifier(info) + log.debug("%s is an fcoe disk" % name) else: diskType = DiskDevice log.debug("%s is a disk" % name)
On Thu, 2009-07-02 at 12:28 +0200, Hans de Goede wrote:
Add the ability to identify if a disk is an FCoE device and to get the identifier of the disk and the name of the NIC used to connect to an FCoE disk
One comment, below.
storage/udev.py | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/storage/udev.py b/storage/udev.py index af3ee12..d057cf2 100644 --- a/storage/udev.py +++ b/storage/udev.py @@ -386,3 +386,30 @@ def udev_device_get_iscsi_port(info): path_components = info["ID_PATH"].split("-")
return path_components[1].split(":")[1]
+# fcoe disks have ID_PATH in the form of: +# pci-eth#-fc-${id} +# fcoe parts look like this: +# pci-eth#-fc-${id}-part# +def udev_device_is_fcoe(info):
- try:
path_components = info["ID_PATH"].split("-")
if info["ID_BUS"] == "scsi" and len(path_components) >= 4 and \
path_components[0] == "pci" and path_components[2] == "fc" and \
path_components[1][0:3] == "eth":
return True
- except KeyError:
pass
If you use LookupError instead, it will also catch index errors in the event that the ID_PATH value is somehow invalid.
Dave
- return False
+def udev_device_get_fcoe_nic(info):
- path_components = info["ID_PATH"].split("-")
- return path_components[1]
+def udev_device_get_fcoe_identifier(info):
- path_components = info["ID_PATH"].split("-")
- return path_components[3]
anaconda-devel@lists.fedoraproject.org