neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone
Vojtech Trefny ba16cb
From b9021fde8ccdd14cbe192b6597f7ca350b4bb585 Mon Sep 17 00:00:00 2001
Vojtech Trefny 66ecf7
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny 66ecf7
Date: Wed, 26 May 2021 12:15:54 +0200
Vojtech Trefny 66ecf7
Subject: [PATCH] Revert "More consistent lvm errors (API break)"
Vojtech Trefny 66ecf7
Vojtech Trefny 66ecf7
This reverts commit 49ec071c6d0673224a0774d613904387c52c7381.
Vojtech Trefny 66ecf7
---
Vojtech Trefny ba16cb
 blivet/devices/lvm.py                     | 72 +++++++++++------------
Vojtech Trefny ba16cb
 tests/unit_tests/devices_test/lvm_test.py | 14 ++---
Vojtech Trefny 66ecf7
 2 files changed, 43 insertions(+), 43 deletions(-)
Vojtech Trefny 66ecf7
Vojtech Trefny 66ecf7
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
Vojtech Trefny ba16cb
index 38e49e18..b8595d63 100644
Vojtech Trefny 66ecf7
--- a/blivet/devices/lvm.py
Vojtech Trefny 66ecf7
+++ b/blivet/devices/lvm.py
Vojtech Trefny ba16cb
@@ -304,7 +304,7 @@ class LVMVolumeGroupDevice(ContainerDevice):
Vojtech Trefny 66ecf7
     def _add_log_vol(self, lv):
Vojtech Trefny 66ecf7
         """ Add an LV to this VG. """
Vojtech Trefny 66ecf7
         if lv in self._lvs:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("lv is already part of this vg")
Vojtech Trefny 66ecf7
+            raise ValueError("lv is already part of this vg")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         # verify we have the space, then add it
Vojtech Trefny 66ecf7
         # do not verify for growing vg (because of ks)
Vojtech Trefny ba16cb
@@ -337,7 +337,7 @@ class LVMVolumeGroupDevice(ContainerDevice):
Vojtech Trefny 66ecf7
     def _remove_log_vol(self, lv):
Vojtech Trefny 66ecf7
         """ Remove an LV from this VG. """
Vojtech Trefny 66ecf7
         if lv not in self.lvs:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("specified lv is not part of this vg")
Vojtech Trefny 66ecf7
+            raise ValueError("specified lv is not part of this vg")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         self._lvs.remove(lv)
Vojtech Trefny 66ecf7
 
Vojtech Trefny ba16cb
@@ -430,7 +430,7 @@ class LVMVolumeGroupDevice(ContainerDevice):
Vojtech Trefny 66ecf7
     @thpool_reserve.setter
Vojtech Trefny 66ecf7
     def thpool_reserve(self, value):
Vojtech Trefny 66ecf7
         if value is not None and not isinstance(value, ThPoolReserveSpec):
Vojtech Trefny 66ecf7
-            raise AttributeError("Invalid thpool_reserve given, must be of type ThPoolReserveSpec")
Vojtech Trefny 66ecf7
+            raise ValueError("Invalid thpool_reserve given, must be of type ThPoolReserveSpec")
Vojtech Trefny 66ecf7
         self._thpool_reserve = value
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @property
Vojtech Trefny ba16cb
@@ -665,14 +665,14 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
Vojtech Trefny ba16cb
             if seg_type not in [None, "linear", "thin", "thin-pool", "cache", "vdo-pool", "vdo", "cache-pool"] + lvm.raid_seg_types:
Vojtech Trefny 66ecf7
                 raise ValueError("Invalid or unsupported segment type: %s" % seg_type)
Vojtech Trefny 66ecf7
             if seg_type and seg_type in lvm.raid_seg_types and not pvs:
Vojtech Trefny 66ecf7
-                raise errors.DeviceError("List of PVs has to be given for every non-linear LV")
Vojtech Trefny 66ecf7
+                raise ValueError("List of PVs has to be given for every non-linear LV")
Vojtech Trefny 66ecf7
             elif (not seg_type or seg_type == "linear") and pvs:
Vojtech Trefny 66ecf7
                 if not all(isinstance(pv, LVPVSpec) for pv in pvs):
