[PATCH 1/9] Always go through doAutoPart.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 storage/partitioning.py |  113 ++++++++++++++++++++++++++---------------------
 1 files changed, 63 insertions(+), 50 deletions(-)

diff --git a/storage/partitioning.py b/storage/partitioning.py
index c104401..66c0c29 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
-- 
1.6.1.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux