--- image.py | 2 +- iw/partition_gui.py | 2 +- partIntfHelpers.py | 2 +- storage/__init__.py | 25 +++++++++++-------------- storage/devicetree.py | 35 ++++++++++++++++++++++++++--------- storage/partitioning.py | 2 +- 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/image.py b/image.py index 6bc421e..889c2fe 100644 --- a/image.py +++ b/image.py @@ -250,7 +250,7 @@ def presentRequiredMediaMessage(anaconda): # Find an attached CD/DVD drive with media in it that contains packages, # and return that device name. def scanForMedia(tree, storage): - for dev in storage.devicetree.devices.values(): + for dev in storage.devicetree.devices: if dev.type != "cdrom": continue diff --git a/iw/partition_gui.py b/iw/partition_gui.py index 0196df7..bffc5a9 100644 --- a/iw/partition_gui.py +++ b/iw/partition_gui.py @@ -1045,7 +1045,7 @@ class PartitionWindow(InstallWindow): rc = -1 else: rc = 0 - all_devices = self.storage.devicetree.devices.values() + all_devices = self.storage.devicetree.devices bootDevs = [d for d in all_devices if d.bootable] #if reqs: # for req in reqs: diff --git a/partIntfHelpers.py b/partIntfHelpers.py index 6d91bad..a68704f 100644 --- a/partIntfHelpers.py +++ b/partIntfHelpers.py @@ -272,7 +272,7 @@ def partitionPreExistFormatWarnings(intf, warnings): def getPreExistFormatWarnings(storage): """Return a list of preexisting devices being formatted.""" devices = [] - for device in storage.devicetree.devices.values(): + for device in storage.devicetree.devices: if device.exists and not device.format.exists: devices.append(device) diff --git a/storage/__init__.py b/storage/__init__.py index 03b9876..efd21a0 100644 --- a/storage/__init__.py +++ b/storage/__init__.py @@ -297,7 +297,7 @@ class Storage(object): @property def devices(self): """ A list of all the devices in the device tree. """ - devices = self.devicetree.devices.values() + devices = self.devicetree.devices devices.sort(key=lambda d: d.path) return devices @@ -312,10 +312,9 @@ class Storage(object): system's disks. """ disks = [] - devices = self.devicetree.devices - for d in devices: - if isinstance(devices[d], DiskDevice) and devices[d].mediaPresent: - disks.append(devices[d]) + for device in self.devicetree.devices: + if isinstance(device, DiskDevice) and device.mediaPresent: + disks.append(device) disks.sort(key=lambda d: d.name) return disks @@ -363,7 +362,7 @@ class Storage(object): does not necessarily reflect the actual on-disk state of the system's disks. """ - devices = self.devicetree.devices.values() + devices = self.devicetree.devices pvs = [d for d in devices if d.format.type == "lvmpv"] pvs.sort(key=lambda d: d.name) return pvs @@ -402,7 +401,7 @@ class Storage(object): does not necessarily reflect the actual on-disk state of the system's disks. """ - devices = self.devicetree.devices.values() + devices = self.devicetree.devices members = [d for d in devices if d.format.type == "mdmember"] members.sort(key=lambda d: d.name) return members @@ -438,14 +437,14 @@ class Storage(object): does not necessarily reflect the actual on-disk state of the system's disks. """ - devices = self.devicetree.devices.values() + devices = self.devicetree.devices swaps = [d for d in devices if d.format.type == "swap"] swaps.sort(key=lambda d: d.name) return swaps @property def protectedDevices(self): - devices = self.devicetree.devices.values() + devices = self.devicetree.devices protected = [d for d in devices if d.protected] protected.sort(key=lambda d: d.name) return protected @@ -1200,7 +1199,7 @@ class CryptTab(object): def populate(self): """ Populate the instance based on the device tree's contents. """ - for device in self.devicetree.devices.values(): + for device in self.devicetree.devices: # XXX should we put them all in there or just the ones that # are part of a device containing swap or a filesystem? # @@ -1321,9 +1320,7 @@ class FSSet(object): @property def devices(self): - devices = self.devicetree.devices.values() - devices.sort(key=lambda d: d.path) - return devices + return sorted(self.devicetree.devices, key=lambda d: d.path) @property def mountpoints(self): @@ -1487,7 +1484,7 @@ class FSSet(object): if not device: continue - if device not in self.devicetree.devices.values(): + if device not in self.devicetree.devices: self.devicetree._addDevice(device) def fsFreeSpace(self, chroot='/'): diff --git a/storage/devicetree.py b/storage/devicetree.py index 08846f3..d306d6e 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -670,7 +670,7 @@ class DeviceTree(object): log.debug("action: %s" % action) log.debug("resetting parted disks...") - for device in self.devices.itervalues(): + for device in self.devices: if isinstance(device, DiskDevice): device.resetPartedDisk() @@ -850,7 +850,7 @@ class DeviceTree(object): if part.partType and part.isLogical and part.disk == dep.disk: logicals.append(part) - for device in self.devices.values(): + for device in self.devices: if device.dependsOn(dep): dependents.append(device) else: @@ -910,7 +910,7 @@ class DeviceTree(object): sysfs_path = udev_device_get_sysfs_path(info) device = None - for dmdev in self.devices.values(): + for dmdev in self.devices: if not isinstance(dmdev, DMDevice): continue @@ -1879,6 +1879,24 @@ class DeviceTree(object): log.debug("found %s" % found) return found + def getDeviceByPath(self, path): + log.debug("looking for device '%s'..." % path) + if not path: + return None + + found = None + for device in self._devices: + if device.path == path: + found = device + break + elif (device.type == "lvmlv" or device.type == "lvmvg") and \ + device.path == path.replace("--","-"): + found = device + break + + log.debug("found %s" % found) + return found + def getDevicesByType(self, device_type): # TODO: expand this to catch device format types return [d for d in self._devices if d.type == device_type] @@ -1888,14 +1906,13 @@ class DeviceTree(object): @property def devices(self): - """ Dict with device path keys and Device values. """ - devices = {} - + """ List of device instances """ + devices = [] for device in self._devices: - if device.path in devices: + if device.path in [d.path for d in devices]: raise DeviceTreeError("duplicate paths in device tree") - devices[device.path] = device + devices.append(device) return devices @@ -1973,7 +1990,7 @@ class DeviceTree(object): log.error("failed to resolve device %s" % devspec) elif devspec.startswith("/dev/"): # device path - device = self.devices.get(devspec) + device = self.getDeviceByPath(devspec) if device is None: if blkidTab: # try to use the blkid.tab to correlate the device diff --git a/storage/partitioning.py b/storage/partitioning.py index ab106b2..7e7a05a 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -162,7 +162,7 @@ def doAutoPartition(anaconda): log.debug("clearPartDisks: %s" % anaconda.id.storage.clearPartDisks) log.debug("autoPartitionRequests: %s" % anaconda.id.storage.autoPartitionRequests) log.debug("storage.disks: %s" % anaconda.id.storage.disks) - log.debug("all names: %s" % [d.name for d in anaconda.id.storage.devicetree.devices.values()]) + log.debug("all names: %s" % [d.name for d in anaconda.id.storage.devices]) if anaconda.dir == DISPATCH_BACK: anaconda.id.storage.reset() return -- 1.6.0.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list