From ae149e3873491dea6add89eac8b23d3317936f86 Mon Sep 17 00:00:00 2001 From: David Lehman Date: Thu, 8 Aug 2013 11:25:50 -0500 Subject: [PATCH 1/3] Keep the dasd list in sync with the devicetree's device list. (#965694) --- blivet/dasd.py | 9 +++++++-- blivet/devices.py | 4 ---- blivet/devicetree.py | 10 +++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/blivet/dasd.py b/blivet/dasd.py index 46a23d5..c2ec2e4 100644 --- a/blivet/dasd.py +++ b/blivet/dasd.py @@ -179,9 +179,14 @@ class DASD: def addDASD(self, dasd): """ Adds a DASDDevice to the internal list of DASDs. """ - if dasd: + if dasd and dasd not in self._devices: self._devices.append(dasd) + def removeDASD(self, dasd): + """ Removes a DASDDevice from the internal list of DASDs. """ + if dasd and dasd in self._devices: + self._devices.remove(dasd) + def clear_device_list(self): """ Clear the device list to force re-populate on next access. """ self._devices = [] @@ -194,7 +199,7 @@ class DASD: return f = open(os.path.realpath(ROOT_PATH + "/etc/dasd.conf"), "w") - for dasd in self._devices: + for dasd in sorted(self._devices, key=lambda d: d.name): fields = [dasd.busid] + dasd.getOpts() f.write("%s\n" % (" ".join(fields),)) f.close() diff --git a/blivet/devices.py b/blivet/devices.py index 8b4fd23..b98dcf7 100644 --- a/blivet/devices.py +++ b/blivet/devices.py @@ -4120,12 +4120,8 @@ class DASDDevice(DiskDevice): def __init__(self, device, **kwargs): self.busid = kwargs.pop('busid') self.opts = kwargs.pop('opts') - self.dasd = kwargs.pop('dasd') DiskDevice.__init__(self, device, **kwargs) - if self.dasd: - self.dasd.addDASD(self) - @property def description(self): return "DASD device %s" % self.busid diff --git a/blivet/devicetree.py b/blivet/devicetree.py index 763b4b6..5a983df 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -899,7 +899,6 @@ class DeviceTree(object): del kwargs["bus"] elif udev_device_is_dasd(info): diskType = DASDDevice - kwargs["dasd"] = self.dasd kwargs["busid"] = udev_device_get_dasd_bus_id(info) kwargs["opts"] = {} @@ -926,6 +925,9 @@ class DeviceTree(object): if devicelibs.mpath.is_multipath_member(device.path): info["ID_FS_TYPE"] = "multipath_member" + if diskType == DASDDevice: + self.dasd.addDASD(device) + self._addDevice(device) return device @@ -1748,6 +1750,9 @@ class DeviceTree(object): for parent in device.parents: parent.removeChild() + if isinstance(device, DASDDevice): + self.dasd.removeDASD(device) + def unhide(self, device): # the hidden list should be in leaves-first order for hidden in reversed(self._hidden): @@ -1761,6 +1766,9 @@ class DeviceTree(object): for parent in hidden.parents: parent.addChild() + if isinstance(hidden, DASDDevice): + self.dasd.addDASD(hidden) + def setupDiskImages(self): """ Set up devices to represent the disk image files. """ for (name, path) in self.diskImages.items(): -- 1.8.1.4