mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
Fix #107. Rename before and after task properties
`before' becomes `successors' and `after' becomes `predecessors'
This commit is contained in:
parent
d05c97afef
commit
663b868b41
25 changed files with 61 additions and 61 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
class Task(object):
|
||||
phase = None
|
||||
before = []
|
||||
after = []
|
||||
predecessors = []
|
||||
successors = []
|
||||
|
||||
def __str__(self):
|
||||
return '{module}.{task}'.format(module=self.__module__, task=self.__class__.__name__)
|
||||
|
|
|
@ -36,8 +36,8 @@ class TaskList(object):
|
|||
for task in tasks:
|
||||
self.check_ordering(task)
|
||||
successors = set()
|
||||
successors.update(task.before)
|
||||
successors.update(filter(lambda succ: task in succ.after, tasks))
|
||||
successors.update(task.successors)
|
||||
successors.update(filter(lambda succ: task in succ.predecessors, tasks))
|
||||
succeeding_phases = order[order.index(task.phase) + 1:]
|
||||
successors.update(filter(lambda succ: succ.phase in succeeding_phases, tasks))
|
||||
graph[task] = filter(lambda succ: succ in tasks, successors)
|
||||
|
@ -58,13 +58,13 @@ class TaskList(object):
|
|||
return sorted_tasks
|
||||
|
||||
def check_ordering(self, task):
|
||||
for successor in task.before:
|
||||
for successor in task.successors:
|
||||
if successor.phase > successor.phase:
|
||||
msg = ("The task {task} is specified as running before {other}, "
|
||||
"but its phase '{phase}' lies after the phase '{other_phase}'"
|
||||
.format(task=task, other=successor, phase=task.phase, other_phase=successor.phase))
|
||||
raise TaskListError(msg)
|
||||
for predecessor in task.after:
|
||||
for predecessor in task.predecessors:
|
||||
if task.phase < predecessor.phase:
|
||||
msg = ("The task {task} is specified as running after {other}, "
|
||||
"but its phase '{phase}' lies before the phase '{other_phase}'"
|
||||
|
|
|
@ -42,8 +42,8 @@ class DisableDaemonAutostart(Task):
|
|||
class AptUpgrade(Task):
|
||||
description = 'Upgrading packages and fixing broken dependencies'
|
||||
phase = phases.system_modification
|
||||
before = [network.RemoveDNSInfo]
|
||||
after = [locale.GenerateLocale, AptSources, DisableDaemonAutostart]
|
||||
predecessors = [locale.GenerateLocale, AptSources, DisableDaemonAutostart]
|
||||
successors = [network.RemoveDNSInfo]
|
||||
|
||||
def run(self, info):
|
||||
log_check_call(['/usr/sbin/chroot', info.root, '/usr/bin/apt-get', 'update'])
|
||||
|
|
|
@ -43,7 +43,7 @@ class MakeTarball(Task):
|
|||
class Bootstrap(Task):
|
||||
description = 'Installing Debian'
|
||||
phase = phases.os_installation
|
||||
after = [MakeTarball]
|
||||
predecessors = [MakeTarball]
|
||||
|
||||
def run(self, info):
|
||||
executable, options, arguments = get_bootstrap_args(info)
|
||||
|
|
|
@ -17,7 +17,7 @@ class Format(Task):
|
|||
class TuneVolumeFS(Task):
|
||||
description = 'Tuning the bootstrap volume filesystem'
|
||||
phase = phases.volume_preparation
|
||||
after = [Format]
|
||||
predecessors = [Format]
|
||||
|
||||
def run(self, info):
|
||||
import re
|
||||
|
@ -49,7 +49,7 @@ class CreateMountDir(Task):
|
|||
class MountRoot(Task):
|
||||
description = 'Mounting the root partition'
|
||||
phase = phases.volume_mounting
|
||||
after = [CreateMountDir]
|
||||
predecessors = [CreateMountDir]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.partition_map.root.mount(info.root)
|
||||
|
@ -58,7 +58,7 @@ class MountRoot(Task):
|
|||
class MountBoot(Task):
|
||||
description = 'Mounting the boot partition'
|
||||
phase = phases.volume_mounting
|
||||
after = [MountRoot]
|
||||
predecessors = [MountRoot]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.partition_map.boot.mount(info.boot_dir)
|
||||
|
@ -67,8 +67,8 @@ class MountBoot(Task):
|
|||
class CreateBootMountDir(Task):
|
||||
description = 'Creating mountpoint for the boot partition'
|
||||
phase = phases.volume_mounting
|
||||
after = [MountRoot]
|
||||
before = [MountBoot]
|
||||
successors = [MountBoot]
|
||||
predecessors = [MountRoot]
|
||||
|
||||
def run(self, info):
|
||||
import os
|
||||
|
@ -79,7 +79,7 @@ class CreateBootMountDir(Task):
|
|||
class MountSpecials(Task):
|
||||
description = 'Mounting special block devices'
|
||||
phase = phases.os_installation
|
||||
after = [Bootstrap]
|
||||
predecessors = [Bootstrap]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.mount_specials()
|
||||
|
@ -88,7 +88,7 @@ class MountSpecials(Task):
|
|||
class UnmountRoot(Task):
|
||||
description = 'Unmounting the bootstrap volume'
|
||||
phase = phases.volume_unmounting
|
||||
before = [volume.Detach]
|
||||
successors = [volume.Detach]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.partition_map.root.unmount()
|
||||
|
@ -97,7 +97,7 @@ class UnmountRoot(Task):
|
|||
class UnmountBoot(Task):
|
||||
description = 'Unmounting the boot partition'
|
||||
phase = phases.volume_unmounting
|
||||
before = [UnmountRoot]
|
||||
successors = [UnmountRoot]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.partition_map.boot.unmount()
|
||||
|
@ -106,7 +106,7 @@ class UnmountBoot(Task):
|
|||
class UnmountSpecials(Task):
|
||||
description = 'Unmunting special block devices'
|
||||
phase = phases.volume_unmounting
|
||||
before = [UnmountRoot]
|
||||
successors = [UnmountRoot]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.unmount_specials()
|
||||
|
@ -115,7 +115,7 @@ class UnmountSpecials(Task):
|
|||
class DeleteMountDir(Task):
|
||||
description = 'Deleting mountpoint for the bootstrap volume'
|
||||
phase = phases.volume_unmounting
|
||||
after = [UnmountRoot]
|
||||
predecessors = [UnmountRoot]
|
||||
|
||||
def run(self, info):
|
||||
import os
|
||||
|
|
|
@ -7,7 +7,7 @@ import packages
|
|||
class CheckPackages(Task):
|
||||
description = 'Checking installed host packages'
|
||||
phase = phases.preparation
|
||||
after = [packages.HostPackages, packages.ImagePackages]
|
||||
predecessors = [packages.HostPackages, packages.ImagePackages]
|
||||
|
||||
def run(self, info):
|
||||
from common.tools import log_check_call
|
||||
|
|
|
@ -37,7 +37,7 @@ class ResolveInitScripts(Task):
|
|||
class InstallInitScripts(Task):
|
||||
description = 'Installing startup scripts'
|
||||
phase = phases.system_modification
|
||||
after = [ResolveInitScripts]
|
||||
predecessors = [ResolveInitScripts]
|
||||
|
||||
def run(self, info):
|
||||
import stat
|
||||
|
|
|
@ -6,7 +6,7 @@ import volume
|
|||
class Create(Task):
|
||||
description = 'Creating a loopback volume'
|
||||
phase = phases.volume_creation
|
||||
before = [volume.Attach]
|
||||
successors = [volume.Attach]
|
||||
|
||||
def run(self, info):
|
||||
import os.path
|
||||
|
|
|
@ -15,8 +15,8 @@ class PartitionVolume(Task):
|
|||
class MapPartitions(Task):
|
||||
description = 'Mapping volume partitions'
|
||||
phase = phases.volume_preparation
|
||||
before = [filesystem.Format]
|
||||
after = [PartitionVolume]
|
||||
predecessors = [PartitionVolume]
|
||||
successors = [filesystem.Format]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.partition_map.map(info.volume)
|
||||
|
@ -25,8 +25,8 @@ class MapPartitions(Task):
|
|||
class UnmapPartitions(Task):
|
||||
description = 'Removing volume partitions mapping'
|
||||
phase = phases.volume_unmounting
|
||||
before = [volume.Detach]
|
||||
after = [filesystem.UnmountRoot]
|
||||
predecessors = [filesystem.UnmountRoot]
|
||||
successors = [volume.Detach]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.partition_map.unmap(info.volume)
|
||||
|
|
|
@ -22,7 +22,7 @@ class Detach(Task):
|
|||
class Delete(Task):
|
||||
description = 'Deleting the volume'
|
||||
phase = phases.cleaning
|
||||
before = [workspace.DeleteWorkspace]
|
||||
successors = [workspace.DeleteWorkspace]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.delete()
|
||||
|
|
|
@ -9,8 +9,8 @@ import os
|
|||
class AddSudoPackage(Task):
|
||||
description = 'Adding ``sudo\'\' to the image packages'
|
||||
phase = phases.preparation
|
||||
after = [ImagePackages]
|
||||
before = [CheckPackages]
|
||||
predecessors = [ImagePackages]
|
||||
successors = [CheckPackages]
|
||||
|
||||
def run(self, info):
|
||||
info.img_packages[0].add('sudo')
|
||||
|
@ -45,7 +45,7 @@ class PasswordlessSudo(Task):
|
|||
class AdminUserCredentials(Task):
|
||||
description = 'Modifying ec2-get-credentials to copy the ssh public key to the admin user'
|
||||
phase = phases.system_modification
|
||||
after = [InstallInitScripts]
|
||||
predecessors = [InstallInitScripts]
|
||||
|
||||
def run(self, info):
|
||||
from common.tools import sed_i
|
||||
|
|
|
@ -10,8 +10,8 @@ import os
|
|||
class AptSourcesBackports(Task):
|
||||
description = 'Adding backports to sources.list'
|
||||
phase = phases.system_modification
|
||||
after = [AptSources]
|
||||
before = [AptUpgrade]
|
||||
predecessors = [AptSources]
|
||||
successors = [AptUpgrade]
|
||||
|
||||
def run(self, info):
|
||||
sources_path = os.path.join(info.root, 'etc/apt/sources.list')
|
||||
|
@ -25,7 +25,7 @@ class AptSourcesBackports(Task):
|
|||
class AddBackportsPackages(Task):
|
||||
description = 'Adding backport packages to the image'
|
||||
phase = phases.system_modification
|
||||
after = [AptUpgrade]
|
||||
predecessors = [AptUpgrade]
|
||||
|
||||
def run(self, info):
|
||||
if 'packages' not in info.manifest.plugins['backports']:
|
||||
|
|
|
@ -6,7 +6,7 @@ from common.tasks import loopback
|
|||
class ConvertImage(Task):
|
||||
description = 'Converting raw image'
|
||||
phase = phases.image_registration
|
||||
before = [loopback.MoveImage]
|
||||
successors = [loopback.MoveImage]
|
||||
|
||||
def run(self, info):
|
||||
from common.tools import log_check_call
|
||||
|
|
|
@ -7,7 +7,7 @@ import os
|
|||
class OpenNebulaContext(Task):
|
||||
description = 'Setup OpenNebula init context'
|
||||
phase = phases.system_modification
|
||||
after = [GenerateLocale]
|
||||
predecessors = [GenerateLocale]
|
||||
|
||||
def run(self, info):
|
||||
import stat
|
||||
|
|
|
@ -14,7 +14,7 @@ log = logging.getLogger(__name__)
|
|||
class Snapshot(Task):
|
||||
description = 'Creating a snapshot of the bootstrapped volume'
|
||||
phase = phases.os_installation
|
||||
after = [bootstrap.Bootstrap, filesystem.MountSpecials]
|
||||
predecessors = [bootstrap.Bootstrap, filesystem.MountSpecials]
|
||||
|
||||
def run(self, info):
|
||||
def mk_snapshot():
|
||||
|
@ -27,7 +27,7 @@ class Snapshot(Task):
|
|||
class CreateFromSnapshot(Task):
|
||||
description = 'Creating EBS volume from a snapshot'
|
||||
phase = phases.volume_creation
|
||||
before = [volume.Attach]
|
||||
successors = [volume.Attach]
|
||||
|
||||
def run(self, info):
|
||||
volume_size = int(info.manifest.volume['size'] / 1024)
|
||||
|
@ -45,7 +45,7 @@ class CreateFromSnapshot(Task):
|
|||
class CopyImage(Task):
|
||||
description = 'Creating a snapshot of the bootstrapped volume'
|
||||
phase = phases.os_installation
|
||||
after = [bootstrap.Bootstrap, filesystem.MountSpecials]
|
||||
predecessors = [bootstrap.Bootstrap, filesystem.MountSpecials]
|
||||
|
||||
def run(self, info):
|
||||
loopback_backup_name = 'volume-{id:x}.{ext}.backup'.format(id=info.run_id, ext=info.volume.extension)
|
||||
|
@ -61,7 +61,7 @@ class CopyImage(Task):
|
|||
class CreateFromImage(Task):
|
||||
description = 'Creating loopback image from a copy'
|
||||
phase = phases.volume_creation
|
||||
before = [volume.Attach]
|
||||
successors = [volume.Attach]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.image_path = os.path.join(info.workspace, 'volume.{ext}'.format(ext=info.volume.extension))
|
||||
|
@ -74,8 +74,8 @@ class CreateFromImage(Task):
|
|||
class SetBootMountDir(Task):
|
||||
description = 'Setting mountpoint for the boot partition'
|
||||
phase = phases.volume_mounting
|
||||
after = [filesystem.MountRoot]
|
||||
before = [filesystem.MountBoot]
|
||||
predecessors = [filesystem.MountRoot]
|
||||
successors = [filesystem.MountBoot]
|
||||
|
||||
def run(self, info):
|
||||
info.boot_dir = os.path.join(info.root, 'boot')
|
||||
|
|
|
@ -8,7 +8,7 @@ import os
|
|||
class DoSeds(Task):
|
||||
description = 'Sedding files'
|
||||
phase = phases.system_modification
|
||||
after = [AptUpgrade]
|
||||
predecessors = [AptUpgrade]
|
||||
|
||||
def run(self, info):
|
||||
chroot_path = os.path.join(info.root, info.manifest.plugins['sed']['file'])
|
||||
|
|
|
@ -7,8 +7,8 @@ from common.tasks.host import CheckPackages
|
|||
class AddUnattendedUpgradesPackage(Task):
|
||||
description = 'Adding ``unattended-upgrades\'\' to the image packages'
|
||||
phase = phases.preparation
|
||||
after = [ImagePackages]
|
||||
before = [CheckPackages]
|
||||
predecessors = [ImagePackages]
|
||||
successors = [CheckPackages]
|
||||
|
||||
def run(self, info):
|
||||
info.img_packages[0].add('unattended-upgrades')
|
||||
|
|
|
@ -9,8 +9,8 @@ from common.tasks.filesystem import MountRoot
|
|||
class AddUserPackages(Task):
|
||||
description = 'Adding user defined packages to the image packages'
|
||||
phase = phases.preparation
|
||||
after = [ImagePackages]
|
||||
before = [CheckPackages]
|
||||
predecessors = [ImagePackages]
|
||||
successors = [CheckPackages]
|
||||
|
||||
def run(self, info):
|
||||
if 'repo' not in info.manifest.plugins['user_packages']:
|
||||
|
@ -22,7 +22,7 @@ class AddUserPackages(Task):
|
|||
class AddLocalUserPackages(Task):
|
||||
description = 'Adding user local packages to the image packages'
|
||||
phase = phases.system_modification
|
||||
after = [MountRoot]
|
||||
predecessors = [MountRoot]
|
||||
|
||||
def run(self, info):
|
||||
if 'local' not in info.manifest.plugins['user_packages']:
|
||||
|
|
|
@ -13,7 +13,7 @@ cert_ec2 = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/c
|
|||
class AMIName(Task):
|
||||
description = 'Determining the AMI name'
|
||||
phase = phases.preparation
|
||||
after = [Connect]
|
||||
predecessors = [Connect]
|
||||
|
||||
def run(self, info):
|
||||
image_vars = {'release': info.manifest.system['release'],
|
||||
|
@ -60,7 +60,7 @@ class BundleImage(Task):
|
|||
class UploadImage(Task):
|
||||
description = 'Uploading the image bundle'
|
||||
phase = phases.image_registration
|
||||
after = [BundleImage]
|
||||
predecessors = [BundleImage]
|
||||
|
||||
def run(self, info):
|
||||
manifest_file = os.path.join(info.bundle_path, info.ami_name + '.manifest.xml')
|
||||
|
@ -81,7 +81,7 @@ class UploadImage(Task):
|
|||
class RemoveBundle(Task):
|
||||
description = 'Removing the bundle files'
|
||||
phase = phases.cleaning
|
||||
before = [workspace.DeleteWorkspace]
|
||||
successors = [workspace.DeleteWorkspace]
|
||||
|
||||
def run(self, info):
|
||||
from shutil import rmtree
|
||||
|
@ -92,7 +92,7 @@ class RemoveBundle(Task):
|
|||
class RegisterAMI(Task):
|
||||
description = 'Registering the image as an AMI'
|
||||
phase = phases.image_registration
|
||||
after = [Snapshot, UploadImage]
|
||||
predecessors = [Snapshot, UploadImage]
|
||||
|
||||
# Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UserProvidedKernels.html#AmazonKernelImageIDs
|
||||
kernel_mapping = {'ap-northeast-1': { # Asia Pacific (Tokyo) Region
|
||||
|
|
|
@ -34,7 +34,7 @@ class GetCredentials(Task):
|
|||
class Connect(Task):
|
||||
description = 'Connecting to EC2'
|
||||
phase = phases.preparation
|
||||
after = [GetCredentials, host.GetInfo]
|
||||
predecessors = [GetCredentials, host.GetInfo]
|
||||
|
||||
def run(self, info):
|
||||
from boto.ec2 import connect_to_region
|
||||
|
|
|
@ -13,7 +13,7 @@ class Create(Task):
|
|||
class Attach(Task):
|
||||
description = 'Attaching the volume'
|
||||
phase = phases.volume_creation
|
||||
after = [Create]
|
||||
predecessors = [Create]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.attach(info.host['instanceId'])
|
||||
|
|
|
@ -8,8 +8,8 @@ import os.path
|
|||
class AddEC2InitScripts(Task):
|
||||
description = 'Adding EC2 startup scripts'
|
||||
phase = phases.system_modification
|
||||
after = [initd.ResolveInitScripts]
|
||||
before = [initd.InstallInitScripts]
|
||||
predecessors = [initd.ResolveInitScripts]
|
||||
successors = [initd.InstallInitScripts]
|
||||
|
||||
def run(self, info):
|
||||
init_scripts = {'ec2-get-credentials': 'ec2-get-credentials',
|
||||
|
@ -23,7 +23,7 @@ class AddEC2InitScripts(Task):
|
|||
class AdjustExpandVolumeScript(Task):
|
||||
description = 'Adjusting the expand-volume script'
|
||||
phase = phases.system_modification
|
||||
after = [initd.InstallInitScripts]
|
||||
predecessors = [initd.InstallInitScripts]
|
||||
|
||||
def run(self, info):
|
||||
if 'expand-volume' not in info.initd['install']:
|
||||
|
|
|
@ -7,8 +7,8 @@ from common.tasks.host import CheckPackages
|
|||
class HostPackages(Task):
|
||||
description = 'Adding more required host packages'
|
||||
phase = phases.preparation
|
||||
before = [CheckPackages]
|
||||
after = [packages.HostPackages]
|
||||
predecessors = [packages.HostPackages]
|
||||
successors = [CheckPackages]
|
||||
|
||||
def run(self, info):
|
||||
if info.manifest.volume['backing'] == 's3':
|
||||
|
@ -18,7 +18,7 @@ class HostPackages(Task):
|
|||
class ImagePackages(Task):
|
||||
description = 'Adding more required image packages'
|
||||
phase = phases.preparation
|
||||
after = [packages.ImagePackages]
|
||||
predecessors = [packages.ImagePackages]
|
||||
|
||||
def run(self, info):
|
||||
manifest = info.manifest
|
||||
|
|
|
@ -7,7 +7,7 @@ from common.fs.loopbackvolume import LoopbackVolume
|
|||
class ConfigureGrub(Task):
|
||||
description = 'Configuring grub'
|
||||
phase = phases.system_modification
|
||||
after = [apt.AptUpgrade]
|
||||
predecessors = [apt.AptUpgrade]
|
||||
|
||||
def run(self, info):
|
||||
import os
|
||||
|
|
|
@ -6,7 +6,7 @@ from common.tasks import packages
|
|||
class ImagePackages(Task):
|
||||
description = 'Determining required image packages'
|
||||
phase = phases.preparation
|
||||
after = [packages.ImagePackages]
|
||||
predecessors = [packages.ImagePackages]
|
||||
|
||||
def run(self, info):
|
||||
manifest = info.manifest
|
||||
|
|
Loading…
Add table
Reference in a new issue