Vojtech Trefny 66ecf7
-                    raise errors.DeviceError("Invalid specification of PVs for a linear LV: either no or complete "
Vojtech Trefny 66ecf7
-                                             "specification (with all space split into PVs has to be given")
Vojtech Trefny 66ecf7
+                    raise ValueError("Invalid specification of PVs for a linear LV: either no or complete "
Vojtech Trefny 66ecf7
+                                     "specification (with all space split into PVs has to be given")
Vojtech Trefny 66ecf7
                 elif sum(spec.size for spec in pvs) != size:
Vojtech Trefny 66ecf7
-                    raise errors.DeviceError("Invalid specification of PVs for a linear LV: the sum of space "
Vojtech Trefny 66ecf7
-                                             "assigned to PVs is not equal to the size of the LV")
Vojtech Trefny 66ecf7
+                    raise ValueError("Invalid specification of PVs for a linear LV: the sum of space "
Vojtech Trefny 66ecf7
+                                     "assigned to PVs is not equal to the size of the LV")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         # When this device's format is set in the superclass constructor it will
Vojtech Trefny 66ecf7
         # try to access self.snapshots.
Vojtech Trefny ba16cb
@@ -721,13 +721,13 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
Vojtech Trefny 66ecf7
         self._from_lvs = from_lvs
Vojtech Trefny 66ecf7
         if self._from_lvs:
Vojtech Trefny 66ecf7
             if exists:
Vojtech Trefny 66ecf7
-                raise errors.DeviceError("Only new LVs can be created from other LVs")
Vojtech Trefny 66ecf7
+                raise ValueError("Only new LVs can be created from other LVs")
Vojtech Trefny 66ecf7
             if size or maxsize or percent:
Vojtech Trefny 66ecf7
-                raise errors.DeviceError("Cannot specify size for a converted LV")
Vojtech Trefny 66ecf7
+                raise ValueError("Cannot specify size for a converted LV")
Vojtech Trefny 66ecf7
             if fmt:
Vojtech Trefny 66ecf7
-                raise errors.DeviceError("Cannot specify format for a converted LV")
Vojtech Trefny 66ecf7
+                raise ValueError("Cannot specify format for a converted LV")
Vojtech Trefny 66ecf7
             if any(lv.vg != self.vg for lv in self._from_lvs):
Vojtech Trefny 66ecf7
-                raise errors.DeviceError("Conversion of LVs only possible inside a VG")
Vojtech Trefny 66ecf7
+                raise ValueError("Conversion of LVs only possible inside a VG")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         self._cache = None
Vojtech Trefny 66ecf7
         if cache_request and not self.exists:
Vojtech Trefny ba16cb
@@ -746,13 +746,13 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
Vojtech Trefny 66ecf7
             elif isinstance(pv_spec, StorageDevice):
Vojtech Trefny 66ecf7
                 self._pv_specs.append(LVPVSpec(pv_spec, Size(0)))
Vojtech Trefny 66ecf7
             else:
Vojtech Trefny 66ecf7
-                raise AttributeError("Invalid PV spec '%s' for the '%s' LV" % (pv_spec, self.name))
Vojtech Trefny 66ecf7
+                raise ValueError("Invalid PV spec '%s' for the '%s' LV" % (pv_spec, self.name))
Vojtech Trefny 66ecf7
         # Make sure any destination PVs are actually PVs in this VG
Vojtech Trefny 66ecf7
         if not set(spec.pv for spec in self._pv_specs).issubset(set(self.vg.parents)):
Vojtech Trefny 66ecf7
             missing = [r.name for r in
Vojtech Trefny 66ecf7
                        set(spec.pv for spec in self._pv_specs).difference(set(self.vg.parents))]
Vojtech Trefny 66ecf7
             msg = "invalid destination PV(s) %s for LV %s" % (missing, self.name)
Vojtech Trefny 66ecf7
-            raise errors.DeviceError(msg)
Vojtech Trefny 66ecf7
+            raise ValueError(msg)
Vojtech Trefny 66ecf7
         if self._pv_specs:
Vojtech Trefny 66ecf7
             self._assign_pv_space()
Vojtech Trefny 66ecf7
 
Vojtech Trefny ba16cb
@@ -1130,7 +1130,7 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
Vojtech Trefny 66ecf7
         else:
