[PATCH 4/4] Raise UnusableConfigurationError when unusable configuration is detected.

David Lehman dlehman at redhat.com
Fri Jan 9 21:32:33 UTC 2015


The two cases included initially are a corrupt gpt disklabel and
multiple lvm volume groups with the same name.

Blivet cannot proceed in the corrupt gpt case because pyparted doesn't
support instantiating a parted.Disk if the underlying gpt disklabel is
corrupt.

The lvm case has several issues, the most basic being that lvm is not
designed to handle multiple volume groups with the same name. A user
would have to rename one of the same-named vgs manually in order to
make it possible to use both vgs.

Resolves: rhbz#1123450
---
 blivet/devicetree.py | 15 +++++++++++++--
 blivet/errors.py     |  4 ++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 2e5850a..37a0f97 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -27,7 +27,7 @@ import shutil
 import pprint
 import copy
 
-from .errors import CryptoError, DeviceError, DeviceTreeError, DiskLabelCommitError, DMError, FSError, InvalidDiskLabelError, LUKSError, MDRaidError, StorageError
+from .errors import UnusableConfigurationError, CryptoError, DeviceError, DeviceTreeError, DiskLabelCommitError, DMError, 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
@@ -946,7 +946,12 @@ class DeviceTree(object):
             if (disk.partitionable and not
                 (disk.format.type == "iso9660" or disk.format.hidden) and
                 (flags.installer_mode and not self._isIgnoredDisk(disk))):
-                raise DeviceTreeError("failed to scan disk %s" % disk.name)
+                if info.get("ID_PART_TABLE_TYPE") == "gpt":
+                    msg = "corrupt gpt disklabel on disk %s" % disk.name
+                else:
+                    msg = "failed to scan disk %s" % disk.name
+
+                raise UnusableConfigurationError(msg)
 
             # there's no need to filter partitions on members of multipaths or
             # fwraid members from lvm since multipath and dmraid are already
@@ -1554,6 +1559,12 @@ class DeviceTree(object):
         if vg_device:
             vg_device.parents.append(device)
         else:
+            same_name = self.getDeviceByName(vg_name)
+            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")
+
             try:
                 vg_size = udev.device_get_vg_size(pv_info)
                 vg_free = udev.device_get_vg_free(pv_info)
diff --git a/blivet/errors.py b/blivet/errors.py
index 71fb7c8..1dae5e3 100644
--- a/blivet/errors.py
+++ b/blivet/errors.py
@@ -151,6 +151,10 @@ class DeviceTreeError(StorageError):
 class DeviceNotFoundError(StorageError):
     pass
 
+class UnusableConfigurationError(StorageError):
+    """ User has an unusable initial storage configuration. """
+    pass
+
 # DeviceAction
 class DeviceActionError(StorageError):
     pass
-- 
1.9.3



More information about the anaconda-patches mailing list