Skip to content

Commit

Permalink
Add a LUKS resize task.
Browse files Browse the repository at this point in the history
Related: #56

Signed-off-by: mulhern <amulhern@redhat.com>
  • Loading branch information
mulkieran committed Jun 18, 2015
1 parent 48d853d commit 916f51a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions blivet/tasks/lukstasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
#
# Red Hat Author(s): Anne Mulhern <amulhern@redhat.com>

from gi.repository import BlockDev as blockdev

from .. import util

from ..devicelibs import crypto
from ..errors import LUKSError
from ..size import Size

Expand Down Expand Up @@ -101,3 +104,27 @@ def doTask(self):
if error_msg:
raise LUKSError(error_msg)
return self._extractSize(out)

class LUKSResize(task.BasicApplication, dfresize.DFResizeTask):
""" Handle resize of LUKS device. """

description = "resize luks device"

ext = availability.BLOCKDEV_CRYPTO_PLUGIN

# units for specifying new size
unit = crypto.SECTOR_SIZE

def __init__(self, a_luks):
""" Initializer.
:param :class:`~.formats.luks.LUKS` a_luks: a LUKS format object
"""
self.luks = a_luks

def doTask(self):
""" Resizes the LUKS format. """
try:
blockdev.crypto.luks_resize(self.luks.mapName, self.luks.targetSize.convertTo(self.unit))
except blockdev.CryptoError as e:
raise LUKSError(e)

0 comments on commit 916f51a

Please sign in to comment.