Vojtech Trefny 66ecf7
             msg = "the specified internal LV '%s' doesn't belong to this LV ('%s')" % (int_lv.lv_name,
Vojtech Trefny 66ecf7
                                                                                        self.name)
Vojtech Trefny 66ecf7
-            raise errors.DeviceError(msg)
Vojtech Trefny 66ecf7
+            raise ValueError(msg)
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     def populate_ksdata(self, data):
Vojtech Trefny 66ecf7
         super(LVMLogicalVolumeBase, self).populate_ksdata(data)
Vojtech Trefny ba16cb
@@ -1229,7 +1229,7 @@ class LVMInternalLogicalVolumeMixin(object):
Vojtech Trefny 66ecf7
     def _init_check(self):
Vojtech Trefny 66ecf7
         # an internal LV should have no parents
Vojtech Trefny 66ecf7
         if self._parent_lv and self._parents:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("an internal LV should have no parents")
Vojtech Trefny 66ecf7
+            raise ValueError("an internal LV should have no parents")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @property
Vojtech Trefny 66ecf7
     def is_internal_lv(self):
Vojtech Trefny ba16cb
@@ -1289,7 +1289,7 @@ class LVMInternalLogicalVolumeMixin(object):
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @readonly.setter
Vojtech Trefny 66ecf7
     def readonly(self, value):  # pylint: disable=unused-argument
Vojtech Trefny 66ecf7
-        raise errors.DeviceError("Cannot make an internal LV read-write")
Vojtech Trefny 66ecf7
+        raise ValueError("Cannot make an internal LV read-write")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @property
Vojtech Trefny 66ecf7
     def type(self):
Vojtech Trefny ba16cb
@@ -1325,7 +1325,7 @@ class LVMInternalLogicalVolumeMixin(object):
Vojtech Trefny 66ecf7
     def _check_parents(self):
Vojtech Trefny 66ecf7
         # an internal LV should have no parents
Vojtech Trefny 66ecf7
         if self._parents:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("an internal LV should have no parents")
Vojtech Trefny 66ecf7
+            raise ValueError("an internal LV should have no parents")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     def _add_to_parents(self):
Vojtech Trefny 66ecf7
         # nothing to do here, an internal LV has no parents (in the DeviceTree's
Vojtech Trefny ba16cb
@@ -1335,13 +1335,13 @@ class LVMInternalLogicalVolumeMixin(object):
Vojtech Trefny 66ecf7
     # internal LVs follow different rules limitting size
Vojtech Trefny 66ecf7
     def _set_size(self, newsize):
Vojtech Trefny 66ecf7
         if not isinstance(newsize, Size):
Vojtech Trefny 66ecf7
-            raise AttributeError("new size must of type Size")
Vojtech Trefny 66ecf7
+            raise ValueError("new size must of type Size")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         if not self.takes_extra_space:
Vojtech Trefny 66ecf7
             if newsize <= self.parent_lv.size:  # pylint: disable=no-member
Vojtech Trefny 66ecf7
                 self._size = newsize  # pylint: disable=attribute-defined-outside-init
Vojtech Trefny 66ecf7
             else:
Vojtech Trefny 66ecf7
-                raise errors.DeviceError("Internal LV cannot be bigger than its parent LV")
Vojtech Trefny 66ecf7
+                raise ValueError("Internal LV cannot be bigger than its parent LV")
Vojtech Trefny 66ecf7
         else:
Vojtech Trefny 66ecf7
             # same rules apply as for any other LV
Vojtech Trefny 66ecf7
             raise NotTypeSpecific()
Vojtech Trefny ba16cb
@@ -1419,18 +1419,18 @@ class LVMSnapshotMixin(object):
Vojtech Trefny 66ecf7
             return
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         if self.origin and not isinstance(self.origin, LVMLogicalVolumeDevice):
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("lvm snapshot origin must be a logical volume")
Vojtech Trefny 66ecf7
+            raise ValueError("lvm snapshot origin must be a logical volume")
Vojtech Trefny 66ecf7
         if self.vorigin and not self.exists:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("only existing vorigin snapshots are supported")
Vojtech Trefny 66ecf7
+            raise ValueError("only existing vorigin snapshots are supported")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         if isinstance(self.origin, LVMLogicalVolumeDevice) and \
Vojtech Trefny 66ecf7
            isinstance(self.parents[0], LVMVolumeGroupDevice) and \
