bootstrap-vz/plugins/prebootstrapped/__init__.py
Anders Ingemann a4ead02a9b Remove provider specific manifests
Manifest and module loading has been refactored
Provider modules now must implement validate_manifest like plugins do
Simplified loading of manifests
2014-01-05 14:03:04 +01:00

60 lines
1.8 KiB
Python

from tasks import Snapshot
from tasks import CopyImage
from tasks import CreateFromSnapshot
from tasks import CreateFromImage
from providers.ec2.tasks import ebs
from common.tasks import loopback
from common.tasks import volume
from common.tasks import locale
from common.tasks import apt
from common.tasks import bootstrap
from common.tasks import filesystem
from common.tasks import partitioning
def validate_manifest(data, validator, error):
import os.path
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.json'))
validator(data, schema_path)
def resolve_tasks(tasklist, manifest):
settings = manifest.plugins['prebootstrapped']
skip_tasks = [ebs.Create,
loopback.Create,
filesystem.Format,
partitioning.PartitionVolume,
filesystem.TuneVolumeFS,
filesystem.AddXFSProgs,
filesystem.CreateBootMountDir,
apt.DisableDaemonAutostart,
locale.GenerateLocale,
bootstrap.MakeTarball,
bootstrap.Bootstrap]
if manifest.volume['backing'] == 'ebs':
if 'snapshot' in settings and settings['snapshot'] is not None:
tasklist.add(CreateFromSnapshot)
tasklist.remove(*skip_tasks)
else:
tasklist.add(Snapshot)
else:
if 'image' in settings and settings['image'] is not None:
tasklist.add(CreateFromImage)
tasklist.remove(*skip_tasks)
else:
tasklist.add(CopyImage)
def resolve_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)
if manifest.volume['backing'] == 'ebs':
counter_task(CreateFromSnapshot, volume.Delete)
else:
counter_task(CreateFromImage, volume.Delete)