[PATCH 2/2] Add handling for preexisting unusable storage configurations.

David Lehman dlehman at redhat.com
Fri Jan 9 21:34:57 UTC 2015


In the event that blivet finds a setup it cannot handle with any
reasonable expectation of success it will raise
UnusableConfigurationError. The user then has the option to resolve
the issue and retry the storage scan or exit the installer.

Related: rhbz#1123450
---
 pyanaconda/errors.py        | 16 ++++++++++++++++
 pyanaconda/exception.py     |  4 ++++
 pyanaconda/storage_utils.py | 13 +++++++++++--
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/pyanaconda/errors.py b/pyanaconda/errors.py
index a1671c6..436ea46 100644
--- a/pyanaconda/errors.py
+++ b/pyanaconda/errors.py
@@ -123,6 +123,21 @@ class ErrorHandler(object):
         self.ui.showError(message)
         return ERROR_RAISE
 
+    def _unusableStorageHandler(self, *args, **kwargs):
+        message = (_("An error has occurred while scanning your existing "
+                     "storage configuration:\n\n%(errortxt)s\n\nYou must "
+                     "resolve this matter before the installation can proceed. "
+                     "There is a shell available for use which you can access "
+                     "by pressing Ctrl-Alt-f1 and then Ctrl-b 2. Once you have "
+                     "resolved the issue you can either retry the storage scan "
+                     "or you can exit the installer.\n\n"
+                     "Would you like to retry?")
+                   % {"errortxt": kwargs["exception"]})
+        if self.ui.showYesNoQuestion(message):
+            return ERROR_RETRY
+        else:
+            return ERROR_RAISE
+
     def _noDisksHandler(self, exn):
         message = _("An error has occurred - no valid devices were found on "
                     "which to create new file systems.  Please check your "
@@ -287,6 +302,7 @@ class ErrorHandler(object):
 
         _map = {"PartitioningError": self._partitionErrorHandler,
                 "FSResizeError": self._fsResizeHandler,
+                "UnusableConfigurationError": self._unusableStorageHandler,
                 "NoDisksError": self._noDisksHandler,
                 "FSTabTypeMismatchError": self._fstabTypeMismatchHandler,
                 "InvalidImageSizeError": self._invalidImageSizeHandler,
diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index b8b8f4f..39da8ef 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -68,6 +68,10 @@ class AnacondaExceptionHandler(ExceptionHandler):
         :type dump_info: an instance of the meh.DumpInfo class
 
         """
+        cls = dump_info.exc_info.type
+        if issubclass(cls, blivet.errors.UnusableConfigurationError):
+            log.info("exiting due to unusable storage configuration")
+            sys.exit(0)
 
         super(AnacondaExceptionHandler, self).handleException(dump_info)
         return False
diff --git a/pyanaconda/storage_utils.py b/pyanaconda/storage_utils.py
index ca24ecb..a19f1bb 100644
--- a/pyanaconda/storage_utils.py
+++ b/pyanaconda/storage_utils.py
@@ -39,7 +39,7 @@ from blivet.devicefactory import DEVICE_TYPE_DISK
 from pyanaconda.i18n import _, N_
 from pyanaconda import isys
 from pyanaconda.constants import productName
-from pyanaconda.errors import UnknownSourceDeviceError
+from pyanaconda.errors import errorHandler, UnknownSourceDeviceError, ERROR_RETRY
 from pyanaconda.flags import flags
 
 from pykickstart.constants import AUTOPART_TYPE_PLAIN, AUTOPART_TYPE_BTRFS
@@ -110,7 +110,16 @@ def initialize_storage(storage, ksdata, protected):
     if protected:
         storage.config.protectedDevSpecs.extend(protected)
 
-    storage.reset()
+    while True:
+        try:
+            storage.reset()
+        except StorageError as e:
+            if errorHandler.cb(e) == ERROR_RETRY:
+                continue
+            else:
+                raise
+        else:
+            break
 
     if protected and not flags.livecdInstall and \
        not any(d.protected for d in storage.devices):
-- 
1.9.3



More information about the anaconda-patches mailing list