Vojtech Trefny 66ecf7
            self.origin.vg != self.parents[0]:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("lvm snapshot and origin must be in the same vg")
Vojtech Trefny 66ecf7
+            raise ValueError("lvm snapshot and origin must be in the same vg")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         if self.is_thin_lv:
Vojtech Trefny 66ecf7
             if self.origin and self.size and not self.exists:
Vojtech Trefny 66ecf7
-                raise errors.DeviceError("thin snapshot size is determined automatically")
Vojtech Trefny 66ecf7
+                raise ValueError("thin snapshot size is determined automatically")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @property
Vojtech Trefny 66ecf7
     def is_snapshot_lv(self):
Vojtech Trefny ba16cb
@@ -1606,7 +1606,7 @@ class LVMThinPoolMixin(object):
Vojtech Trefny 66ecf7
     def _check_from_lvs(self):
Vojtech Trefny 66ecf7
         if self._from_lvs:
Vojtech Trefny 66ecf7
             if len(self._from_lvs) != 2:
Vojtech Trefny 66ecf7
-                raise errors.DeviceError("two LVs required to create a thin pool")
Vojtech Trefny 66ecf7
+                raise ValueError("two LVs required to create a thin pool")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     def _convert_from_lvs(self):
Vojtech Trefny 66ecf7
         data_lv, metadata_lv = self._from_lvs
Vojtech Trefny ba16cb
@@ -1652,7 +1652,7 @@ class LVMThinPoolMixin(object):
Vojtech Trefny 66ecf7
     def _add_log_vol(self, lv):
Vojtech Trefny 66ecf7
         """ Add an LV to this pool. """
Vojtech Trefny 66ecf7
         if lv in self._lvs:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("lv is already part of this vg")
Vojtech Trefny 66ecf7
+            raise ValueError("lv is already part of this vg")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         # TODO: add some checking to prevent overcommit for preexisting
Vojtech Trefny 66ecf7
         self.vg._add_log_vol(lv)
Vojtech Trefny ba16cb
@@ -1663,7 +1663,7 @@ class LVMThinPoolMixin(object):
Vojtech Trefny 66ecf7
     def _remove_log_vol(self, lv):
Vojtech Trefny 66ecf7
         """ Remove an LV from this pool. """
Vojtech Trefny 66ecf7
         if lv not in self._lvs:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("specified lv is not part of this vg")
Vojtech Trefny 66ecf7
+            raise ValueError("specified lv is not part of this vg")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         self._lvs.remove(lv)
Vojtech Trefny 66ecf7
         self.vg._remove_log_vol(lv)
Vojtech Trefny ba16cb
@@ -1772,14 +1772,14 @@ class LVMThinLogicalVolumeMixin(object):
Vojtech Trefny 66ecf7
         """Check that this device has parents as expected"""
Vojtech Trefny 66ecf7
         if isinstance(self.parents, (list, ParentList)):
Vojtech Trefny 66ecf7
             if len(self.parents) != 1:
Vojtech Trefny 66ecf7
-                raise errors.DeviceError("constructor requires a single thin-pool LV")
Vojtech Trefny 66ecf7
+                raise ValueError("constructor requires a single thin-pool LV")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
             container = self.parents[0]
Vojtech Trefny 66ecf7
         else:
Vojtech Trefny 66ecf7
             container = self.parents
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         if not container or not isinstance(container, LVMLogicalVolumeDevice) or not container.is_thin_pool:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("constructor requires a thin-pool LV")
Vojtech Trefny 66ecf7
+            raise ValueError("constructor requires a thin-pool LV")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @property
Vojtech Trefny 66ecf7
     def is_thin_lv(self):
Vojtech Trefny ba16cb
@@ -1816,7 +1816,7 @@ class LVMThinLogicalVolumeMixin(object):
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     def _set_size(self, newsize):
Vojtech Trefny 66ecf7
         if not isinstance(newsize, Size):
Vojtech Trefny 66ecf7
-            raise AttributeError("new size must of type Size")
Vojtech Trefny 66ecf7
+            raise ValueError("new size must of type Size")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         newsize = self.vg.align(newsize)
Vojtech Trefny 66ecf7
         newsize = self.vg.align(util.numeric_type(newsize))
