2013-05-16 08:00:28 +02:00
|
|
|
from manifest import Manifest
|
2013-07-01 20:56:38 +02:00
|
|
|
import logging
|
2013-06-26 23:40:42 +02:00
|
|
|
from tasks import packages
|
|
|
|
from tasks import connection
|
|
|
|
from tasks import host
|
2013-07-07 20:28:24 +02:00
|
|
|
from tasks import ami
|
2013-10-09 00:09:34 +02:00
|
|
|
from common.tasks import volume as volume_tasks
|
2013-06-26 23:40:42 +02:00
|
|
|
from tasks import ebs
|
2013-10-09 00:09:34 +02:00
|
|
|
from common.tasks import partitioning
|
2013-08-10 16:38:45 +02:00
|
|
|
from common.tasks import loopback
|
|
|
|
from common.tasks import filesystem
|
2013-08-10 16:22:16 +02:00
|
|
|
from common.tasks import bootstrap
|
2013-07-01 23:15:49 +02:00
|
|
|
from tasks import boot
|
2013-08-10 16:18:48 +02:00
|
|
|
from common.tasks import boot as common_boot
|
2013-08-10 17:12:58 +02:00
|
|
|
from common.tasks import security
|
2013-09-22 15:41:43 +02:00
|
|
|
from tasks import network
|
|
|
|
from common.tasks import network as common_network
|
2013-07-07 14:58:03 +02:00
|
|
|
from tasks import initd
|
2013-08-10 16:51:42 +02:00
|
|
|
from common.tasks import initd as common_initd
|
2013-08-10 16:24:12 +02:00
|
|
|
from common.tasks import cleanup
|
2013-10-09 00:09:34 +02:00
|
|
|
from common.tasks import workspace
|
2013-05-16 08:00:28 +02:00
|
|
|
|
|
|
|
|
2013-07-01 20:56:38 +02:00
|
|
|
def initialize():
|
|
|
|
# Regardless of of loglevel, we don't want boto debug stuff, it's very noisy
|
|
|
|
logging.getLogger('boto').setLevel(logging.INFO)
|
|
|
|
|
|
|
|
|
2013-06-23 15:26:08 +02:00
|
|
|
def tasks(tasklist, manifest):
|
2013-10-09 00:09:34 +02:00
|
|
|
from common.task_sets import base_set
|
|
|
|
from common.task_sets import mounting_set
|
|
|
|
from common.task_sets import apt_set
|
|
|
|
from common.task_sets import locale_set
|
|
|
|
from common.task_sets import ssh_set
|
|
|
|
tasklist.add(*base_set)
|
|
|
|
tasklist.add(*mounting_set)
|
|
|
|
tasklist.add(*apt_set)
|
|
|
|
tasklist.add(*locale_set)
|
|
|
|
tasklist.add(*ssh_set)
|
2013-07-13 15:10:04 +02:00
|
|
|
|
2013-10-09 00:09:34 +02:00
|
|
|
if manifest.volume['partitions']['type'] != 'none':
|
|
|
|
from common.task_sets import partitioning_set
|
|
|
|
tasklist.add(*partitioning_set)
|
|
|
|
|
|
|
|
tasklist.add(packages.HostPackages,
|
|
|
|
packages.ImagePackages,
|
|
|
|
connection.GetCredentials,
|
|
|
|
host.GetInfo,
|
|
|
|
ami.AMIName,
|
|
|
|
connection.Connect,
|
|
|
|
|
|
|
|
boot.ConfigureGrub,
|
|
|
|
common_boot.BlackListModules,
|
|
|
|
common_boot.DisableGetTTYs,
|
|
|
|
security.EnableShadowConfig,
|
|
|
|
common_network.RemoveDNSInfo,
|
|
|
|
common_network.ConfigureNetworkIF,
|
|
|
|
network.EnableDHCPCDDNS,
|
|
|
|
common_initd.ResolveInitScripts,
|
|
|
|
initd.AddEC2InitScripts,
|
|
|
|
common_initd.InstallInitScripts,
|
|
|
|
cleanup.ClearMOTD,
|
|
|
|
cleanup.CleanTMP,
|
|
|
|
|
|
|
|
ami.RegisterAMI)
|
|
|
|
|
|
|
|
backing_specific_tasks = {'ebs': [ebs.Create,
|
|
|
|
ebs.Attach,
|
|
|
|
ebs.Snapshot],
|
|
|
|
's3': [loopback.Create,
|
|
|
|
volume_tasks.Attach,
|
|
|
|
ami.BundleImage,
|
|
|
|
ami.UploadImage,
|
|
|
|
ami.RemoveBundle]}
|
2013-07-13 15:10:04 +02:00
|
|
|
tasklist.add(*backing_specific_tasks.get(manifest.volume['backing'].lower()))
|
2013-10-09 00:09:34 +02:00
|
|
|
tasklist.add(filesystem.Format,
|
|
|
|
filesystem.FStab,
|
|
|
|
volume_tasks.Detach,
|
|
|
|
volume_tasks.Delete)
|
|
|
|
|
|
|
|
if manifest.bootstrapper.get('tarball', False):
|
|
|
|
tasklist.add(bootstrap.MakeTarball)
|
|
|
|
|
|
|
|
from common.task_sets import get_fs_specific_set
|
|
|
|
tasklist.add(*get_fs_specific_set(manifest.volume['partitions']))
|
2013-07-13 15:10:04 +02:00
|
|
|
|
2013-10-09 00:09:34 +02:00
|
|
|
if 'boot' in manifest.volume['partitions']:
|
|
|
|
from common.task_sets import boot_partition_set
|
|
|
|
tasklist.add(*boot_partition_set)
|
2013-06-26 23:40:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
def rollback_tasks(tasklist, tasks_completed, manifest):
|
|
|
|
completed = [type(task) for task in tasks_completed]
|
2013-06-27 22:21:43 +02:00
|
|
|
|
|
|
|
def counter_task(task, counter):
|
|
|
|
if task in completed and counter not in completed:
|
2013-10-09 00:09:34 +02:00
|
|
|
tasklist.add(counter)
|
|
|
|
|
|
|
|
counter_task(ebs.Create, volume_tasks.Delete)
|
|
|
|
counter_task(ebs.Attach, volume_tasks.Detach)
|
|
|
|
|
|
|
|
counter_task(loopback.Create, volume_tasks.Delete)
|
|
|
|
counter_task(volume_tasks.Attach, volume_tasks.Detach)
|
|
|
|
|
|
|
|
counter_task(partitioning.MapPartitions, partitioning.UnmapPartitions)
|
2013-06-27 22:21:43 +02:00
|
|
|
counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir)
|
2013-07-01 20:48:51 +02:00
|
|
|
counter_task(filesystem.MountSpecials, filesystem.UnmountSpecials)
|
2013-10-09 00:09:34 +02:00
|
|
|
|
|
|
|
counter_task(filesystem.MountRoot, filesystem.UnmountRoot)
|
|
|
|
counter_task(filesystem.MountBoot, filesystem.UnmountBoot)
|
|
|
|
counter_task(volume_tasks.Attach, volume_tasks.Detach)
|
|
|
|
counter_task(workspace.CreateWorkspace, workspace.DeleteWorkspace)
|