diff --git a/common/task_sets.py b/common/task_sets.py index 558ebb8..8af0ae7 100644 --- a/common/task_sets.py +++ b/common/task_sets.py @@ -12,7 +12,7 @@ from common.tasks import security from common.tasks import locale base_set = [workspace.CreateWorkspace, - host.AddExternalCommands, + bootstrap.AddRequiredCommands, host.CheckExternalCommands, bootstrap.Bootstrap, workspace.DeleteWorkspace, @@ -20,11 +20,13 @@ base_set = [workspace.CreateWorkspace, volume_set = [volume.Attach, volume.Detach, + filesystem.AddRequiredCommands, filesystem.Format, filesystem.FStab, ] -partitioning_set = [partitioning.PartitionVolume, +partitioning_set = [partitioning.AddRequiredCommands, + partitioning.PartitionVolume, partitioning.MapPartitions, partitioning.UnmapPartitions, ] diff --git a/common/tasks/bootstrap.py b/common/tasks/bootstrap.py index 8cb8d31..42d89ba 100644 --- a/common/tasks/bootstrap.py +++ b/common/tasks/bootstrap.py @@ -1,10 +1,21 @@ from base import Task from common import phases from common.exceptions import TaskError +import host import logging 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): executable = ['/usr/sbin/debootstrap'] options = ['--arch=' + info.manifest.system['architecture']] diff --git a/common/tasks/filesystem.py b/common/tasks/filesystem.py index 4f79af5..b8f87c7 100644 --- a/common/tasks/filesystem.py +++ b/common/tasks/filesystem.py @@ -2,10 +2,22 @@ from base import Task from common import phases from common.tools import log_check_call from bootstrap import Bootstrap -from common.tasks import apt +import apt +import host 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): description = 'Formatting the volume' phase = phases.volume_preparation diff --git a/common/tasks/host.py b/common/tasks/host.py index fbedaf3..0522a49 100644 --- a/common/tasks/host.py +++ b/common/tasks/host.py @@ -3,35 +3,9 @@ from common import phases 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): description = 'Checking availability of external commands' phase = phases.preparation - predecessors = [AddExternalCommands] @classmethod def run(cls, info): diff --git a/common/tasks/loopback.py b/common/tasks/loopback.py index 9420429..615de0d 100644 --- a/common/tasks/loopback.py +++ b/common/tasks/loopback.py @@ -1,8 +1,25 @@ from base import Task from common import phases +import host 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): description = 'Creating a loopback volume' phase = phases.volume_creation diff --git a/common/tasks/partitioning.py b/common/tasks/partitioning.py index a9d982c..88a8ebc 100644 --- a/common/tasks/partitioning.py +++ b/common/tasks/partitioning.py @@ -1,9 +1,23 @@ from base import Task from common import phases import filesystem +import host 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): description = 'Partitioning the volume' phase = phases.volume_preparation diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index eee1866..243dbd8 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -97,7 +97,8 @@ def resolve_tasks(taskset, manifest): tasks.ebs.Attach, filesystem.FStab, tasks.ebs.Snapshot], - 's3': [loopback.Create, + 's3': [loopback.AddRequiredCommands, + loopback.Create, volume.Attach, tasks.filesystem.S3FStab, tasks.ami.BundleImage,