From 86748b36c2c15597b3dda9307080b27793dba54e Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Mon, 8 Jun 2015 12:45:28 +0200 Subject: [PATCH] Implement the support for resizing internal metadata LVs of thin pools Internal metadata LVs of thin pools can be resized so our representation should also allow it. --- blivet/devices/lvm.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py index 6c929c260..e56873c08 100644 --- a/blivet/devices/lvm.py +++ b/blivet/devices/lvm.py @@ -1030,12 +1030,34 @@ class LVMDataLogicalVolumeDevice(LVMInternalLogicalVolumeDevice): class LVMMetadataLogicalVolumeDevice(LVMInternalLogicalVolumeDevice): """Internal metadata LV (used by thin/cache pools, RAIDs, etc.)""" + # thin pool metadata LVs can be resized directly + _resizable = True + attr_letters = ["e"] # RAIDs can have multiple (numbered) metadata LVs name_suffix = r"_[trc]meta(_[0-9]+)?" takes_extra_space = True - # TODO: override and allow resize() + # (only) thin pool metadata LVs can be resized directly + @property + def resizable(self): + if self._parent_lv: + return isinstance(self._parent_lv, LVMThinPoolDevice) + else: + # hard to say at this point, just use the name + return not re.search(r'_[rc]meta', self.lvname) + + # (only) thin pool metadata LVs can be resized directly + def resize(self): + if ((self._parent_lv and not isinstance(self._parent_lv, LVMThinPoolDevice)) or + re.search(r'_[rc]meta', self.lvname)): + raise errors.DeviceError("RAID and cache pool metadata LVs cannot be resized directly") + + # skip the generic LVMInternalLogicalVolumeDevice class and call the + # resize() method of the LVMLogicalVolumeDevice + # pylint: disable=bad-super-call + super(LVMInternalLogicalVolumeDevice, self).resize() + _INTERNAL_LV_CLASSES.append(LVMMetadataLogicalVolumeDevice) class LVMLogLogicalVolumeDevice(LVMInternalLogicalVolumeDevice):