From 663b868b41ffb7b9f45f260eaa845accdaa55ea5 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Thu, 21 Nov 2013 15:54:42 +0100 Subject: [PATCH] Fix #107. Rename before and after task properties `before' becomes `successors' and `after' becomes `predecessors' --- base/task.py | 4 ++-- base/tasklist.py | 8 ++++---- common/tasks/apt.py | 4 ++-- common/tasks/bootstrap.py | 2 +- common/tasks/filesystem.py | 20 ++++++++++---------- common/tasks/host.py | 2 +- common/tasks/initd.py | 2 +- common/tasks/loopback.py | 2 +- common/tasks/partitioning.py | 8 ++++---- common/tasks/volume.py | 2 +- plugins/admin_user/tasks.py | 6 +++--- plugins/backports/tasks.py | 6 +++--- plugins/convert_image/tasks.py | 2 +- plugins/opennebula/tasks.py | 2 +- plugins/prebootstrapped/tasks.py | 12 ++++++------ plugins/sed/tasks.py | 2 +- plugins/unattended_upgrades/tasks.py | 4 ++-- plugins/user_packages/user_packages.py | 6 +++--- providers/ec2/tasks/ami.py | 8 ++++---- providers/ec2/tasks/connection.py | 2 +- providers/ec2/tasks/ebs.py | 2 +- providers/ec2/tasks/initd.py | 6 +++--- providers/ec2/tasks/packages.py | 6 +++--- providers/virtualbox/tasks/boot.py | 2 +- providers/virtualbox/tasks/packages.py | 2 +- 25 files changed, 61 insertions(+), 61 deletions(-) diff --git a/base/task.py b/base/task.py index 8a10462..44abba4 100644 --- a/base/task.py +++ b/base/task.py @@ -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__) diff --git a/base/tasklist.py b/base/tasklist.py index fe07755..fbc2f98 100644 --- a/base/tasklist.py +++ b/base/tasklist.py @@ -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}'" diff --git a/common/tasks/apt.py b/common/tasks/apt.py index bb9086f..6e6b1ce 100644 --- a/common/tasks/apt.py +++ b/common/tasks/apt.py @@ -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']) diff --git a/common/tasks/bootstrap.py b/common/tasks/bootstrap.py index 42e1da9..14315c6 100644 --- a/common/tasks/bootstrap.py +++ b/common/tasks/bootstrap.py @@ -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) diff --git a/common/tasks/filesystem.py b/common/tasks/filesystem.py index 80288a7..063fb82 100644 --- a/common/tasks/filesystem.py +++ b/common/tasks/filesystem.py @@ -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 diff --git a/common/tasks/host.py b/common/tasks/host.py index f62f6e0..c5b6e34 100644 --- a/common/tasks/host.py +++ b/common/tasks/host.py @@ -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 diff --git a/common/tasks/initd.py b/common/tasks/initd.py index a0df088..1046d68 100644 --- a/common/tasks/initd.py +++ b/common/tasks/initd.py @@ -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 diff --git a/common/tasks/loopback.py b/common/tasks/loopback.py index 8a0b2c9..5f19f49 100644 --- a/common/tasks/loopback.py +++ b/common/tasks/loopback.py @@ -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 diff --git a/common/tasks/partitioning.py b/common/tasks/partitioning.py index a0ec17b..990d331 100644 --- a/common/tasks/partitioning.py +++ b/common/tasks/partitioning.py @@ -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) diff --git a/common/tasks/volume.py b/common/tasks/volume.py index 64be8eb..54baddb 100644 --- a/common/tasks/volume.py +++ b/common/tasks/volume.py @@ -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() diff --git a/plugins/admin_user/tasks.py b/plugins/admin_user/tasks.py index 387894f..cfe001c 100644 --- a/plugins/admin_user/tasks.py +++ b/plugins/admin_user/tasks.py @@ -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 diff --git a/plugins/backports/tasks.py b/plugins/backports/tasks.py index add0e0d..887a4ce 100644 --- a/plugins/backports/tasks.py +++ b/plugins/backports/tasks.py @@ -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']: diff --git a/plugins/convert_image/tasks.py b/plugins/convert_image/tasks.py index c573d08..cd2d748 100644 --- a/plugins/convert_image/tasks.py +++ b/plugins/convert_image/tasks.py @@ -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 diff --git a/plugins/opennebula/tasks.py b/plugins/opennebula/tasks.py index ca5778b..68c800d 100644 --- a/plugins/opennebula/tasks.py +++ b/plugins/opennebula/tasks.py @@ -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 diff --git a/plugins/prebootstrapped/tasks.py b/plugins/prebootstrapped/tasks.py index d5fcb57..7286293 100644 --- a/plugins/prebootstrapped/tasks.py +++ b/plugins/prebootstrapped/tasks.py @@ -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') diff --git a/plugins/sed/tasks.py b/plugins/sed/tasks.py index 4cdd171..e71618e 100644 --- a/plugins/sed/tasks.py +++ b/plugins/sed/tasks.py @@ -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']) diff --git a/plugins/unattended_upgrades/tasks.py b/plugins/unattended_upgrades/tasks.py index b83f421..6dedf55 100644 --- a/plugins/unattended_upgrades/tasks.py +++ b/plugins/unattended_upgrades/tasks.py @@ -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') diff --git a/plugins/user_packages/user_packages.py b/plugins/user_packages/user_packages.py index a53e51e..7739358 100644 --- a/plugins/user_packages/user_packages.py +++ b/plugins/user_packages/user_packages.py @@ -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']: diff --git a/providers/ec2/tasks/ami.py b/providers/ec2/tasks/ami.py index 5b30204..0cbe023 100644 --- a/providers/ec2/tasks/ami.py +++ b/providers/ec2/tasks/ami.py @@ -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 diff --git a/providers/ec2/tasks/connection.py b/providers/ec2/tasks/connection.py index 65d9871..56e1b81 100644 --- a/providers/ec2/tasks/connection.py +++ b/providers/ec2/tasks/connection.py @@ -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 diff --git a/providers/ec2/tasks/ebs.py b/providers/ec2/tasks/ebs.py index e8c363e..b541a54 100644 --- a/providers/ec2/tasks/ebs.py +++ b/providers/ec2/tasks/ebs.py @@ -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']) diff --git a/providers/ec2/tasks/initd.py b/providers/ec2/tasks/initd.py index 7be1667..1a68645 100644 --- a/providers/ec2/tasks/initd.py +++ b/providers/ec2/tasks/initd.py @@ -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']: diff --git a/providers/ec2/tasks/packages.py b/providers/ec2/tasks/packages.py index 814a6f6..85c0afe 100644 --- a/providers/ec2/tasks/packages.py +++ b/providers/ec2/tasks/packages.py @@ -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 diff --git a/providers/virtualbox/tasks/boot.py b/providers/virtualbox/tasks/boot.py index bddb860..dfe9247 100644 --- a/providers/virtualbox/tasks/boot.py +++ b/providers/virtualbox/tasks/boot.py @@ -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 diff --git a/providers/virtualbox/tasks/packages.py b/providers/virtualbox/tasks/packages.py index 58b1d7f..8d16285 100644 --- a/providers/virtualbox/tasks/packages.py +++ b/providers/virtualbox/tasks/packages.py @@ -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