Vojtech Trefny ba16cb
@@ -2499,7 +2499,7 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
Vojtech Trefny 66ecf7
             container = self.parents
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         if not isinstance(container, LVMVolumeGroupDevice):
Vojtech Trefny 66ecf7
-            raise AttributeError("constructor requires a LVMVolumeGroupDevice")
Vojtech Trefny 66ecf7
+            raise ValueError("constructor requires a LVMVolumeGroupDevice")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @type_specific
Vojtech Trefny 66ecf7
     def _add_to_parents(self):
Vojtech Trefny ba16cb
@@ -2510,12 +2510,12 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
Vojtech Trefny 66ecf7
     @type_specific
Vojtech Trefny 66ecf7
     def _check_from_lvs(self):
Vojtech Trefny 66ecf7
         """Check the LVs to create this LV from"""
Vojtech Trefny 66ecf7
-        raise errors.DeviceError("Cannot create a new LV of type '%s' from other LVs" % self.seg_type)
Vojtech Trefny 66ecf7
+        raise ValueError("Cannot create a new LV of type '%s' from other LVs" % self.seg_type)
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @type_specific
Vojtech Trefny 66ecf7
     def _convert_from_lvs(self):
Vojtech Trefny 66ecf7
         """Convert the LVs to create this LV from into its internal LVs"""
Vojtech Trefny 66ecf7
-        raise errors.DeviceError("Cannot create a new LV of type '%s' from other LVs" % self.seg_type)
Vojtech Trefny 66ecf7
+        raise ValueError("Cannot create a new LV of type '%s' from other LVs" % self.seg_type)
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @property
Vojtech Trefny 66ecf7
     def external_dependencies(self):
Vojtech Trefny ba16cb
@@ -2535,7 +2535,7 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
Vojtech Trefny 66ecf7
     @type_specific
Vojtech Trefny 66ecf7
     def _set_size(self, newsize):
Vojtech Trefny 66ecf7
         if not isinstance(newsize, Size):
Vojtech Trefny 66ecf7
-            raise AttributeError("new size must be of type Size")
Vojtech Trefny 66ecf7
+            raise ValueError("new size must be of type Size")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         newsize = self.vg.align(newsize)
Vojtech Trefny 66ecf7
         log.debug("trying to set lv %s size to %s", self.name, newsize)
Vojtech Trefny ba16cb
@@ -2544,7 +2544,7 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
Vojtech Trefny 66ecf7
         # space for it. A similar reasoning applies to shrinking the LV.
Vojtech Trefny 66ecf7
         if not self.exists and newsize > self.size and newsize > self.vg.free_space + self.vg_space_used:
Vojtech Trefny 66ecf7
             log.error("failed to set size: %s short", newsize - (self.vg.free_space + self.vg_space_used))
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("not enough free space in volume group")
Vojtech Trefny 66ecf7
+            raise ValueError("not enough free space in volume group")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         LVMLogicalVolumeBase._set_size(self, newsize)
Vojtech Trefny 66ecf7
 
Vojtech Trefny ba16cb
@@ -2910,7 +2910,7 @@ class LVMCache(Cache):
Vojtech Trefny 66ecf7
                 spec.size = spec.pv.format.free
Vojtech Trefny 66ecf7
                 space_to_assign -= spec.pv.format.free
Vojtech Trefny 66ecf7
         if space_to_assign > 0:
Vojtech Trefny 66ecf7
-            raise errors.DeviceError("Not enough free space in the PVs for this cache: %s short" % space_to_assign)
Vojtech Trefny 66ecf7
+            raise ValueError("Not enough free space in the PVs for this cache: %s short" % space_to_assign)
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
     @property
Vojtech Trefny 66ecf7
     def size(self):
