Add a method to get the bus/interconnect from udev and store it on devices.
Hi,
See comments inline. On 12/01/2009 09:15 PM, Chris Lumens wrote: --- storage/devices.py | 8 +++++--- storage/devicetree.py | 3 ++- storage/udev.py | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/storage/devices.py b/storage/devices.py index 75f9107..e61591c 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -422,7 +422,7 @@ class StorageDevice(Device): def __init__(self, device, format=None, size=None, major=None, minor=None, sysfsPath=', parents=None, exists=None, serial=None, - vendor=""): + vendor="", bus=""): """ Create a StorageDevice instance. Arguments: @@ -454,6 +454,7 @@ class StorageDevice(Device): self.exists = exists self.serial = serial self.vendor = vendor + self.bus = bus self.protected = False @@ -718,7 +719,7 @@ class DiskDevice(StorageDevice): def __init__(self, device, format=None, size=None, major=None, minor=None, sysfsPath=', - parents=None, serial=None, vendor=""): + parents=None, serial=None, vendor="", bus=""): """ Create a DiskDevice instance. Arguments: @@ -736,6 +737,7 @@ class DiskDevice(StorageDevice): removable -- whether or not this is a removable device serial -- the ID_SERIAL_SHORT for this device vendor -- the manufacturer of this Device + bus -- the interconnect this device uses DiskDevices always exist. @@ -743,7 +745,7 @@ class DiskDevice(StorageDevice): StorageDevice.__init__(self, device, format=format, size=size, major=major, minor=minor, exists=True, sysfsPath=sysfsPath, parents=parents, - serial=serial, vendor=vendor) + serial=serial, vendor=vendor, bus=bus) def __str__(self): s = StorageDevice.__str__(self) diff --git a/storage/devicetree.py b/storage/devicetree.py index 6090dd3..a5a59e7 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -1166,6 +1166,7 @@ class DeviceTree(object): uuid = udev_device_get_uuid(info) sysfs_path = udev_device_get_sysfs_path(info) serial = udev_device_get_serial(info) + bus = udev_device_get_bus(info) try: # udev doesn't always provide a vendor. @@ -1223,7 +1224,7 @@ class DeviceTree(object): device = diskType(name, serial=serial, vendor=vendor, major=udev_device_get_major(info), minor=udev_device_get_minor(info), - sysfsPath=sysfs_path, **kwargs) + sysfsPath=sysfs_path, bus=bus, **kwargs) self._addDevice(device) return device diff --git a/storage/udev.py b/storage/udev.py index aa131b4..4ea9a94 100644 --- a/storage/udev.py +++ b/storage/udev.py @@ -258,6 +258,10 @@ def udev_device_get_vendor(udev_info): """ Get the vendor of the device as reported by udev. """ return udev_info.get("ID_VENDOR_FROM_DATABASE", udev_info.get("ID_VENDOR")) +def udev_device_get_bus(udev_info): + """ Get the bus a device is connected to the system by. """ + return udev_info.get("ID_BUS").upper() + Not sure if I like the upper here, I can understand you want things like scsi and sata to be upper cased, but for for example iSCSI or FcOE (not sure if that ever gets returned, I think they both will just return scsi, which could be considered a problem by itself) uppercasing them is wrong. Hmm, we may want to consider overriding the bus value returned from udev when determining the disk type in devicetree.py, so that we can properly set bus as iSCSI / FCoE / DASD for such disks (I think udev will return scsi for all of them), assuming this is used purely for informational purposes. def udev_device_get_sysfs_path(info): return info['sysfs_path'] Regards, Hans _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
Add a method to get the bus/interconnect from udev and store it on devices.
> Not sure if I like the upper here, I can understand you want things
> like scsi and sata to be upper cased, but for for example > iSCSI or FcOE (not sure if that ever gets returned, I think they both > will just return scsi, which could be considered a problem by itself) > uppercasing them is wrong. I think I'm okay with this for now, as I haven't gotten to testing iSCSI and FcOE yet. Once I get there, I can reconsider what I'm doing with this string. I'm not tied to the idea of uppercasing it - taking the value as-is from udev might be a better plan just to get me out of the business of manipulating more udev data. > Hmm, we may want to consider overriding the bus value returned from > udev when determining the disk type in devicetree.py, so that we can > properly set bus as iSCSI / FCoE / DASD for such disks (I think > udev will return scsi for all of them), assuming this is used > purely for informational purposes. It's purely for informational purposes in my patches, but I can't speak to what crazy new things we'll come up for in the future. Anyway, setting the bus type in devicetree.py won't help the filtering. There's no DeviceTree object populated when this code runs. It has to operate completely on udev dicts. Of course, we can still add this overriding in to help out later on, should we use the bus attribute on Devices at some point. - Chris _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
| All times are GMT. The time now is 03:19 AM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.