From 9b56e89720642f4b1c54a34756f0131c9bdd449b Mon Sep 17 00:00:00 2001 From: David Lehman Date: Wed, 29 Apr 2015 15:09:04 -0500 Subject: [PATCH] Store vendor/model information for DiskDevice instances. Also make sure _model and _vendor attrs are never set to None in the StorageDevice constructor. Fixes #84 --- blivet/devices/disk.py | 6 +++++- blivet/devices/storage.py | 4 ++-- blivet/populator.py | 9 +++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/blivet/devices/disk.py b/blivet/devices/disk.py index 39acea291..c727c74e4 100644 --- a/blivet/devices/disk.py +++ b/blivet/devices/disk.py @@ -105,7 +105,11 @@ def mediaPresent(self): @property def description(self): - return self.model + desc = self.vendor + if desc: + desc += " " + desc += self.model + return desc def _preDestroy(self): """ Destroy the device. """ diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py index 052b3975b..87181ace9 100644 --- a/blivet/devices/storage.py +++ b/blivet/devices/storage.py @@ -113,8 +113,8 @@ def __init__(self, name, fmt=None, uuid=None, 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._readonly = False diff --git a/blivet/populator.py b/blivet/populator.py index 1a213455e..157178ae0 100644 --- a/blivet/populator.py +++ b/blivet/populator.py @@ -476,12 +476,10 @@ def addUdevDiskDevice(self, info): 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) @@ -561,7 +559,6 @@ def addUdevDiskDevice(self, info): 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: