Re: [PATCH 04/14] Add a vendor getting udev method, though udev doesn't always know it.

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

 



Hi,

See comment inline .

On 12/01/2009 09:15 PM, Chris Lumens wrote:
---
  storage/devices.py    |   11 +++++++----
  storage/devicetree.py |    9 ++++++++-
  storage/udev.py       |    4 ++++
  3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index b5f7aee..75f9107 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -421,7 +421,8 @@ class StorageDevice(Device):

      def __init__(self, device, format=None,
                   size=None, major=None, minor=None,
-                 sysfsPath='', parents=None, exists=None, serial=None):
+                 sysfsPath='', parents=None, exists=None, serial=None,
+                 vendor=""):
          """ Create a StorageDevice instance.

              Arguments:
@@ -452,6 +453,7 @@ class StorageDevice(Device):
          self.sysfsPath = sysfsPath
          self.exists = exists
          self.serial = serial
+        self.vendor = vendor

          self.protected = False

@@ -715,8 +717,8 @@ class DiskDevice(StorageDevice):
      _type = "disk"

      def __init__(self, device, format=None,
-                 size=None, major=None, minor=None, sysfsPath='', \
-                 parents=None, serial=None):
+                 size=None, major=None, minor=None, sysfsPath='',
+                 parents=None, serial=None, vendor=""):
          """ Create a DiskDevice instance.

              Arguments:
@@ -733,6 +735,7 @@ class DiskDevice(StorageDevice):
                  parents -- a list of required Device instances
                  removable -- whether or not this is a removable device
                  serial -- the ID_SERIAL_SHORT for this device
+                vendor -- the manufacturer of this Device


              DiskDevices always exist.
@@ -740,7 +743,7 @@ class DiskDevice(StorageDevice):
          StorageDevice.__init__(self, device, format=format, size=size,
                                 major=major, minor=minor, exists=True,
                                 sysfsPath=sysfsPath, parents=parents,
-                               serial=serial)
+                               serial=serial, vendor=vendor)

      def __str__(self):
          s = StorageDevice.__str__(self)
diff --git a/storage/devicetree.py b/storage/devicetree.py
index 7fb9f47..6090dd3 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1166,6 +1166,13 @@ class DeviceTree(object):
          uuid = udev_device_get_uuid(info)
          sysfs_path = udev_device_get_sysfs_path(info)
          serial = udev_device_get_serial(info)
+
+        try:
+            # udev doesn't always provide a vendor.
+            vendor = udev_device_get_vendor(info)
+        except KeyError:
+            vendor = ""
+
          device = None

          kwargs = {}

udev_device_get_vendor, does a get() on the info dict, so if
the key is not there it will return None (and won't raise a keyerror)
Assuming we want vendor to always be a string, and never none, the above
or udev_device_get_vendor() needs to be changed.


@@ -1213,7 +1220,7 @@ class DeviceTree(object):
              diskType = DiskDevice
              log.debug("%s is a disk" % name)

-        device = diskType(name, serial=serial,
+        device = diskType(name, serial=serial, vendor=vendor,
                            major=udev_device_get_major(info),
                            minor=udev_device_get_minor(info),
                            sysfsPath=sysfs_path, **kwargs)
diff --git a/storage/udev.py b/storage/udev.py
index 5d4c778..aa131b4 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -254,6 +254,10 @@ 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_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_sysfs_path(info):
      return info['sysfs_path']


Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux