diff options
author | Chris Lumens <clumens@redhat.com> | 2009-03-10 14:01:50 -0400 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2009-03-12 09:41:57 -0400 |
commit | 1c479aff318c1a9249135a21095170f7d5d61aa4 (patch) | |
tree | e821318a80571a4907c4133723a6af4afb8d2ff5 /storage | |
parent | b40033c68fb1644fe7743338462edf41e5c5b3f8 (diff) | |
download | anaconda-1c479aff318c1a9249135a21095170f7d5d61aa4.tar.gz anaconda-1c479aff318c1a9249135a21095170f7d5d61aa4.tar.xz anaconda-1c479aff318c1a9249135a21095170f7d5d61aa4.zip |
Always go through doAutoPart.
We need to do this in order to make sure doPartitioning gets called, which
does most of the magic of performing partitioning. We want to break out
the autopart stuff into separate functions and only call it in the autopart
case.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/partitioning.py | 113 |
1 files changed, 63 insertions, 50 deletions
diff --git a/storage/partitioning.py b/storage/partitioning.py index c10440145..66c0c29b3 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -40,25 +40,7 @@ _ = lambda x: gettext.ldgettext("anaconda", x) import logging log = logging.getLogger("storage") -def doAutoPartition(anaconda): - log.debug("doAutoPartition(%s)" % anaconda) - log.debug("doAutoPart: %s" % anaconda.id.storage.doAutoPart) - 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("all names: %s" % [d.name for d in anaconda.id.storage.devicetree.devices.values()]) - if anaconda.dir == DISPATCH_BACK: - anaconda.id.storage.reset() - return - - if anaconda.id.storage.doAutoPart or anaconda.isKickstart: - # kickstart uses clearPartitions even without autopart - clearPartitions(anaconda.id.storage) - - if not anaconda.id.storage.doAutoPart: - return - +def _createFreeSpacePartitions(anaconda): # get a list of disks that have at least one free space region of at # least 100MB disks = [] @@ -90,6 +72,9 @@ def doAutoPartition(anaconda): anaconda.id.storage.createDevice(part) devs.append(part) + return (disks, devs) + +def _schedulePartitions(anaconda, disks): # # Convert storage.autoPartitionRequests into Device instances and # schedule them for creation @@ -115,38 +100,9 @@ def doAutoPartition(anaconda): anaconda.id.storage.createDevice(dev) # make sure preexisting broken lvm/raid configs get out of the way + return - # sanity check the individual devices - log.warning("not sanity checking devices because I don't know how yet") - - # run the autopart function to allocate and grow partitions - try: - doPartitioning(anaconda.id.storage, - exclusiveDisks=anaconda.id.storage.clearPartDisks) - except PartitioningWarning as msg: - if not anaconda.isKickstart: - anaconda.intf.messageWindow(_("Warnings During Automatic " - "Partitioning"), - _("Following warnings occurred during automatic " - "partitioning:\n\n%s") % (msg,), - custom_icon='warning') - else: - log.warning(msg) - except PartitioningError as msg: - # restore drives to original state - anaconda.id.storage.reset() - if not anaconda.isKickstart: - extra = "" - anaconda.dispatch.skipStep("partition", skip = 0) - else: - extra = _("\n\nPress 'OK' to exit the installer.") - anaconda.intf.messageWindow(_("Error Partitioning"), - _("Could not allocate requested partitions: \n\n" - "%s.%s") % (msg, extra), custom_icon='error') - - if anaconda.isKickstart: - sys.exit(0) - +def _scheduleLVs(anaconda, devs): if anaconda.id.storage.encryptedAutoPart: pvs = [] for dev in devs: @@ -190,6 +146,63 @@ def doAutoPartition(anaconda): # grow the new VG and its LVs growLVM(anaconda.id.storage) +def doAutoPartition(anaconda): + log.debug("doAutoPartition(%s)" % anaconda) + log.debug("doAutoPart: %s" % anaconda.id.storage.doAutoPart) + 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("all names: %s" % [d.name for d in anaconda.id.storage.devicetree.devices.values()]) + if anaconda.dir == DISPATCH_BACK: + anaconda.id.storage.reset() + return + + disks = [] + devs = [] + + if anaconda.id.storage.doAutoPart or anaconda.isKickstart: + # kickstart uses clearPartitions even without autopart + clearPartitions(anaconda.id.storage) + + if anaconda.id.storage.doAutoPart: + (disks, devs) = _createFreeSpacePartitions(anaconda) + _schedulePartitions(anaconda, disks) + + # sanity check the individual devices + log.warning("not sanity checking devices because I don't know how yet") + + # run the autopart function to allocate and grow partitions + try: + doPartitioning(anaconda.id.storage, + exclusiveDisks=anaconda.id.storage.clearPartDisks) + except PartitioningWarning as msg: + if not anaconda.isKickstart: + anaconda.intf.messageWindow(_("Warnings During Automatic " + "Partitioning"), + _("Following warnings occurred during automatic " + "partitioning:\n\n%s") % (msg,), + custom_icon='warning') + else: + log.warning(msg) + except PartitioningError as msg: + # restore drives to original state + anaconda.id.storage.reset() + if not anaconda.isKickstart: + extra = "" + anaconda.dispatch.skipStep("partition", skip = 0) + else: + extra = _("\n\nPress 'OK' to exit the installer.") + anaconda.intf.messageWindow(_("Error Partitioning"), + _("Could not allocate requested partitions: \n\n" + "%s.%s") % (msg, extra), custom_icon='error') + + if anaconda.isKickstart: + sys.exit(0) + + if anaconda.id.storage.doAutoPart: + _scheduleLVs(anaconda, dev) + # sanity check the collection of devices log.warning("not sanity checking storage config because I don't know how yet") # now do a full check of the requests |