neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

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

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