forked from andsens/bootstrap-vz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
71 lines (63 loc) · 2.77 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from . import tasks
from bootstrapvz.providers.ec2.tasks import ebs
from bootstrapvz.plugins.minimize_size.tasks import dpkg
from bootstrapvz.providers.virtualbox.tasks import guest_additions
from bootstrapvz.common.tasks import loopback
from bootstrapvz.common.tasks import volume
from bootstrapvz.common.tasks import folder
from bootstrapvz.common.tasks import locale
from bootstrapvz.common.tasks import apt
from bootstrapvz.common.tasks import bootstrap
from bootstrapvz.common.tasks import filesystem
from bootstrapvz.common.tasks import partitioning
import bootstrapvz.common.tasks.dpkg
def validate_manifest(data, validator, error):
from bootstrapvz.common.tools import rel_path
validator(data, rel_path(__file__, 'manifest-schema.yml'))
def resolve_tasks(taskset, manifest):
settings = manifest.plugins['prebootstrapped']
skip_tasks = [ebs.Create,
loopback.Create,
folder.Create,
filesystem.Format,
partitioning.PartitionVolume,
filesystem.TuneVolumeFS,
filesystem.AddXFSProgs,
filesystem.CreateBootMountDir,
apt.DisableDaemonAutostart,
dpkg.InitializeBootstrapFilterList,
bootstrapvz.common.tasks.dpkg.CreateDpkgCfg,
dpkg.CreateBootstrapFilterScripts,
dpkg.FilterLocales,
dpkg.ExcludeDocs,
dpkg.DeleteBootstrapFilterScripts,
locale.GenerateLocale,
bootstrap.MakeTarball,
bootstrap.Bootstrap,
guest_additions.InstallGuestAdditions,
]
if manifest.volume['backing'] == 'ebs':
if settings.get('snapshot', None) is not None:
taskset.add(tasks.CreateFromSnapshot)
[taskset.discard(task) for task in skip_tasks]
else:
taskset.add(tasks.Snapshot)
elif manifest.volume['backing'] == 'folder':
if settings.get('folder', None) is not None:
taskset.add(tasks.CreateFromFolder)
[taskset.discard(task) for task in skip_tasks]
else:
taskset.add(tasks.CopyFolder)
else:
if settings.get('image', None) is not None:
taskset.add(tasks.CreateFromImage)
[taskset.discard(task) for task in skip_tasks]
else:
taskset.add(tasks.CopyImage)
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
if manifest.volume['backing'] == 'ebs':
counter_task(taskset, tasks.CreateFromSnapshot, volume.Delete)
elif manifest.volume['backing'] == 'folder':
counter_task(taskset, tasks.CreateFromFolder, folder.Delete)
else:
counter_task(taskset, tasks.CreateFromImage, volume.Delete)