diff options
author | David Lehman <dlehman@redhat.com> | 2009-12-09 01:23:11 -0600 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2009-12-09 15:12:59 -0600 |
commit | 414e70f9d87771eeb45875fea69b54d7ce9444af (patch) | |
tree | cdad5e9bab52f266015b55ca0f5c50a398180495 | |
parent | 429d97802d036413ddfc3f60148a39618e032b6e (diff) | |
download | anaconda-414e70f9d87771eeb45875fea69b54d7ce9444af.tar.gz anaconda-414e70f9d87771eeb45875fea69b54d7ce9444af.tar.xz anaconda-414e70f9d87771eeb45875fea69b54d7ce9444af.zip |
Add support for whole-disk formatting.
Whole-disk formats are recognized but cannot be edited in any way.
-rw-r--r-- | booty/bootloaderInfo.py | 6 | ||||
-rw-r--r-- | iw/bootloader_main_gui.py | 10 | ||||
-rw-r--r-- | iw/partition_dialog_gui.py | 6 | ||||
-rw-r--r-- | iw/partition_gui.py | 119 | ||||
-rw-r--r-- | iw/partition_ui_helpers_gui.py | 2 | ||||
-rw-r--r-- | iw/raid_dialog_gui.py | 4 | ||||
-rw-r--r-- | storage/__init__.py | 26 | ||||
-rw-r--r-- | storage/devices.py | 105 | ||||
-rw-r--r-- | storage/devicetree.py | 49 | ||||
-rw-r--r-- | storage/partitioning.py | 10 | ||||
-rw-r--r-- | textw/partition_text.py | 2 |
11 files changed, 184 insertions, 155 deletions
diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py index 613b489e8..067ffa700 100644 --- a/booty/bootloaderInfo.py +++ b/booty/bootloaderInfo.py @@ -474,7 +474,11 @@ class bootloaderInfo(object): f.write("\n") def updateDriveList(self, sortedList=[]): - self._drivelist = map(lambda x: x.name, self.storage.disks) + # bootloader is unusual in that we only want to look at disks that + # have disklabels -- no partitioned md or unpartitioned disks + disks = self.storage.disks + partitioned = self.storage.partitioned + self._drivelist = [d.name for d in disks if d in partitioned] self._drivelist.sort(isys.compareDrives) # If we're given a sort order, make sure the drives listed in it diff --git a/iw/bootloader_main_gui.py b/iw/bootloader_main_gui.py index 213083ad6..5f2fec502 100644 --- a/iw/bootloader_main_gui.py +++ b/iw/bootloader_main_gui.py @@ -136,7 +136,10 @@ class MainBootloaderWindow(InstallWindow): lbl = dxml.get_widget("bd%dLabel" %(i,)) combo.show() lbl.show() - m = __genStore(combo, anaconda.id.storage.disks, self.driveorder[i - 1]) + partitioned = anaconda.id.storage.partitioned + disks = anaconda.id.storage.disks + bl_disks = [d.name for d in disks if d in partitioned] + m = __genStore(combo, bl_disks, self.driveorder[i - 1]) dxml.get_widget("bd1Combo").connect("changed", __driveChange, dxml, choices) __driveChange(dxml.get_widget("bd1Combo"), dxml, choices) @@ -190,10 +193,11 @@ class MainBootloaderWindow(InstallWindow): self.bl = anaconda.id.bootloader self.intf = anaconda.intf - disks = anaconda.id.storage.disks self.driveorder = self.bl.drivelist if len(self.driveorder) == 0: - self.driveorder = [d.name for d in disks] + partitioned = anaconda.id.storage.partitioned + disks = anaconda.id.storage.disks + self.driveorder = [d.name for d in disks if d in partitioned] if self.bl.getPassword(): self.usePass = 1 diff --git a/iw/partition_dialog_gui.py b/iw/partition_dialog_gui.py index c9781e02b..7f76c8630 100644 --- a/iw/partition_dialog_gui.py +++ b/iw/partition_dialog_gui.py @@ -164,14 +164,14 @@ class PartitionEditor: iter = model.iter_next(iter) - if len(allowdrives) == len(self.storage.disks): + if len(allowdrives) == len(self.storage.partitioned): allowdrives = None size = self.sizespin.get_value_as_int() disks = [] if allowdrives: for drive in allowdrives: - for disk in self.storage.disks: + for disk in self.storage.partitioned: if disk.name == drive: disks.append(disk) @@ -403,7 +403,7 @@ class PartitionEditor: maintable.attach(lbl, 0, 1, row, row + 1) req_disk_names = [d.name for d in self.origrequest.req_disks] - self.driveview = createAllowedDrivesList(self.storage.disks, + self.driveview = createAllowedDrivesList(self.storage.partitioned, req_disk_names, disallowDrives=[self.anaconda.updateSrc]) lbl.set_mnemonic_widget(self.driveview) diff --git a/iw/partition_gui.py b/iw/partition_gui.py index 04c9988ea..a17fd709f 100644 --- a/iw/partition_gui.py +++ b/iw/partition_gui.py @@ -1017,62 +1017,66 @@ class PartitionWindow(InstallWindow): parent = self.tree.append(drvparent) self.tree[parent]['PyObject'] = disk - part = disk.format.firstPartition - extendedParent = None - while part: - if part.type & parted.PARTITION_METADATA: - part = part.nextPartition() - continue - - partName = devicePathToName(part.getDeviceNodeName()) - device = self.storage.devicetree.getDeviceByName(partName) - if not device and not part.type & parted.PARTITION_FREESPACE: - log.debug("can't find partition %s in device" - " tree" % partName) - - # ignore the tiny < 1 MB free space partitions (#119479) - if part.getSize(unit="MB") <= 1.0 and \ - part.type & parted.PARTITION_FREESPACE: - if not part.active or not device.bootable: + if disk.partitioned: + part = disk.format.firstPartition + extendedParent = None + while part: + if part.type & parted.PARTITION_METADATA: part = part.nextPartition() continue - if device and device.isExtended: - if extendedParent: - raise RuntimeError, ("can't handle more than " - "one extended partition per disk") - extendedParent = self.tree.append(parent) - iter = extendedParent - elif device and device.isLogical: - if not extendedParent: - raise RuntimeError, ("crossed logical partition " - "before extended") - iter = self.tree.append(extendedParent) - else: - iter = self.tree.append(parent) - - if device and not device.isExtended: - self.addDevice(device, iter) - else: - # either extended or freespace - if part.type & parted.PARTITION_FREESPACE: - devstring = _("Free") - ptype = "" + partName = devicePathToName(part.getDeviceNodeName()) + device = self.storage.devicetree.getDeviceByName(partName) + if not device and not part.type & parted.PARTITION_FREESPACE: + log.debug("can't find partition %s in device" + " tree" % partName) + + # ignore the tiny < 1 MB free space partitions (#119479) + if part.getSize(unit="MB") <= 1.0 and \ + part.type & parted.PARTITION_FREESPACE: + if not part.active or not device.bootable: + part = part.nextPartition() + continue + + if device and device.isExtended: + if extendedParent: + raise RuntimeError, ("can't handle more than " + "one extended partition per disk") + extendedParent = self.tree.append(parent) + iter = extendedParent + elif device and device.isLogical: + if not extendedParent: + raise RuntimeError, ("crossed logical partition " + "before extended") + iter = self.tree.append(extendedParent) else: - devstring = device.name - ptype = _("Extended") - - self.tree[iter]['Device'] = devstring - self.tree[iter]['Type'] = ptype - size = part.getSize(unit="MB") - if size < 1.0: - sizestr = "< 1" + iter = self.tree.append(parent) + + if device and not device.isExtended: + self.addDevice(device, iter) else: - sizestr = "%Ld" % (size) - self.tree[iter]['Size (MB)'] = sizestr - self.tree[iter]['PyObject'] = device + # either extended or freespace + if part.type & parted.PARTITION_FREESPACE: + devstring = _("Free") + ptype = "" + else: + devstring = device.name + ptype = _("Extended") + + self.tree[iter]['Device'] = devstring + self.tree[iter]['Type'] = ptype + size = part.getSize(unit="MB") + if size < 1.0: + sizestr = "< 1" + else: + sizestr = "%Ld" % (size) + self.tree[iter]['Size (MB)'] = sizestr + self.tree[iter]['PyObject'] = device - part = part.nextPartition() + part = part.nextPartition() + else: + # whole-disk formatting + self.addDevice(disk, parent) # Insert a '\n' when device string is too long. Usually when it # contains '/dev/mapper'. First column should be around 20 chars. @@ -1116,7 +1120,7 @@ class PartitionWindow(InstallWindow): # Display a create dialog. stripe_dev = disp_stripe.obj - if isinstance(stripe_dev, storage.DiskDevice): + if stripe_dev.partitioned: tempformat = self.storage.defaultFSType device = self.storage.newPartition(fmt_type=tempformat, size=200) self.editPartition(device, isNew = True) @@ -1145,7 +1149,7 @@ class PartitionWindow(InstallWindow): # FIXME: This code might repeat itself. might be a good idea to # put it in a function. curr_parent = self.tree[iparent]["PyObject"] - if isinstance(curr_parent, storage.DiskDevice): + if curr_parent.partitioned: tempformat = self.storage.defaultFSType device = self.storage.newPartition(fmt_type=tempformat, size=200) self.editPartition(device, isNew = True) @@ -1187,7 +1191,7 @@ class PartitionWindow(InstallWindow): if not device: # This is free space. parent = self.tree[iparent]["PyObject"] - if isinstance(parent, storage.DiskDevice): + if parent.partitioned: if not isinstance(self.stripeGraph, DiskStripeGraph): self.stripeGraph.shutDown() self.stripeGraph = DiskStripeGraph(self.storage, @@ -1203,7 +1207,7 @@ class PartitionWindow(InstallWindow): dcCB = self.barviewActivateCB) self.stripeGraph.setDisplayed(parent) - elif isinstance(device, storage.DiskDevice): + elif device.partitioned: if not isinstance(self.stripeGraph, DiskStripeGraph): self.stripeGraph.shutDown() self.stripeGraph = DiskStripeGraph(self.storage, @@ -1273,7 +1277,7 @@ class PartitionWindow(InstallWindow): devices. This will need some work when that time comes. """ device = self.tree.getCurrentDevice() - if device.format.type == "disklabel": + if device.partitioned: if doClearPartitionedDevice(self.intf, self.storage, device): @@ -1281,8 +1285,7 @@ class PartitionWindow(InstallWindow): elif doDeleteDevice(self.intf, self.storage, device): - if isinstance(device, storage.devices.DiskDevice) or \ - isinstance(device, storage.devices.PartitionDevice): + if isinstance(device, storage.devices.PartitionDevice): justRedraw = False else: justRedraw = True @@ -1327,7 +1330,7 @@ class PartitionWindow(InstallWindow): # FIXME: Why do I need availraidparts to clone? activate_create_raid_clone = False - if (len(self.storage.disks) > 1 + if (len(self.storage.partitioned) > 1 and availraidparts > 0): activate_create_raid_clone = True diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py index 39b2561f2..ee6d0acde 100644 --- a/iw/partition_ui_helpers_gui.py +++ b/iw/partition_ui_helpers_gui.py @@ -420,7 +420,7 @@ def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo, # do tests we just want in UI for now, not kickstart def doUIRAIDLVMChecks(request, storage): fstype = request.format.name - numdrives = len(storage.disks) + numdrives = len(storage.partitioned) ## if fstype and fstype.getName() == "physical volume (LVM)": ## if request.grow: diff --git a/iw/raid_dialog_gui.py b/iw/raid_dialog_gui.py index 8431e71a7..086c562ee 100644 --- a/iw/raid_dialog_gui.py +++ b/iw/raid_dialog_gui.py @@ -812,7 +812,7 @@ class RaidCloneDialog: lbl = gtk.Label(_("Source Drive:")) lbl.set_alignment(0.0, 0.0) box.pack_start(lbl, padding=5) - (sw, self.sourceView) = self.createDriveList(storage.disks) + (sw, self.sourceView) = self.createDriveList(storage.partitioned) selection = self.sourceView.get_selection() selection.set_mode(gtk.SELECTION_SINGLE) box.pack_start(sw, padding=5) @@ -820,7 +820,7 @@ class RaidCloneDialog: lbl = gtk.Label(_("Target Drive(s):")) lbl.set_alignment(0.0, 0.0) box.pack_start(lbl, padding=5) - (sw, self.targetView) = self.createDriveList(storage.disks) + (sw, self.targetView) = self.createDriveList(storage.partitioned) selection = self.targetView.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) box.pack_start(sw, padding=5) diff --git a/storage/__init__.py b/storage/__init__.py index 6a24de1b5..32026d9ff 100644 --- a/storage/__init__.py +++ b/storage/__init__.py @@ -386,7 +386,7 @@ class Storage(object): """ disks = [] for device in self.devicetree.devices: - if isinstance(device, DiskDevice): + if device.isDisk: if not device.mediaPresent: log.info("Skipping disk: %s: No media present" % device.name) continue @@ -395,6 +395,30 @@ class Storage(object): return disks @property + def partitioned(self): + """ A list of the partitioned devices in the device tree. + + Ignored devices are not included, nor disks with no media present. + + This is based on the current state of the device tree and + does not necessarily reflect the actual on-disk state of the + system's disks. + """ + partitioned = [] + for device in self.devicetree.devices: + if not device.partitioned: + continue + + if not device.mediaPresent: + log.info("Skipping device: %s: No media present" % device.name) + continue + + partitioned.append(device) + + partitioned.sort(key=lambda d: d.name) + return partitioned + + @property def partitions(self): """ A list of the partitions in the device tree. diff --git a/storage/devices.py b/storage/devices.py index ca25539ae..8db4d7cb5 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -419,6 +419,8 @@ class StorageDevice(Device): _devDir = "/dev" sysfsBlockDir = "class/block" _resizable = False + partitionable = False + isDisk = False def __init__(self, device, format=None, size=None, major=None, minor=None, @@ -711,9 +713,15 @@ class StorageDevice(Device): os.access(remfile, os.R_OK) and open(remfile).readline().strip() == "1") + @property + def partitioned(self): + return self.format.type == "disklabel" + class DiskDevice(StorageDevice): """ A disk """ _type = "disk" + partitionable = True + isDisk = True def __init__(self, device, format=None, size=None, major=None, minor=None, sysfsPath='', \ @@ -2196,12 +2204,9 @@ class LVMLogicalVolumeDevice(DMDevice): class MDRaidArrayDevice(StorageDevice): - """ An mdraid (Linux RAID) device. - - Since this is derived from StorageDevice, not DiskDevice, it - can NOT be used to represent a partitionable device. - """ + """ An mdraid (Linux RAID) device. """ _type = "mdarray" + partitionable = True def __init__(self, name, level=None, major=None, minor=None, size=None, memberDevices=None, totalDevices=None, bitmap=False, @@ -2644,29 +2649,28 @@ class MDRaidArrayDevice(StorageDevice): # real work, but it isn't our place to do it from here. self.exists = False - -class PartitionableMDRaidArrayDevice(MDRaidArrayDevice, DiskDevice): - """ A partitionable mdraid (Linux RAID) device. - - Since this is derived from DiskDevice, not StorageDevice, it - can be used to represent a partitionable device. - """ - _type = "partitionable mdarray" - @property def mediaPresent(self): - # Even if stopped/deactivated we still want to show up in storage.disks - return True + present = None + if self.partitioned: + # Even if stopped/deactivated we still want to show up in + # storage.disks + present = True + else: + present = self.partedDevice is not None + + return present @property def model(self): return "RAID%d Array" % self.level -class DMRaidArrayDevice(DiskDevice): +class DMRaidArrayDevice(DMDevice): """ A dmraid (device-mapper RAID) device """ _type = "dm-raid array" _packages = ["dmraid"] - _devDir = "/dev/mapper" + partitionable = True + isDisk = True def __init__(self, name, raidSet=None, format=None, size=None, major=None, minor=None, parents=None, @@ -2689,15 +2693,14 @@ class DMRaidArrayDevice(DiskDevice): for parent in parents: if not parent.format or parent.format.type != "dmraidmember": raise ValueError("parent devices must contain dmraidmember format") - DiskDevice.__init__(self, name, format=format, size=size, - major=major, minor=minor, parents=parents, - sysfsPath=sysfsPath) + DMDevice.__init__(self, name, format=format, size=size, + major=major, minor=minor, parents=parents, + sysfsPath=sysfsPath) self.formatClass = get_device_format_class("dmraidmember") if not self.formatClass: raise StorageError("cannot find class for 'dmraidmember'") - self._raidSet = raidSet @property @@ -2734,19 +2737,6 @@ class DMRaidArrayDevice(DiskDevice): """ Return a list of this array's member device instances. """ return self.parents - def updateSysfsPath(self): - """ Update this device's sysfs path. """ - log_method_call(self, self.name, status=self.status) - if not self.exists: - raise DeviceError("device has not been created", self.name) - - if self.status: - dm_node = dm.dm_node_from_name(self.name) - path = os.path.join("/sys", self.sysfsBlockDir, dm_node) - self.sysfsPath = os.path.realpath(path)[4:] - else: - self.sysfsPath = '' - def deactivate(self): """ Deactivate the raid set. """ log_method_call(self, self.name, status=self.status) @@ -2760,6 +2750,20 @@ class DMRaidArrayDevice(DiskDevice): self._raidSet.activate(mknod=True) udev_settle() + def setup(self, intf=None): + """ Open, or set up, a device. """ + log_method_call(self, self.name, status=self.status) + StorageDevice.setup(self, intf=intf) + self.activate() + + def teardown(self, recursive=None): + """ Close, or tear down, a device. """ + log_method_call(self, self.name, status=self.status) + if not self.exists and not recursive: + raise DeviceError("device has not been created", self.name) + + log.debug("not tearing down dmraid device %s" % self.name) + @property def mediaPresent(self): # Even if teared down we still want to show up in storage.disks @@ -2778,11 +2782,12 @@ def generateMultipathDeviceName(): number = _multipathDeviceNameGenerator.get() return "mpath%s" % (number, ) -class MultipathDevice(DiskDevice): +class MultipathDevice(DMDevice): """ A multipath device """ _type = "dm-multipath" _packages = ["device-mapper-multipath"] - _devDir = "/dev/mapper" + partitionable = True + isDisk = True def __init__(self, name, info, format=None, size=None, parents=None, sysfsPath=''): @@ -2805,7 +2810,7 @@ class MultipathDevice(DiskDevice): self._isUp = False self._pyBlockMultiPath = None self.setupIdentity() - DiskDevice.__init__(self, name, format=format, size=size, + DMDevice.__init__(self, name, format=format, size=size, parents=parents, sysfsPath=sysfsPath) # PJTODO: these need better setup @@ -2882,26 +2887,6 @@ class MultipathDevice(DiskDevice): self._isUp = False self._pyBlockMultiPath = None - def updateSysfsPath(self): - """ Update this device's sysfs path. """ - log_method_call(self, self.name, status=self.status) - if not self.exists: - raise DeviceError("device has not been created", self.name) - - if self.status: - dm_node = self.getDMNode() - path = os.path.join("/sys", self.sysfsBlockDir, dm_node) - self.sysfsPath = os.path.realpath(path)[4:] - else: - self.sysfsPath = '' - - def getDMNode(self): - """ Return the dm-X (eg: dm-0) device node for this device. """ - log_method_call(self, self.name, status=self.status) - if not self.exists: - raise DeviceError("device has not been created", self.name) - - return dm.dm_node_from_name(self.name) class NoDevice(StorageDevice): """ A nodev device for nodev filesystems like tmpfs. """ @@ -3094,6 +3079,8 @@ class iScsiDiskDevice(DiskDevice, NetworkStorageDevice): """ An iSCSI disk. """ _type = "iscsi" _packages = ["iscsi-initiator-utils", "dracut-network"] + partitionable = True + isDisk = True def __init__(self, device, **kwargs): self.node = kwargs.pop("node") @@ -3126,6 +3113,8 @@ class FcoeDiskDevice(DiskDevice, NetworkStorageDevice): """ An FCoE disk. """ _type = "fcoe" _packages = ["fcoe-utils", "dracut-network"] + partitionable = True + isDisk = True def __init__(self, device, **kwargs): self.nic = kwargs.pop("nic") diff --git a/storage/devicetree.py b/storage/devicetree.py index 5fc7c64b6..7e3bd1077 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -570,10 +570,10 @@ class DeviceTree(object): else: ret = cmp(a2.device.name, a1.device.name) elif isinstance(a1.device, PartitionDevice) and \ - not isinstance(a2.device, DiskDevice): + a2.device.partitioned: ret = 1 elif isinstance(a2.device, PartitionDevice) and \ - not isinstance(a1.device, DiskDevice): + a1.device.partitioned: ret = -1 else: ret = 0 @@ -613,13 +613,13 @@ class DeviceTree(object): isinstance(a2.device, PartitionDevice): ret = cmp(a1.device.name, a2.device.name) elif isinstance(a1.device, PartitionDevice) and \ - not isinstance(a2.device, DiskDevice): + a2.device.partitioned: if a1.isGrow(): ret = -1 else: ret = 1 elif isinstance(a2.device, PartitionDevice) and \ - not isinstance(a1.device, DiskDevice): + a1.device.partitioned: if a2.isGrow(): ret = 1 else: @@ -653,10 +653,10 @@ class DeviceTree(object): else: ret = cmp(a1.device.name, a2.device.name) elif isinstance(a1.device, PartitionDevice) and \ - not isinstance(a2.device, DiskDevice): + a2.device.partitioned: ret = -1 elif isinstance(a2.device, PartitionDevice) and \ - not isinstance(a1.device, DiskDevice): + a1.device.partitioned: ret = 1 else: ret = 0 @@ -684,7 +684,7 @@ class DeviceTree(object): log.debug("resetting parted disks...") for device in self.devices: - if device.format.type == "disklabel": + if device.partitioned: device.format.resetPartedDisk() # reget parted.Partition for remaining preexisting devices @@ -1187,7 +1187,7 @@ class DeviceTree(object): kwargs["identifier"] = udev_device_get_fcoe_identifier(info) log.debug("%s is an fcoe disk" % name) elif udev_device_get_md_container(info): - diskType = PartitionableMDRaidArrayDevice + diskType = MDRaidArrayDevice parentName = devicePathToName(udev_device_get_md_container(info)) kwargs["parents"] = [ self.getDeviceByName(parentName) ] kwargs["level"] = udev_device_get_md_level(info) @@ -1253,7 +1253,7 @@ class DeviceTree(object): # The first step is to either look up or create the device # if udev_device_is_multipath_member(info): - device = StorageDevice(name, + device = DiskDevice(name, major=udev_device_get_major(info), minor=udev_device_get_minor(info), sysfsPath=sysfs_path, exists=True, @@ -1285,14 +1285,9 @@ class DeviceTree(object): if device is None: device = self.addUdevOpticalDevice(info) elif udev_device_is_biosraid(info) and udev_device_is_disk(info): - # This is special handling to avoid the "unrecognized disklabel" - # code since biosraid member disks won't have a disklabel. We - # use a StorageDevice because DiskDevices need disklabels. - # Quite lame, but it doesn't matter much since we won't use - # the StorageDevice instances for anything. log.debug("%s is part of a biosraid" % name) if device is None: - device = StorageDevice(name, + device = DiskDevice(name, major=udev_device_get_major(info), minor=udev_device_get_minor(info), sysfsPath=sysfs_path, exists=True) @@ -1314,23 +1309,28 @@ class DeviceTree(object): if device and device.name in self.protectedDevNames: device.protected = True - # Don't try to do format handling on drives without media - if device and not device.mediaPresent: + # Don't try to do format handling on drives without media or + # if we didn't end up with a device somehow. + if not device or not device.mediaPresent: return # Now, if the device is a disk, see if there is a usable disklabel. # If not, see if the user would like to create one. - # XXX this is the bit that forces disklabels on disks. Lame. - if isinstance(device, DiskDevice): + if device.partitionable: self.handleUdevDiskLabelFormat(info, device) - return + if device.partitioned or self.isIgnored(info): + # If the device has a disklabel, or the user chose not to + # create one, we are finished with this device. Otherwise + # it must have some non-disklabel formatting, in which case + # we fall through to handle that. + return # now handle the device's formatting self.handleUdevDeviceFormat(info, device) def handleUdevDiskLabelFormat(self, info, device): log_method_call(self, device=device.name) - if device.format.type == "disklabel": + if device.partitioned: # this device is already set up log.debug("disklabel format on %s already set up" % device.name) return @@ -1374,6 +1374,11 @@ class DeviceTree(object): device=device.path, exists=not initlabel) except InvalidDiskLabelError: + # if there is preexisting formatting on the device we will + # use it instead of ignoring the device + if not self.zeroMbr and \ + getFormat(udev_device_get_format(info)).type is not None: + return # if we have a cb function use it. else we ignore the device. if initcb is not None and initcb(): format = getFormat("disklabel", @@ -1770,7 +1775,7 @@ class DeviceTree(object): if shouldClear(device, self.clearPartType, clearPartDisks=self.clearPartDisks): - # if this is a partition that will be cleared by clearpart, + # if this is a device that will be cleared by clearpart, # don't bother with format-specific processing return diff --git a/storage/partitioning.py b/storage/partitioning.py index 8c6858fbd..5af8cb08f 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -43,7 +43,7 @@ def _createFreeSpacePartitions(anaconda): # get a list of disks that have at least one free space region of at # least 100MB disks = [] - for disk in anaconda.id.storage.disks: + for disk in anaconda.id.storage.partitioned: if anaconda.id.storage.clearPartDisks and \ (disk.name not in anaconda.id.storage.clearPartDisks): continue @@ -169,7 +169,8 @@ def doAutoPartition(anaconda): log.debug("clearPartType: %s" % anaconda.id.storage.clearPartType) 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("storage.disks: %s" % [d.name for d in anaconda.id.storage.disks]) + log.debug("storage.partitioned: %s" % [d.name for d in anaconda.id.storage.partitioned]) log.debug("all names: %s" % [d.name for d in anaconda.id.storage.devices]) if anaconda.dir == DISPATCH_BACK: anaconda.id.storage.reset() @@ -363,9 +364,8 @@ def clearPartitions(storage): # now remove any empty extended partitions removeEmptyExtendedPartitions(storage) - def removeEmptyExtendedPartitions(storage): - for disk in storage.disks: + for disk in storage.partitioned: log.debug("checking whether disk %s has an empty extended" % disk.name) extended = disk.format.extendedPartition logical_parts = disk.format.logicalPartitions @@ -742,7 +742,7 @@ def doPartitioning(storage, exclusiveDisks=None): """ anaconda = storage.anaconda - disks = storage.disks + disks = storage.partitioned if exclusiveDisks: disks = [d for d in disks if d.name in exclusiveDisks] diff --git a/textw/partition_text.py b/textw/partition_text.py index 81c1f05b0..a299b94e0 100644 --- a/textw/partition_text.py +++ b/textw/partition_text.py @@ -95,7 +95,7 @@ class PartitionTypeWindow: screen.pushHelpLine (_("<Space>,<+>,<-> selection | <F2> Add drive | <F12> next screen")) # restore the drive list each time - disks = anaconda.id.storage.disks + disks = anaconda.id.storage.partitioned cleardrives = anaconda.id.storage.clearPartDisks for disk in disks: |