[master 2/3] Include suggestions in error classes for unusable storage configurations.

dwlehman installerbot-noreply at redhat.com
Fri Apr 10 19:58:23 UTC 2015


From: David Lehman <dlehman at redhat.com>

Related: rhbz#1158475
---
 blivet/errors.py    | 22 +++++++++++++++++++++-
 blivet/populator.py |  8 +++++---
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/blivet/errors.py b/blivet/errors.py
index b05c0c7..4a31987 100644
--- a/blivet/errors.py
+++ b/blivet/errors.py
@@ -20,6 +20,8 @@
 # Red Hat Author(s): Dave Lehman <dlehman at redhat.com>
 #
 
+from .i18n import N_
+
 class StorageError(Exception):
     def __init__(self, *args, **kwargs):
         self.hardware_fault = kwargs.pop("hardware_fault", False)
@@ -129,7 +131,25 @@ class DeviceNotFoundError(StorageError):
 
 class UnusableConfigurationError(StorageError):
     """ User has an unusable initial storage configuration. """
-    pass
+    suggestion = ""
+
+class DiskLabelScanError(UnusableConfigurationError):
+    suggestion = N_("For some reason we were unable to locate a disklabel on a "
+                    "disk that the kernel is reporting partitions on. It is "
+                    "unclear what the exact problem is. Please file a bug at "
+                    "http://bugzilla.redhat.com")
+
+class CorruptGPTError(UnusableConfigurationError):
+    suggestion = N_("Either restore the disklabel to a completely working "
+                    "state or remove it completely.\n"
+                    "Hint: parted can restore it or wipefs can remove it.")
+
+class DuplicateVGError(UnusableConfigurationError):
+    suggestion = N_("Rename one of the volume groups so the names are "
+                    "distinct.\n"
+                    "Hint 1: vgrename accepts UUID in place of the old name.\n"
+                    "Hint 2: You can get the VG UUIDs by running "
+                    "'pvs -o +vg_uuid'.")
 
 # DeviceAction
 class DeviceActionError(StorageError):
diff --git a/blivet/populator.py b/blivet/populator.py
index b3a3822..213f510 100644
--- a/blivet/populator.py
+++ b/blivet/populator.py
@@ -30,7 +30,7 @@
 from gi.repository import BlockDev as blockdev
 from gi.repository import GLib
 
-from .errors import DeviceError, DeviceTreeError, FSError, InvalidDiskLabelError, LUKSError, UnusableConfigurationError
+from .errors import CorruptGPTError, DeviceError, DeviceTreeError, DiskLabelScanError, DuplicateVGError, FSError, InvalidDiskLabelError, LUKSError
 from .devices import BTRFSSubVolumeDevice, BTRFSVolumeDevice, BTRFSSnapShotDevice
 from .devices import DASDDevice, DMDevice, DMLinearDevice, DMRaidArrayDevice, DiskDevice
 from .devices import FcoeDiskDevice, FileDevice, LoopDevice, LUKSDevice
@@ -436,10 +436,12 @@ def addUdevPartitionDevice(self, info, disk=None):
                not self._isIgnoredDisk(disk):
                 if info.get("ID_PART_TABLE_TYPE") == "gpt":
                     msg = "corrupt gpt disklabel on disk %s" % disk.name
+                    cls = CorruptGPTError
                 else:
                     msg = "failed to scan disk %s" % disk.name
+                    cls = DiskLabelScanError
 
-                raise UnusableConfigurationError(msg)
+                raise cls(msg)
 
             # there's no need to filter partitions on members of multipaths or
             # fwraid members from lvm since multipath and dmraid are already
@@ -1050,7 +1052,7 @@ def handleUdevLVMPVFormat(self, info, device):
             if isinstance(same_name, LVMVolumeGroupDevice) and \
                not (all(self._isIgnoredDisk(d) for d in same_name.disks) or
                     all(self._isIgnoredDisk(d) for d in device.disks)):
-                raise UnusableConfigurationError("multiple LVM volume groups with the same name")
+                raise DuplicateVGError("multiple LVM volume groups with the same name (%s)" % vg_name)
 
             try:
                 vg_size = Size(pv_info.vg_size)


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/3ac084a5bceca5f3d7a81a11f7adc0caf4924b66


More information about the anaconda-patches mailing list