Split up RequiredCommands task.

The requirements are now located in the appropriate modules
This commit is contained in:
Anders Ingemann 2014-02-23 22:03:13 +01:00
parent 5cff8f9b1d
commit 0ef1d3ab69
7 changed files with 61 additions and 30 deletions

View file

@ -12,7 +12,7 @@ from common.tasks import security
from common.tasks import locale from common.tasks import locale
base_set = [workspace.CreateWorkspace, base_set = [workspace.CreateWorkspace,
host.AddExternalCommands, bootstrap.AddRequiredCommands,
host.CheckExternalCommands, host.CheckExternalCommands,
bootstrap.Bootstrap, bootstrap.Bootstrap,
workspace.DeleteWorkspace, workspace.DeleteWorkspace,
@ -20,11 +20,13 @@ base_set = [workspace.CreateWorkspace,
volume_set = [volume.Attach, volume_set = [volume.Attach,
volume.Detach, volume.Detach,
filesystem.AddRequiredCommands,
filesystem.Format, filesystem.Format,
filesystem.FStab, filesystem.FStab,
] ]
partitioning_set = [partitioning.PartitionVolume, partitioning_set = [partitioning.AddRequiredCommands,
partitioning.PartitionVolume,
partitioning.MapPartitions, partitioning.MapPartitions,
partitioning.UnmapPartitions, partitioning.UnmapPartitions,
] ]

View file

@ -1,10 +1,21 @@
from base import Task from base import Task
from common import phases from common import phases
from common.exceptions import TaskError from common.exceptions import TaskError
import host
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class AddRequiredCommands(Task):
description = 'Adding commands required bootstrapping Debian'
phase = phases.preparation
successors = [host.CheckExternalCommands]
@classmethod
def run(cls, info):
info.host_dependencies['debootstrap'] = 'debootstrap'
def get_bootstrap_args(info): def get_bootstrap_args(info):
executable = ['/usr/sbin/debootstrap'] executable = ['/usr/sbin/debootstrap']
options = ['--arch=' + info.manifest.system['architecture']] options = ['--arch=' + info.manifest.system['architecture']]

View file

@ -2,10 +2,22 @@ from base import Task
from common import phases from common import phases
from common.tools import log_check_call from common.tools import log_check_call
from bootstrap import Bootstrap from bootstrap import Bootstrap
from common.tasks import apt import apt
import host
import volume import volume
class AddRequiredCommands(Task):
description = 'Adding commands required for formatting the partitions'
phase = phases.preparation
successors = [host.CheckExternalCommands]
@classmethod
def run(cls, info):
if 'xfs' in (p.filesystem for p in info.volume.partition_map.partitions):
info.host_dependencies['mkfs.xfs'] = 'xfsprogs'
class Format(Task): class Format(Task):
description = 'Formatting the volume' description = 'Formatting the volume'
phase = phases.volume_preparation phase = phases.volume_preparation

View file

@ -3,35 +3,9 @@ from common import phases
from common.exceptions import TaskError from common.exceptions import TaskError
class AddExternalCommands(Task):
description = 'Determining which external commands are required'
phase = phases.preparation
@classmethod
def run(cls, info):
info.host_dependencies['debootstrap'] = 'debootstrap'
from common.fs.loopbackvolume import LoopbackVolume
if isinstance(info.volume, LoopbackVolume):
info.host_dependencies['qemu-img'] = 'qemu-utils'
info.host_dependencies['losetup'] = 'mount'
from common.fs.qemuvolume import QEMUVolume
if isinstance(info.volume, QEMUVolume):
info.host_dependencies['losetup'] = 'qemu-nbd'
if 'xfs' in (p.filesystem for p in info.volume.partition_map.partitions):
info.host_dependencies['mkfs.xfs'] = 'xfsprogs'
from base.fs.partitionmaps.none import NoPartitions
if not isinstance(info.volume.partition_map, NoPartitions):
info.host_dependencies['parted'] = 'parted'
info.host_dependencies['kpartx'] = 'kpartx'
class CheckExternalCommands(Task): class CheckExternalCommands(Task):
description = 'Checking availability of external commands' description = 'Checking availability of external commands'
phase = phases.preparation phase = phases.preparation
predecessors = [AddExternalCommands]
@classmethod @classmethod
def run(cls, info): def run(cls, info):

View file

@ -1,8 +1,25 @@
from base import Task from base import Task
from common import phases from common import phases
import host
import volume import volume
class AddRequiredCommands(Task):
description = 'Adding commands required for creating loopback volumes'
phase = phases.preparation
successors = [host.CheckExternalCommands]
@classmethod
def run(cls, info):
from common.fs.loopbackvolume import LoopbackVolume
if isinstance(info.volume, LoopbackVolume):
info.host_dependencies['qemu-img'] = 'qemu-utils'
info.host_dependencies['losetup'] = 'mount'
from common.fs.qemuvolume import QEMUVolume
if isinstance(info.volume, QEMUVolume):
info.host_dependencies['losetup'] = 'qemu-nbd'
class Create(Task): class Create(Task):
description = 'Creating a loopback volume' description = 'Creating a loopback volume'
phase = phases.volume_creation phase = phases.volume_creation

View file

@ -1,9 +1,23 @@
from base import Task from base import Task
from common import phases from common import phases
import filesystem import filesystem
import host
import volume import volume
class AddRequiredCommands(Task):
description = 'Adding commands required for partitioning the volume'
phase = phases.preparation
successors = [host.CheckExternalCommands]
@classmethod
def run(cls, info):
from base.fs.partitionmaps.none import NoPartitions
if not isinstance(info.volume.partition_map, NoPartitions):
info.host_dependencies['parted'] = 'parted'
info.host_dependencies['kpartx'] = 'kpartx'
class PartitionVolume(Task): class PartitionVolume(Task):
description = 'Partitioning the volume' description = 'Partitioning the volume'
phase = phases.volume_preparation phase = phases.volume_preparation

View file

@ -97,7 +97,8 @@ def resolve_tasks(taskset, manifest):
tasks.ebs.Attach, tasks.ebs.Attach,
filesystem.FStab, filesystem.FStab,
tasks.ebs.Snapshot], tasks.ebs.Snapshot],
's3': [loopback.Create, 's3': [loopback.AddRequiredCommands,
loopback.Create,
volume.Attach, volume.Attach,
tasks.filesystem.S3FStab, tasks.filesystem.S3FStab,
tasks.ami.BundleImage, tasks.ami.BundleImage,