bootstrap-vz/providers/one/__init__.py

84 lines
2.9 KiB
Python
Raw Normal View History

2013-07-10 10:49:45 +02:00
from manifest import Manifest
from tasks import packages
from tasks import host
from tasks import filesystem
from common.tasks import filesystem as common_filesystem
from common.tasks import bootstrap
from common.tasks import locale
from common.tasks import apt
2013-07-10 10:49:45 +02:00
from tasks import boot
from common.tasks import boot as common_boot
from tasks import context
from common.tasks import security
from common.tasks import network
from common.tasks import initd
from common.tasks import cleanup
2013-07-10 10:49:45 +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:52:24 +02:00
host.CheckPackages(),
filesystem.FormatVolume(),
common_filesystem.CreateMountDir(),
filesystem.MountVolume(),
bootstrap.Bootstrap(),
common_filesystem.MountSpecials(),
2013-07-10 10:49:45 +02:00
locale.GenerateLocale(),
2013-08-10 17:52:24 +02:00
context.OpenNebulaContext(),
2013-07-10 10:49:45 +02:00
locale.SetTimezone(),
apt.DisableDaemonAutostart(),
apt.AptSources(),
#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(),
common_boot.BlackListModules(),
common_boot.DisableGetTTYs(),
2013-07-10 10:49:45 +02:00
security.EnableShadowConfig(),
security.SetRootPassword(),
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(),
common_filesystem.UnmountSpecials(),
2013-08-10 17:52:24 +02:00
2013-07-10 10:49:45 +02:00
filesystem.UnmountVolume(),
common_filesystem.DeleteMountDir())
2013-08-10 17:52:24 +02:00
if manifest.bootstrapper['tarball']:
tasklist.add(bootstrap.MakeTarball())
filesystem_specific_tasks = {'xfs': [filesystem.AddXFSProgs()],
'ext2': [filesystem.TuneVolumeFS()],
'ext3': [filesystem.TuneVolumeFS()],
'ext4': [filesystem.TuneVolumeFS()]}
tasklist.add(*filesystem_specific_tasks.get(manifest.volume['filesystem'].lower()))
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())
counter_task(common_filesystem.CreateMountDir, common_filesystem.DeleteMountDir)
2013-07-10 10:49:45 +02:00
counter_task(filesystem.MountVolume, filesystem.UnmountVolume)
counter_task(common_filesystem.MountSpecials, common_filesystem.UnmountSpecials)