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