2013-05-16 08:00:28 +02:00
|
|
|
from manifest import Manifest
|
2013-12-29 23:52:08 +01:00
|
|
|
import tasks.packages
|
|
|
|
import tasks.connection
|
|
|
|
import tasks.host
|
|
|
|
import tasks.ami
|
|
|
|
import tasks.ebs
|
|
|
|
import tasks.filesystem
|
|
|
|
import tasks.boot
|
|
|
|
import tasks.network
|
|
|
|
import tasks.initd
|
|
|
|
from common.tasks import volume
|
|
|
|
from common.tasks import filesystem
|
|
|
|
from common.tasks import boot
|
|
|
|
from common.tasks import network
|
|
|
|
from common.tasks import initd
|
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
|
2013-08-10 16:22:16 +02:00
|
|
|
from common.tasks import bootstrap
|
2013-08-10 17:12:58 +02:00
|
|
|
from common.tasks import security
|
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
|
2013-12-29 23:52:08 +01:00
|
|
|
import logging
|
2013-07-01 20:56:38 +02:00
|
|
|
logging.getLogger('boto').setLevel(logging.INFO)
|
|
|
|
|
|
|
|
|
2013-12-02 00:00:59 +01:00
|
|
|
def resolve_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)
|
|
|
|
|
2013-12-29 23:52:08 +01:00
|
|
|
tasklist.add(tasks.host.HostDependencies,
|
|
|
|
tasks.packages.DefaultPackages,
|
|
|
|
tasks.connection.GetCredentials,
|
|
|
|
tasks.host.GetInfo,
|
|
|
|
tasks.ami.AMIName,
|
|
|
|
tasks.connection.Connect,
|
2013-10-09 00:09:34 +02:00
|
|
|
|
2013-12-29 23:52:08 +01:00
|
|
|
boot.BlackListModules,
|
|
|
|
boot.DisableGetTTYs,
|
2013-10-09 00:09:34 +02:00
|
|
|
security.EnableShadowConfig,
|
2013-12-29 23:52:08 +01:00
|
|
|
network.RemoveDNSInfo,
|
|
|
|
network.ConfigureNetworkIF,
|
|
|
|
tasks.network.EnableDHCPCDDNS,
|
|
|
|
initd.AddExpandRoot,
|
|
|
|
initd.AddSSHKeyGeneration,
|
|
|
|
initd.RemoveHWClock,
|
|
|
|
tasks.initd.AddEC2InitScripts,
|
|
|
|
initd.InstallInitScripts,
|
|
|
|
initd.AdjustExpandRootScript,
|
2013-10-09 00:09:34 +02:00
|
|
|
cleanup.ClearMOTD,
|
|
|
|
cleanup.CleanTMP,
|
|
|
|
|
2013-12-29 23:52:08 +01:00
|
|
|
tasks.ami.RegisterAMI)
|
2013-10-09 00:09:34 +02:00
|
|
|
|
2013-12-30 12:14:43 +01:00
|
|
|
if manifest.system['bootloader'] == 'pvgrub':
|
|
|
|
tasklist.add(boot.AddGrubPackage, tasks.boot.ConfigurePVGrub)
|
2013-12-01 23:50:32 +01:00
|
|
|
else:
|
2013-12-30 12:14:43 +01:00
|
|
|
from common.task_sets import bootloader_set
|
|
|
|
tasklist.add(*bootloader_set.get(manifest.system['bootloader']))
|
2013-12-01 23:50:32 +01:00
|
|
|
|
2013-12-29 23:52:08 +01:00
|
|
|
backing_specific_tasks = {'ebs': [tasks.ebs.Create,
|
|
|
|
tasks.ebs.Attach,
|
|
|
|
filesystem.FStab,
|
|
|
|
tasks.ebs.Snapshot],
|
2013-10-09 00:09:34 +02:00
|
|
|
's3': [loopback.Create,
|
2013-12-29 23:52:08 +01:00
|
|
|
volume.Attach,
|
|
|
|
tasks.filesystem.S3FStab,
|
|
|
|
tasks.ami.BundleImage,
|
|
|
|
tasks.ami.UploadImage,
|
|
|
|
tasks.ami.RemoveBundle]}
|
2013-07-13 15:10:04 +02:00
|
|
|
tasklist.add(*backing_specific_tasks.get(manifest.volume['backing'].lower()))
|
2013-12-29 23:52:08 +01:00
|
|
|
tasklist.add(filesystem.Format,
|
|
|
|
volume.Detach,
|
|
|
|
volume.Delete)
|
2013-10-09 00:09:34 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2013-12-02 00:00:59 +01:00
|
|
|
def resolve_rollback_tasks(tasklist, tasks_completed, manifest):
|
2013-06-26 23:40:42 +02:00
|
|
|
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)
|
|
|
|
|
2013-12-29 23:52:08 +01:00
|
|
|
counter_task(tasks.ebs.Create, volume.Delete)
|
|
|
|
counter_task(tasks.ebs.Attach, volume.Detach)
|
2013-10-09 00:09:34 +02:00
|
|
|
|
2013-12-29 23:52:08 +01:00
|
|
|
counter_task(loopback.Create, volume.Delete)
|
|
|
|
counter_task(volume.Attach, volume.Detach)
|
2013-10-09 00:09:34 +02:00
|
|
|
|
|
|
|
counter_task(partitioning.MapPartitions, partitioning.UnmapPartitions)
|
2013-12-29 23:52:08 +01:00
|
|
|
counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir)
|
2013-10-09 00:09:34 +02:00
|
|
|
|
2013-12-29 23:52:08 +01:00
|
|
|
counter_task(filesystem.MountRoot, filesystem.UnmountRoot)
|
|
|
|
counter_task(volume.Attach, volume.Detach)
|
2013-10-09 00:09:34 +02:00
|
|
|
counter_task(workspace.CreateWorkspace, workspace.DeleteWorkspace)
|
2013-12-29 23:52:08 +01:00
|
|
|
counter_task(tasks.ami.BundleImage, tasks.ami.RemoveBundle)
|