[PATCH 4/5] Add handling for unusable storage configurations.

David Lehman dlehman at redhat.com
Tue Jul 7 22:32:58 UTC 2015


Show an error message and offer to retry or quit. The user can go to the
shell on buffer 2, resolve the issue, then return to the installer, retry
and continue.

(cherry picked from commit 8b27185f47b6ab423c91b93fc5030743ecbf46b3)

Resolves: rhbz#1236995
Resolves: rhbz#1198367
---
 pyanaconda/errors.py    | 26 ++++++++++++++++++++++++++
 pyanaconda/exception.py |  9 ++++++---
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/errors.py b/pyanaconda/errors.py
index 7cf2c66..7406806 100644
--- a/pyanaconda/errors.py
+++ b/pyanaconda/errors.py
@@ -25,6 +25,12 @@ __all__ = ["ERROR_RAISE", "ERROR_CONTINUE", "ERROR_RETRY",
            "MediaMountError", "ScriptError", "CmdlineError",
            "errorHandler"]
 
+# Only run the pango markup escape if the GUI is available
+try:
+    from pyanaconda.ui.gui.utils import escape_markup
+except ImportError:
+    escape_markup = lambda x: x
+
 class InvalidImageSizeError(Exception):
     def __init__(self, message, filename):
         Exception.__init__(self, message)
@@ -115,6 +121,22 @@ class ErrorHandler(object):
         self.ui.showError(message)
         return ERROR_RAISE
 
+    def _storageResetHandler(self, exn):
+        message = (_("There is a problem with your existing storage "
+                     "configuration: <b>%(errortxt)s</b>\n\n"
+                     "You 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."
+                     "\n\nOnce you have resolved the issue you can retry the "
+                     "storage scan. If you do not fix it you will have to exit "
+                     "the installer.") % {"errortxt": escape_markup(exn.message)})
+        details = _(exn.suggestion)
+        buttons = (_("_Exit Installer"), _("_Retry"))
+        if self.ui.showDetailedError(message, details, buttons=buttons):
+            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 "
@@ -282,6 +304,10 @@ class ErrorHandler(object):
 
         _map = {"PartitioningError": self._partitionErrorHandler,
                 "FSResizeError": self._fsResizeHandler,
+                "UnusableConfigurationError": self._storageResetHandler,
+                "DiskLabelScanError": self._storageResetHandler,
+                "CorruptGPTError": self._storageResetHandler,
+                "DuplicateVGError": self._storageResetHandler,
                 "NoDisksError": self._noDisksHandler,
                 "DirtyFSError": self._dirtyFSHandler,
                 "FSTabTypeMismatchError": self._fstabTypeMismatchHandler,
diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index aa2d6b8..366c107 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -69,9 +69,12 @@ class AnacondaExceptionHandler(ExceptionHandler):
         :type dump_info: an instance of the meh.DumpInfo class
 
         """
-
-        super(AnacondaExceptionHandler, self).handleException(dump_info)
-        return False
+        if isinstance(dump_info.exc_info.value,
+                      blivet.errors.UnusableConfigurationError):
+            sys.exit(0)
+        else:
+            super(AnacondaExceptionHandler, self).handleException(dump_info)
+            return False
 
     def handleException(self, dump_info):
         """
-- 
2.4.3



More information about the anaconda-patches mailing list