neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

Blame SOURCES/0014-Use-UnusableConfigurationError-for-patially-hidden-multipath-devices.patch

667f11
From 4e6a322d32d2a12f8a87ab763a6286cf3d7b5c27 Mon Sep 17 00:00:00 2001
667f11
From: Vojtech Trefny <vtrefny@redhat.com>
667f11
Date: Tue, 8 Sep 2020 13:57:40 +0200
667f11
Subject: [PATCH] Use UnusableConfigurationError for partially hidden multipath
667f11
 devices
667f11
667f11
Follow-up for https://github.com/storaged-project/blivet/pull/883
667f11
to make Anaconda show an error message instead of crashing.
667f11
667f11
Resolves: rhbz#1877052
667f11
---
667f11
 blivet/devicetree.py     | 4 ++--
667f11
 blivet/errors.py         | 6 ++++++
667f11
 tests/devicetree_test.py | 4 ++--
667f11
 3 files changed, 10 insertions(+), 4 deletions(-)
667f11
667f11
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
667f11
index 2afb0d0e..57a9bbd7 100644
667f11
--- a/blivet/devicetree.py
667f11
+++ b/blivet/devicetree.py
667f11
@@ -32,7 +32,7 @@ from gi.repository import BlockDev as blockdev
667f11
 
667f11
 from .actionlist import ActionList
667f11
 from .callbacks import callbacks
667f11
-from .errors import DeviceError, DeviceTreeError, StorageError, DuplicateUUIDError
667f11
+from .errors import DeviceError, DeviceTreeError, StorageError, DuplicateUUIDError, InvalidMultideviceSelection
667f11
 from .deviceaction import ActionDestroyDevice, ActionDestroyFormat
667f11
 from .devices import BTRFSDevice, NoDevice, PartitionDevice
667f11
 from .devices import LVMLogicalVolumeDevice, LVMVolumeGroupDevice
667f11
@@ -936,7 +936,7 @@ class DeviceTreeBase(object):
667f11
             if is_ignored:
667f11
                 if len(disk.children) == 1:
667f11
                     if not all(self._is_ignored_disk(d) for d in disk.children[0].parents):
667f11
-                        raise DeviceTreeError("Including only a subset of raid/multipath member disks is not allowed.")
667f11
+                        raise InvalidMultideviceSelection("Including only a subset of raid/multipath member disks is not allowed.")
667f11
 
667f11
                     # and also children like fwraid or mpath
667f11
                     self.hide(disk.children[0])
667f11
diff --git a/blivet/errors.py b/blivet/errors.py
667f11
index 811abf81..7a93f1ce 100644
667f11
--- a/blivet/errors.py
667f11
+++ b/blivet/errors.py
667f11
@@ -233,6 +233,12 @@ class DuplicateVGError(UnusableConfigurationError):
667f11
                     "Hint 2: You can get the VG UUIDs by running "
667f11
                     "'pvs -o +vg_uuid'.")
667f11
 
667f11
+
667f11
+class InvalidMultideviceSelection(UnusableConfigurationError):
667f11
+    suggestion = N_("All parent devices must be selected when choosing exclusive "
667f11
+                    "or ignored disks for a multipath or firmware RAID device.")
667f11
+
667f11
+
667f11
 # DeviceAction
667f11
 
667f11
 
667f11
diff --git a/tests/devicetree_test.py b/tests/devicetree_test.py
667f11
index 6032e7f6..4e47ffc3 100644
667f11
--- a/tests/devicetree_test.py
667f11
+++ b/tests/devicetree_test.py
667f11
@@ -5,7 +5,7 @@ import six
667f11
 import unittest
667f11
 
667f11
 from blivet.actionlist import ActionList
667f11
-from blivet.errors import DeviceTreeError, DuplicateUUIDError
667f11
+from blivet.errors import DeviceTreeError, DuplicateUUIDError, InvalidMultideviceSelection
667f11
 from blivet.deviceaction import ACTION_TYPE_DESTROY, ACTION_OBJECT_DEVICE
667f11
 from blivet.devicelibs import lvm
667f11
 from blivet.devices import DiskDevice
667f11
@@ -512,5 +512,5 @@ class DeviceTreeIgnoredExclusiveMultipathTestCase(unittest.TestCase):
667f11
         self.tree.ignored_disks = ["sda", "sdb"]
667f11
         self.tree.exclusive_disks = []
667f11
 
667f11
-        with self.assertRaises(DeviceTreeError):
667f11
+        with self.assertRaises(InvalidMultideviceSelection):
667f11
             self.tree._hide_ignored_disks()
667f11
-- 
667f11
2.26.2
667f11