[PATCH 3/3] Store vendor/model information for DiskDevice instances.
David Lehman
dlehman at redhat.com
Fri Jun 26 21:54:56 UTC 2015
Also make sure _model and _vendor attrs are never set to None in the
StorageDevice constructor.
(cherry picked from commit 067183942c97f432e739c979c4b1d7a9816eef06)
Related: rhbz#1069597
---
blivet/devices/disk.py | 2 +-
blivet/devices/storage.py | 4 ++--
blivet/devicetree.py | 9 +++------
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/blivet/devices/disk.py b/blivet/devices/disk.py
index d17e975..3638f50 100644
--- a/blivet/devices/disk.py
+++ b/blivet/devices/disk.py
@@ -105,7 +105,7 @@ class DiskDevice(StorageDevice):
@property
def description(self):
- return self.model
+ return " ".join(s for s in (self.vendor, self.model) if s)
def _preDestroy(self):
""" Destroy the device. """
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index b6ee4dc..348eb65 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -112,8 +112,8 @@ class StorageDevice(Device):
self.major = util.numeric_type(major)
self.minor = util.numeric_type(minor)
self._serial = serial
- self._vendor = vendor
- self._model = model
+ self._vendor = vendor or ""
+ self._model = model or ""
self.bus = bus
self.protected = False
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index a70d7b9..915b94e 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1000,12 +1000,10 @@ class DeviceTree(object):
serial = udev.device_get_serial(info)
bus = udev.device_get_bus(info)
- # udev doesn't always provide a vendor.
- vendor = udev.device_get_vendor(info)
- if not vendor:
- vendor = ""
+ vendor = util.get_sysfs_attr(sysfs_path, "device/vendor")
+ model = util.get_sysfs_attr(sysfs_path, "device/model")
- kwargs = { "serial": serial, "vendor": vendor, "bus": bus }
+ kwargs = { "serial": serial, "vendor": vendor, "model": model, "bus": bus }
if udev.device_is_iscsi(info):
diskType = iScsiDiskDevice
initiator = udev.device_get_iscsi_initiator(info)
@@ -1085,7 +1083,6 @@ class DeviceTree(object):
device = diskType(name,
major=udev.device_get_major(info),
minor=udev.device_get_minor(info),
- model=udev.device_get_model(info),
sysfsPath=sysfs_path, **kwargs)
if diskType == DASDDevice:
--
2.4.3
More information about the anaconda-patches
mailing list