Skip to content

Commit

Permalink
Implement the support for resizing internal metadata LVs of thin pools
Browse files Browse the repository at this point in the history
Internal metadata LVs of thin pools can be resized so our representation should
also allow it.
  • Loading branch information
vpodzime committed Jun 18, 2015
1 parent 7f84fa4 commit 7d1938f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion blivet/devices/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7d1938f

Please sign in to comment.