2014-03-23 23:12:07 +01:00
|
|
|
from bootstrapvz.base import Task
|
2015-10-16 00:41:53 -03:00
|
|
|
from bootstrapvz.common import phases
|
2014-02-23 22:03:13 +01:00
|
|
|
import host
|
2013-09-15 13:19:45 +02:00
|
|
|
import volume
|
2013-07-13 15:10:04 +02:00
|
|
|
|
|
|
|
|
2014-02-23 22:03:13 +01:00
|
|
|
class AddRequiredCommands(Task):
|
2016-06-04 11:35:59 +02:00
|
|
|
description = 'Adding commands required for creating loopback volumes'
|
|
|
|
phase = phases.preparation
|
|
|
|
successors = [host.CheckExternalCommands]
|
2014-02-23 22:03:13 +01:00
|
|
|
|
2016-06-04 11:35:59 +02:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
from ..fs.loopbackvolume import LoopbackVolume
|
|
|
|
from ..fs.qemuvolume import QEMUVolume
|
|
|
|
if type(info.volume) is LoopbackVolume:
|
|
|
|
info.host_dependencies['losetup'] = 'mount'
|
|
|
|
info.host_dependencies['truncate'] = 'coreutils'
|
|
|
|
if isinstance(info.volume, QEMUVolume):
|
|
|
|
info.host_dependencies['qemu-img'] = 'qemu-utils'
|
2014-02-23 22:03:13 +01:00
|
|
|
|
|
|
|
|
2013-07-13 15:10:04 +02:00
|
|
|
class Create(Task):
|
2016-06-04 11:35:59 +02:00
|
|
|
description = 'Creating a loopback volume'
|
|
|
|
phase = phases.volume_creation
|
|
|
|
successors = [volume.Attach]
|
2013-07-13 15:10:04 +02:00
|
|
|
|
2016-06-04 11:35:59 +02:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
import os.path
|
|
|
|
image_path = os.path.join(info.workspace, 'volume.' + info.volume.extension)
|
|
|
|
info.volume.create(image_path)
|