2013-07-10 10:49:45 +02:00
|
|
|
from manifest import Manifest
|
|
|
|
from tasks import packages
|
|
|
|
from tasks import host
|
|
|
|
from tasks import filesystem
|
2013-08-10 17:31:19 +02:00
|
|
|
from common.tasks import filesystem as common_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-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):
|
|
|
|
tasklist.add(packages.HostPackages(),
|
|
|
|
packages.ImagePackages(),
|
2013-08-10 17:20:10 +02:00
|
|
|
host.CheckPackages())
|
2013-07-10 10:49:45 +02:00
|
|
|
tasklist.add(filesystem.FormatVolume())
|
|
|
|
if manifest.volume['filesystem'].lower() == 'xfs':
|
2013-08-10 17:31:19 +02:00
|
|
|
tasklist.add(common_filesystem.AddXFSProgs())
|
2013-07-10 10:49:45 +02:00
|
|
|
if manifest.volume['filesystem'].lower() in ['ext2', 'ext3', 'ext4']:
|
|
|
|
tasklist.add(filesystem.TuneVolumeFS())
|
2013-08-10 17:31:19 +02:00
|
|
|
tasklist.add(common_filesystem.CreateMountDir(),
|
2013-07-10 10:49:45 +02:00
|
|
|
filesystem.MountVolume())
|
|
|
|
if manifest.bootstrapper['tarball']:
|
|
|
|
tasklist.add(bootstrap.MakeTarball())
|
|
|
|
tasklist.add(bootstrap.Bootstrap(),
|
2013-08-10 17:31:19 +02:00
|
|
|
common_filesystem.MountSpecials(),
|
2013-07-10 10:49:45 +02:00
|
|
|
locale.GenerateLocale(),
|
|
|
|
locale.SetTimezone(),
|
|
|
|
apt.DisableDaemonAutostart(),
|
|
|
|
apt.AptSources(),
|
2013-08-10 16:15:49 +02:00
|
|
|
#No network for the moment, skip
|
2013-07-10 15:43:39 +02:00
|
|
|
#apt.AptUpgrade(),
|
2013-07-10 10:49:45 +02:00
|
|
|
boot.ConfigureGrub(),
|
|
|
|
filesystem.ModifyFstab(),
|
2013-08-10 16:18:48 +02:00
|
|
|
common_boot.BlackListModules(),
|
|
|
|
common_boot.DisableGetTTYs(),
|
2013-07-10 10:49:45 +02:00
|
|
|
security.EnableShadowConfig(),
|
2013-08-10 16:15:49 +02:00
|
|
|
security.SetRootPassword(),
|
2013-07-31 16:57:29 +02:00
|
|
|
security.DisableSSHPasswordAuthentication(),
|
2013-07-10 10:49:45 +02:00
|
|
|
security.DisableSSHDNSLookup(),
|
|
|
|
network.RemoveDNSInfo(),
|
|
|
|
network.ConfigureNetworkIF(),
|
|
|
|
network.ConfigureDHCP(),
|
|
|
|
initd.ResolveInitScripts(),
|
|
|
|
initd.InstallInitScripts(),
|
|
|
|
cleanup.ClearMOTD(),
|
|
|
|
cleanup.ShredHostkeys(),
|
|
|
|
cleanup.CleanTMP(),
|
|
|
|
apt.PurgeUnusedPackages(),
|
|
|
|
apt.AptClean(),
|
|
|
|
apt.EnableDaemonAutostart(),
|
2013-08-10 17:31:19 +02:00
|
|
|
common_filesystem.UnmountSpecials(),
|
2013-07-10 10:49:45 +02:00
|
|
|
filesystem.UnmountVolume(),
|
2013-08-10 17:31:19 +02:00
|
|
|
common_filesystem.DeleteMountDir())
|
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:
|
|
|
|
tasklist.add(counter())
|
|
|
|
|
2013-08-10 17:31:19 +02:00
|
|
|
counter_task(common_filesystem.CreateMountDir, common_filesystem.DeleteMountDir)
|
2013-07-10 10:49:45 +02:00
|
|
|
counter_task(filesystem.MountVolume, filesystem.UnmountVolume)
|
2013-08-10 17:31:19 +02:00
|
|
|
counter_task(common_filesystem.MountSpecials, common_filesystem.UnmountSpecials)
|