[PATCH 1/2] Include suggestions in error classes for unusable storage configurations.

David Lehman dlehman at redhat.com
Tue Jul 7 21:36:30 UTC 2015


(cherry picked from commit e44aaeeacdabd294793a5932cfbcfb97a752e5fc)

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

diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 05b6dca..fed90f7 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -28,7 +28,7 @@ import pprint
 import copy
 import parted
 
-from .errors import CryptoError, DeviceError, DeviceTreeError, DiskLabelCommitError, DMError, FSError, InvalidDiskLabelError, LUKSError, MDRaidError, StorageError, UnusableConfigurationError
+from .errors import CorruptGPTError, CryptoError, DeviceError, DeviceTreeError, DiskLabelCommitError, DiskLabelScanError, DMError, DuplicateVGError, FSError, InvalidDiskLabelError, LUKSError, MDRaidError, StorageError
 from .devices import BTRFSDevice, BTRFSSubVolumeDevice, BTRFSVolumeDevice, BTRFSSnapShotDevice
 from .devices import DASDDevice, DMDevice, DMLinearDevice, DMRaidArrayDevice, DiskDevice
 from .devices import FcoeDiskDevice, FileDevice, LoopDevice, LUKSDevice
@@ -961,10 +961,12 @@ class DeviceTree(object):
                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
@@ -1595,7 +1597,7 @@ class DeviceTree(object):
             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 = udev.device_get_vg_size(pv_info)
diff --git a/blivet/errors.py b/blivet/errors.py
index 51fd1f0..a063c56 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)
@@ -158,7 +160,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):
-- 
2.4.3



More information about the anaconda-patches mailing list