From: Vojtech Trefny <vtrefny(a)redhat.com>
Intead of raising "filesystem" exceptions (FSError and FSResizeError).
---
blivet/errors.py | 7 +++++++
blivet/formats/__init__.py | 18 ++++++++++--------
blivet/osinstall.py | 4 ++--
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/blivet/errors.py b/blivet/errors.py
index c446b28..809638b 100644
--- a/blivet/errors.py
+++ b/blivet/errors.py
@@ -86,6 +86,13 @@ class FormatTeardownError(DeviceFormatError):
pass
+class FormatResizeError(DeviceFormatError):
+
+ def __init__(self, message, details):
+ DeviceFormatError.__init__(self, message)
+ self.details = details
+
+
class DMRaidMemberError(DeviceFormatError):
pass
diff --git a/blivet/formats/__init__.py b/blivet/formats/__init__.py
index 1c26ed4..08aad82 100644
--- a/blivet/formats/__init__.py
+++ b/blivet/formats/__init__.py
@@ -40,7 +40,7 @@
from ..threads import SynchronizedMeta
from ..flags import flags
-from ..errors import FSError, FSResizeError #FIXME
+from ..errors import FSError, FSResizeError, LUKSError, FormatResizeError
from ..tasks import fsinfo
from ..tasks import fsresize
@@ -419,10 +419,10 @@ def _set_target_size(self, newsize):
raise ValueError("new size must be of type Size")
if not self.exists:
- raise FSError("filesystem has not been created")
+ raise DeviceFormatError("format has not been created")
if not self.resizable:
- raise FSError("filesystem is not resizable")
+ raise DeviceFormatError("format is not resizable")
if newsize < self.min_size:
raise ValueError("requested size %s must be at least minimum size
%s" % (newsize, self.min_size))
@@ -463,13 +463,13 @@ def update_size_info(self):
def do_resize(self):
""" Resize this filesystem based on this instance's
target_size attr.
- :raises: FSResizeError, FSError
+ :raises: FSResizeError, FormatResizeError
"""
if not self.exists:
- raise FSResizeError("filesystem does not exist", self.device)
+ raise FormatResizeError("format does not exist", self.device)
if not self.resizable:
- raise FSResizeError("filesystem not resizable", self.device)
+ raise FormatResizeError("format not resizable", self.device)
if self.target_size == self.current_size:
return
@@ -479,7 +479,7 @@ def do_resize(self):
# tmpfs mounts don't need an existing device node
if not self.device == "tmpfs" and not os.path.exists(self.device):
- raise FSResizeError("device does not exist", self.device)
+ raise FormatResizeError("device does not exist", self.device)
# The first minimum size can be incorrect if the fs was not
# properly unmounted. After do_check the minimum size will be correct
@@ -489,7 +489,7 @@ def do_resize(self):
# Check again if resizable is True, as update_size_info() can change that
if not self.resizable:
- raise FSResizeError("filesystem not resizable", self.device)
+ raise FormatResizeError("format not resizable", self.device)
if self.target_size < self.min_size:
self.target_size = self.min_size
@@ -530,6 +530,8 @@ def do_resize(self):
self._resize.do_task()
except FSError as e:
raise FSResizeError(e, self.device)
+ except LUKSError as e:
+ raise FormatResizeError(e, self.device)
self._post_resize()
diff --git a/blivet/osinstall.py b/blivet/osinstall.py
index 86f6ba9..ec6dd21 100644
--- a/blivet/osinstall.py
+++ b/blivet/osinstall.py
@@ -36,7 +36,7 @@
from .storage_log import log_exception_info
from .devices import FileDevice, NFSDevice, NoDevice, OpticalDevice,
NetworkStorageDevice, DirectoryDevice
-from .errors import FSTabTypeMismatchError, UnrecognizedFSTabEntryError, StorageError,
FSResizeError, UnknownSourceDeviceError
+from .errors import FSTabTypeMismatchError, UnrecognizedFSTabEntryError, StorageError,
FSResizeError, FormatResizeError, UnknownSourceDeviceError
from .formats import get_device_format_class
from .formats import get_format
from .flags import flags
@@ -1112,7 +1112,7 @@ def turn_on_filesystems(storage, mount_only=False, callbacks=None):
try:
storage.do_it(callbacks)
- except FSResizeError as e:
+ except (FSResizeError, FormatResizeError) as e:
if error_handler.cb(e) == ERROR_RAISE:
raise
except Exception as e:
--
To view this commit on github, visit
https://github.com/rhinstaller/blivet/commit/98758de053c55328e49ab3b0f7af...