From: Vojtech Trefny vtrefny@redhat.com
--- blivet/blivet.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/blivet/blivet.py b/blivet/blivet.py index 19ff1b3..06d8e13 100644 --- a/blivet/blivet.py +++ b/blivet/blivet.py @@ -38,6 +38,7 @@ from .deviceaction import ActionDestroyFormat, ActionResizeDevice, ActionResizeFormat from .devicelibs.edd import get_edd_dict from .devicelibs.btrfs import MAIN_VOLUME_ID +from .devicelibs.crypto import LUKS_METADATA_SIZE from .errors import StorageError from .size import Size from .devicetree import DeviceTree @@ -1138,22 +1139,33 @@ def resize_device(self, device, new_size): if device.protected: raise ValueError("cannot modify protected device")
- classes = [] + actions = [] + if device.resizable: - classes.append(ActionResizeDevice) + actions.append(ActionResizeDevice(device, new_size)) + + if device.format.type == "luks" and device.children: + luks_dev = device.children[0] + + if luks_dev.resizable: + actions.append(ActionResizeDevice(luks_dev, new_size - LUKS_METADATA_SIZE))
- if device.format.resizable: - classes.append(ActionResizeFormat) + if luks_dev.format.resizable: + actions.append(ActionResizeFormat(luks_dev, new_size - LUKS_METADATA_SIZE)) + + else: + if device.format.resizable: + actions.append(ActionResizeFormat(device, new_size))
- if not classes: + if not actions: raise ValueError("device cannot be resized")
# if this is a shrink, schedule the format resize first if new_size < device.size: - classes.reverse() + actions.reverse()
- for action_class in classes: - self.devicetree.actions.add(action_class(device, new_size)) + for action in actions: + self.devicetree.actions.add(action)
def format_by_default(self, device): """Return whether the device should be reformatted by default."""
anaconda-patches@lists.fedorahosted.org