

from __future__ import absolute_import

from vdsm.storage import operation

_FALLOCATE = "/usr/libexec/vdsm/fallocate"


def allocate(image, size, offset=0):
    cmd = [_FALLOCATE]

    if offset > 0:
        cmd.extend(("--offset", str(offset)))

    cmd.append(str(size))
    cmd.append(image)

    return operation.Command(cmd)
