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

Re: [PATCH 05/14] 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


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