2013-07-13 13:55:12 +02:00
|
|
|
from tasks import Snapshot
|
2013-07-14 23:16:37 +02:00
|
|
|
from tasks import CopyImage
|
2013-07-13 13:55:12 +02:00
|
|
|
from tasks import CreateFromSnapshot
|
2013-07-14 23:16:37 +02:00
|
|
|
from tasks import CreateFromImage
|
2013-07-01 00:17:48 +02:00
|
|
|
from providers.ec2.tasks import ebs
|
2013-08-11 19:42:48 +02:00
|
|
|
from common.tasks import loopback
|
2013-09-15 13:19:45 +02:00
|
|
|
from common.tasks import volume
|
2013-08-11 19:42:48 +02:00
|
|
|
from common.tasks import bootstrap
|
|
|
|
from common.tasks import filesystem
|
2013-09-15 13:19:45 +02:00
|
|
|
from common.tasks import partitioning
|
2013-06-30 23:26:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
def tasks(tasklist, manifest):
|
2013-07-14 23:16:37 +02:00
|
|
|
settings = manifest.plugins['prebootstrapped']
|
2013-09-15 13:19:45 +02:00
|
|
|
skip_tasks = [filesystem.Format,
|
|
|
|
partitioning.PartitionVolume,
|
|
|
|
filesystem.TuneVolumeFS,
|
|
|
|
filesystem.AddXFSProgs,
|
|
|
|
filesystem.CreateBootMountDir,
|
|
|
|
bootstrap.MakeTarball,
|
|
|
|
bootstrap.Bootstrap]
|
2013-07-14 23:16:37 +02:00
|
|
|
if manifest.volume['backing'] == 'ebs':
|
|
|
|
if 'snapshot' in settings and settings['snapshot'] is not None:
|
|
|
|
tasklist.replace(ebs.Create, CreateFromSnapshot())
|
2013-09-15 13:19:45 +02:00
|
|
|
tasklist.remove(*skip_tasks)
|
2013-07-14 23:16:37 +02:00
|
|
|
else:
|
|
|
|
tasklist.add(Snapshot())
|
2013-07-09 20:45:57 +02:00
|
|
|
else:
|
2013-07-14 23:16:37 +02:00
|
|
|
if 'image' in settings and settings['image'] is not None:
|
2013-09-15 13:19:45 +02:00
|
|
|
tasklist.replace(loopback.Create, CreateFromImage())
|
|
|
|
tasklist.remove(*skip_tasks)
|
2013-07-14 23:16:37 +02:00
|
|
|
else:
|
|
|
|
tasklist.add(CopyImage())
|
2013-07-01 00:17:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
def rollback_tasks(tasklist, tasks_completed, manifest):
|
|
|
|
completed = [type(task) for task in tasks_completed]
|
|
|
|
|
|
|
|
def counter_task(task, counter):
|
|
|
|
if task in completed and counter not in completed:
|
|
|
|
tasklist.add(counter())
|
|
|
|
|
2013-07-14 23:16:37 +02:00
|
|
|
if manifest.volume['backing'] == 'ebs':
|
2013-09-15 13:19:45 +02:00
|
|
|
counter_task(CreateFromSnapshot, volume.Delete)
|
2013-07-14 23:16:37 +02:00
|
|
|
else:
|
2013-09-15 13:19:45 +02:00
|
|
|
counter_task(CreateFromImage, volume.Delete)
|
2013-07-01 20:13:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
def validate_manifest(data, schema_validate):
|
|
|
|
from os import path
|
|
|
|
schema_path = path.normpath(path.join(path.dirname(__file__), 'manifest-schema.json'))
|
|
|
|
schema_validate(data, schema_path)
|