Vojtech Trefny ba16cb
diff --git a/tests/unit_tests/devices_test/lvm_test.py b/tests/unit_tests/devices_test/lvm_test.py
Vojtech Trefny ba16cb
index 47613fdc..995c2da4 100644
Vojtech Trefny ba16cb
--- a/tests/unit_tests/devices_test/lvm_test.py
Vojtech Trefny ba16cb
+++ b/tests/unit_tests/devices_test/lvm_test.py
Vojtech Trefny ba16cb
@@ -32,10 +32,10 @@ class LVMDeviceTest(unittest.TestCase):
Vojtech Trefny 66ecf7
         lv = LVMLogicalVolumeDevice("testlv", parents=[vg],
Vojtech Trefny 66ecf7
                                     fmt=blivet.formats.get_format("xfs"))
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
-        with six.assertRaisesRegex(self, errors.DeviceError, "lvm snapshot origin must be a logical volume"):
Vojtech Trefny 66ecf7
+        with six.assertRaisesRegex(self, ValueError, "lvm snapshot origin must be a logical volume"):
Vojtech Trefny 66ecf7
             LVMLogicalVolumeDevice("snap1", parents=[vg], origin=pv)
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
-        with six.assertRaisesRegex(self, errors.DeviceError, "only existing vorigin snapshots are supported"):
Vojtech Trefny 66ecf7
+        with six.assertRaisesRegex(self, ValueError, "only existing vorigin snapshots are supported"):
Vojtech Trefny 66ecf7
             LVMLogicalVolumeDevice("snap1", parents=[vg], vorigin=True)
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         lv.exists = True
Vojtech Trefny ba16cb
@@ -60,7 +60,7 @@ class LVMDeviceTest(unittest.TestCase):
Vojtech Trefny 66ecf7
         pool = LVMLogicalVolumeDevice("pool1", parents=[vg], size=Size("500 MiB"), seg_type="thin-pool")
Vojtech Trefny 66ecf7
         thinlv = LVMLogicalVolumeDevice("thinlv", parents=[pool], size=Size("200 MiB"), seg_type="thin")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
-        with six.assertRaisesRegex(self, errors.DeviceError, "lvm snapshot origin must be a logical volume"):
Vojtech Trefny 66ecf7
+        with six.assertRaisesRegex(self, ValueError, "lvm snapshot origin must be a logical volume"):
Vojtech Trefny 66ecf7
             LVMLogicalVolumeDevice("snap1", parents=[pool], origin=pv, seg_type="thin")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         # now make the constructor succeed so we can test some properties
Vojtech Trefny ba16cb
@@ -310,21 +310,21 @@ class LVMDeviceTest(unittest.TestCase):
Vojtech Trefny 66ecf7
         vg = LVMVolumeGroupDevice("testvg", parents=[pv, pv2])
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         # pvs have to be specified for non-linear LVs
Vojtech Trefny 66ecf7
-        with self.assertRaises(errors.DeviceError):
Vojtech Trefny 66ecf7
+        with self.assertRaises(ValueError):
Vojtech Trefny 66ecf7
             lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"),
Vojtech Trefny 66ecf7
                                         fmt=blivet.formats.get_format("xfs"),
Vojtech Trefny 66ecf7
                                         exists=False, seg_type="raid1")
Vojtech Trefny 66ecf7
-        with self.assertRaises(errors.DeviceError):
Vojtech Trefny 66ecf7
+        with self.assertRaises(ValueError):
Vojtech Trefny 66ecf7
             lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"),
Vojtech Trefny 66ecf7
                                         fmt=blivet.formats.get_format("xfs"),
Vojtech Trefny 66ecf7
                                         exists=False, seg_type="striped")
Vojtech Trefny 66ecf7
 
Vojtech Trefny 66ecf7
         # no or complete specification has to be given for linear LVs
Vojtech Trefny 66ecf7
-        with self.assertRaises(errors.DeviceError):
Vojtech Trefny 66ecf7
+        with self.assertRaises(ValueError):
Vojtech Trefny 66ecf7
             lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"),
Vojtech Trefny 66ecf7
                                         fmt=blivet.formats.get_format("xfs"),
Vojtech Trefny 66ecf7
                                         exists=False, pvs=[pv])
Vojtech Trefny 66ecf7
-        with self.assertRaises(errors.DeviceError):
Vojtech Trefny 66ecf7
+        with self.assertRaises(ValueError):
Vojtech Trefny 66ecf7
             pv_spec = LVPVSpec(pv, Size("256 MiB"))
Vojtech Trefny 66ecf7
             pv_spec2 = LVPVSpec(pv2, Size("250 MiB"))
Vojtech Trefny 66ecf7
             lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"),
Vojtech Trefny 66ecf7
-- 
Vojtech Trefny ba16cb
2.37.3
Vojtech Trefny 66ecf7