[PATCH 4/5] Make sure storage is reset just before partitioning, always.

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

 



- reset storage from autopart_type only if custom selected
- reset storage last thing in cleardisks_gui for all autopart,
  including the single-disk case
- unset bootloader stage1_drive and stage1_device in
  Storage.reset since they are no longer valid after reset
- store autopart shrink requests in Storage and reschedule
  the actions as needed across storage resets when users go
  back and forth between cleardisks_gui and partitioning

Resolves: rhbz#741587
Related: rhbz#739408
---
 pyanaconda/iw/autopart_type.py     |   19 ++++++++++---------
 pyanaconda/iw/cleardisks_gui.py    |   20 ++++++++++++--------
 pyanaconda/storage/__init__.py     |    6 ++++++
 pyanaconda/storage/partitioning.py |   10 ++++++++++
 4 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/pyanaconda/iw/autopart_type.py b/pyanaconda/iw/autopart_type.py
index 47e089d..87907b8 100644
--- a/pyanaconda/iw/autopart_type.py
+++ b/pyanaconda/iw/autopart_type.py
@@ -149,14 +149,6 @@ class PartitionTypeWindow(InstallWindow):
         if self.storage.checkNoDisks():
             raise gui.StayOnScreen
 
-        # reset storage, this is only done when moving forward, not back
-        # temporarily unset storage.config.clearPartType so that all devices
-        # will be found during storage reset
-        clearPartType = self.anaconda.storage.config.clearPartType
-        self.anaconda.storage.config.clearPartType = None
-        self.anaconda.storage.reset()
-        self.anaconda.storage.config.clearPartType = clearPartType
-
         self.storage.clearPartChoice = self.buttonGroup.getCurrent()
 
         if self.buttonGroup.getCurrent() == "custom":
@@ -165,13 +157,22 @@ class PartitionTypeWindow(InstallWindow):
             self.dispatch.request_steps("partition")
             self.dispatch.request_steps_gently("bootloader")
 
+            # re-scan all devices. this is handled in cleardisks_gui if autopart
             self.storage.config.clearPartType = CLEARPART_TYPE_NONE
+            self.storage.reset()
         else:
             if self.buttonGroup.getCurrent() == "shrink":
+                # we need to store this information so that it can survive
+                # storage.reset since it may get called going between
+                # the partitioning screen and the cleardisks screen when users
+                # elect to do autopart w/ review and go back and forth
                 (rc, actions) = whichToShrink(self.storage, self.intf)
                 if rc == gtk.RESPONSE_OK:
                     for action in actions:
-                        self.storage.devicetree.registerAction(action)
+                        path = action.device.path
+                        size = action.device.targetSize
+                        self.storage.shrinkPartitions[path] = size
+                        self.storage.devicetree.cancelAction(action)
                 else:
                     raise gui.StayOnScreen
 
diff --git a/pyanaconda/iw/cleardisks_gui.py b/pyanaconda/iw/cleardisks_gui.py
index 9b84474..5ce6aee 100644
--- a/pyanaconda/iw/cleardisks_gui.py
+++ b/pyanaconda/iw/cleardisks_gui.py
@@ -57,12 +57,17 @@ class ClearDisksWindow (InstallWindow):
                                              custom_icon="error")
             raise gui.StayOnScreen
 
-        bootDisk = selected[0][OBJECT_COL]
-
         cleardisks.sort(self.anaconda.storage.compareDisks)
+        self.resetStorage(clear=cleardisks, boot=selected[0][OBJECT_COL].name)
 
-        self.anaconda.storage.config.clearPartDisks = cleardisks
-        self.anaconda.bootloader.stage1_drive = bootDisk
+    def resetStorage(self, clear=None, boot=None):
+        """ Save clearPartDisks and reset storage, preserving stage1_drive. """
+        # Re-scan the devices. We only come here for autopart, so the clearpart
+        # type should be set appropriately already.
+        self.anaconda.storage.config.clearPartDisks = clear
+        self.anaconda.storage.reset()
+        boot_disk = self.anaconda.storage.devicetree.getDeviceByName(boot)
+        self.anaconda.bootloader.stage1_drive = boot_disk
 
     def getScreen (self, anaconda):
         # We can't just use exclusiveDisks here because of kickstart.  First,
@@ -73,10 +78,11 @@ class ClearDisksWindow (InstallWindow):
         # issues.
         disks = filter(lambda d: not d.format.hidden, anaconda.storage.disks)
 
+        self.anaconda = anaconda
+
         # Skip this screen as well if there's only one disk to use.
         if len(disks) == 1:
-            anaconda.storage.config.clearPartDisks = [disks[0].name]
-            anaconda.bootloader.stage1_drive = disks[0]
+            self.resetStorage(clear=[disks[0].name], boot=disks[0].name)
             return None
 
         (xml, self.vbox) = gui.getGladeWidget("cleardisks.glade", "vbox")
@@ -87,8 +93,6 @@ class ClearDisksWindow (InstallWindow):
         self.installTargetImage = xml.get_widget("installTargetImage")
         self.installTargetTip = xml.get_widget("installTargetTip")
 
-        self.anaconda = anaconda
-
         self.leftVisible = 1
         self.leftActive = 2
         self.rightVisible = 4
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index d77e766..f42b49f 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -362,6 +362,7 @@ class Storage(object):
         self.autoPartAddBackupPassphrase = False
         self.encryptionRetrofit = False
         self.autoPartitionRequests = []
+        self.shrinkPartitions = {}
         self.eddDict = {}
 
         self.__luksDevs = {}
@@ -486,7 +487,12 @@ class Storage(object):
             self.anaconda.rootParts = None
             self.anaconda.upgradeRoot = None
         if self.anaconda:
+            # clear out bootloader attributes that refer to devices that are
+            # no longer in the tree
             self.anaconda.bootloader.clear_drive_list()
+            self.anaconda.bootloader.stage1_drive = None
+            self.anaconda.bootloader.stage1_device = None
+
         self.dumpState("initial")
         if prog:
             prog.pop()
diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index e33943f..98ed172 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -227,6 +227,15 @@ def _scheduleLVs(storage, devs):
         # schedule the device for creation
         storage.createDevice(dev)
 
+def scheduleShrinkActions(storage):
+    """ Schedule actions to shrink partitions as per autopart selection. """
+    for (path, size) in storage.shrinkPartitions.items():
+        device = storage.getDeviceByPath(path)
+        if not device:
+            raise StorageError("device %s scheduled for shrink disappeared"
+                                % path)
+        storage.registerAction(ActionResizeFormat(device, size))
+        storage.registerAction(ActionResizeDevice(device, size))
 
 def doAutoPartition(anaconda):
     log.debug("doAutoPartition(%s)" % anaconda)
@@ -246,6 +255,7 @@ def doAutoPartition(anaconda):
     devs = []
 
     if anaconda.storage.doAutoPart:
+        scheduleShrinkActions(anaconda.storage)
         clearPartitions(anaconda.storage, bootloader=anaconda.bootloader)
         # update the bootloader's drive list to add disks which have their
         # whole disk format replaced by a disklabel. Make sure to keep any
-- 
1.7.3.4

_______________________________________________
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