2013-07-10 10:49:45 +02:00
|
|
|
from manifest import Manifest
|
|
|
|
from tasks import packages
|
2013-08-10 19:01:54 +02:00
|
|
|
from common.tasks import packages as common_packages
|
2013-08-11 18:00:19 +02:00
|
|
|
from common.tasks import host
|
2013-09-15 13:19:45 +02:00
|
|
|
from common.tasks import volume as volume_tasks
|
2013-08-11 15:54:04 +02:00
|
|
|
from common.tasks import loopback
|
2013-09-15 13:19:45 +02:00
|
|
|
from common.tasks import partitioning
|
2013-08-10 20:03:20 +02:00
|
|
|
from common.tasks import filesystem
|
2013-08-10 16:22:16 +02:00
|
|
|
from common.tasks import bootstrap
|
2013-08-10 16:27:43 +02:00
|
|
|
from common.tasks import locale
|
2013-08-10 16:15:49 +02:00
|
|
|
from common.tasks import apt
|
2013-07-10 10:49:45 +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-08-10 16:27:43 +02:00
|
|
|
from common.tasks import network
|
2013-08-10 16:55:27 +02:00
|
|
|
from common.tasks import initd
|
2013-08-10 16:24:12 +02:00
|
|
|
from common.tasks import cleanup
|
2013-09-15 16:59:56 +02:00
|
|
|
from common.tasks import workspace
|
2013-07-10 10:49:45 +02:00
|
|
|
|
2013-08-10 16:18:48 +02:00
|
|
|
|
2013-07-10 10:49:45 +02:00
|
|
|
def initialize():
|
2013-08-10 16:56:14 +02:00
|
|
|
pass
|
2013-07-10 10:49:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
def tasks(tasklist, manifest):
|
2013-09-22 17:31:43 +02:00
|
|
|
tasklist.add(workspace.CreateWorkspace,
|
|
|
|
packages.HostPackages,
|
|
|
|
common_packages.HostPackages,
|
|
|
|
packages.ImagePackages,
|
|
|
|
common_packages.ImagePackages,
|
|
|
|
host.CheckPackages,
|
2013-08-10 17:52:24 +02:00
|
|
|
|
2013-09-22 17:31:43 +02:00
|
|
|
loopback.Create,
|
|
|
|
volume_tasks.Attach,
|
|
|
|
partitioning.PartitionVolume,
|
|
|
|
partitioning.MapPartitions,
|
|
|
|
filesystem.Format,
|
|
|
|
filesystem.CreateMountDir,
|
|
|
|
filesystem.MountRoot,
|
2013-08-10 17:52:24 +02:00
|
|
|
|
2013-09-22 17:31:43 +02:00
|
|
|
bootstrap.Bootstrap,
|
|
|
|
filesystem.MountSpecials,
|
|
|
|
locale.GenerateLocale,
|
|
|
|
locale.SetTimezone,
|
|
|
|
apt.DisableDaemonAutostart,
|
|
|
|
apt.AptSources,
|
|
|
|
apt.AptUpgrade,
|
|
|
|
boot.ConfigureGrub,
|
|
|
|
filesystem.FStab,
|
|
|
|
common_boot.BlackListModules,
|
|
|
|
common_boot.DisableGetTTYs,
|
|
|
|
security.EnableShadowConfig,
|
|
|
|
network.RemoveDNSInfo,
|
|
|
|
network.ConfigureNetworkIF,
|
|
|
|
network.RemoveHostname,
|
|
|
|
initd.ResolveInitScripts,
|
|
|
|
initd.InstallInitScripts,
|
|
|
|
cleanup.ClearMOTD,
|
|
|
|
cleanup.CleanTMP,
|
|
|
|
apt.PurgeUnusedPackages,
|
|
|
|
apt.AptClean,
|
|
|
|
apt.EnableDaemonAutostart,
|
|
|
|
filesystem.UnmountSpecials,
|
2013-08-10 17:52:24 +02:00
|
|
|
|
2013-09-22 17:31:43 +02:00
|
|
|
filesystem.UnmountRoot,
|
|
|
|
partitioning.UnmapPartitions,
|
|
|
|
volume_tasks.Detach,
|
|
|
|
filesystem.DeleteMountDir,
|
|
|
|
loopback.MoveImage,
|
|
|
|
workspace.DeleteWorkspace)
|
2013-08-10 17:52:24 +02:00
|
|
|
|
2013-09-15 16:59:56 +02:00
|
|
|
if manifest.bootstrapper.get('tarball', False):
|
2013-09-22 17:31:43 +02:00
|
|
|
tasklist.add(bootstrap.MakeTarball)
|
2013-08-10 17:52:24 +02:00
|
|
|
|
2013-09-15 13:19:45 +02:00
|
|
|
partitions = manifest.volume['partitions']
|
|
|
|
import re
|
|
|
|
for key in ['boot', 'root']:
|
|
|
|
if key not in partitions:
|
|
|
|
continue
|
|
|
|
if re.match('^ext[2-4]$', partitions[key]['filesystem']) is not None:
|
2013-09-22 17:31:43 +02:00
|
|
|
tasklist.add(filesystem.TuneVolumeFS)
|
2013-09-15 13:19:45 +02:00
|
|
|
break
|
|
|
|
for key in ['boot', 'root']:
|
|
|
|
if key not in partitions:
|
|
|
|
continue
|
|
|
|
if partitions[key]['filesystem'] == 'xfs':
|
2013-09-22 17:31:43 +02:00
|
|
|
tasklist.add(filesystem.AddXFSProgs)
|
2013-09-15 13:19:45 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
if 'boot' in manifest.volume['partitions']:
|
2013-09-22 17:31:43 +02:00
|
|
|
tasklist.add(filesystem.CreateBootMountDir,
|
|
|
|
filesystem.MountBoot,
|
|
|
|
filesystem.UnmountBoot)
|
2013-07-10 10:49:45 +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:
|
2013-09-22 17:31:43 +02:00
|
|
|
tasklist.add(counter)
|
2013-07-10 10:49:45 +02:00
|
|
|
|
2013-09-15 13:19:45 +02:00
|
|
|
counter_task(loopback.Create, volume_tasks.Delete)
|
2013-08-10 20:03:20 +02:00
|
|
|
counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir)
|
2013-09-15 13:19:45 +02:00
|
|
|
counter_task(partitioning.MapPartitions, partitioning.UnmapPartitions)
|
|
|
|
counter_task(filesystem.MountRoot, filesystem.UnmountRoot)
|
|
|
|
counter_task(filesystem.MountBoot, filesystem.UnmountBoot)
|
2013-09-15 18:26:22 +02:00
|
|
|
counter_task(filesystem.MountSpecials, filesystem.UnmountSpecials)
|
2013-09-15 13:19:45 +02:00
|
|
|
counter_task(volume_tasks.Attach, volume_tasks.Detach)
|
2013-09-15 16:59:56 +02:00
|
|
|
counter_task(workspace.CreateWorkspace, workspace.DeleteWorkspace)
|