mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Introduce task-sets to combat the unwieldy amount of tasks
This commit is contained in:
parent
738ba47c65
commit
c756eb3f74
2 changed files with 85 additions and 45 deletions
62
common/task_sets.py
Normal file
62
common/task_sets.py
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
from common.tasks import workspace
|
||||||
|
from common.tasks import packages
|
||||||
|
from common.tasks import host
|
||||||
|
from common.tasks import volume
|
||||||
|
from common.tasks import filesystem
|
||||||
|
from common.tasks import partitioning
|
||||||
|
from common.tasks import cleanup
|
||||||
|
from common.tasks import apt
|
||||||
|
from common.tasks import security
|
||||||
|
from common.tasks import locale
|
||||||
|
|
||||||
|
base_set = [workspace.CreateWorkspace,
|
||||||
|
packages.HostPackages,
|
||||||
|
packages.ImagePackages,
|
||||||
|
host.CheckPackages,
|
||||||
|
workspace.DeleteWorkspace,
|
||||||
|
]
|
||||||
|
|
||||||
|
volume_set = [volume.Attach,
|
||||||
|
volume.Detach,
|
||||||
|
]
|
||||||
|
|
||||||
|
partitioning_set = [partitioning.PartitionVolume,
|
||||||
|
partitioning.MapPartitions,
|
||||||
|
partitioning.UnmapPartitions,
|
||||||
|
]
|
||||||
|
|
||||||
|
boot_partition_set = [filesystem.CreateBootMountDir,
|
||||||
|
filesystem.MountBoot,
|
||||||
|
filesystem.UnmountBoot,
|
||||||
|
]
|
||||||
|
|
||||||
|
mounting_set = [filesystem.CreateMountDir,
|
||||||
|
filesystem.MountRoot,
|
||||||
|
filesystem.MountSpecials,
|
||||||
|
filesystem.UnmountSpecials,
|
||||||
|
filesystem.UnmountRoot,
|
||||||
|
filesystem.DeleteMountDir,
|
||||||
|
]
|
||||||
|
|
||||||
|
ssh_set = [security.DisableSSHPasswordAuthentication,
|
||||||
|
security.DisableSSHDNSLookup,
|
||||||
|
cleanup.ShredHostkeys,
|
||||||
|
]
|
||||||
|
|
||||||
|
apt_set = [apt.DisableDaemonAutostart,
|
||||||
|
apt.AptSources,
|
||||||
|
apt.AptUpgrade,
|
||||||
|
apt.PurgeUnusedPackages,
|
||||||
|
apt.AptClean,
|
||||||
|
apt.EnableDaemonAutostart,
|
||||||
|
]
|
||||||
|
|
||||||
|
locale_set = [locale.GenerateLocale,
|
||||||
|
locale.SetTimezone,
|
||||||
|
]
|
||||||
|
|
||||||
|
fs_specific_set = {'ext2': [filesystem.TuneVolumeFS],
|
||||||
|
'ext3': [filesystem.TuneVolumeFS],
|
||||||
|
'ext4': [filesystem.TuneVolumeFS],
|
||||||
|
'xfs': [filesystem.AddXFSProgs],
|
||||||
|
}
|
|
@ -1,14 +1,10 @@
|
||||||
from manifest import Manifest
|
from manifest import Manifest
|
||||||
from tasks import packages
|
from tasks import packages
|
||||||
from common.tasks import packages as common_packages
|
|
||||||
from common.tasks import host
|
|
||||||
from common.tasks import volume as volume_tasks
|
from common.tasks import volume as volume_tasks
|
||||||
from common.tasks import loopback
|
from common.tasks import loopback
|
||||||
from common.tasks import partitioning
|
from common.tasks import partitioning
|
||||||
from common.tasks import filesystem
|
from common.tasks import filesystem
|
||||||
from common.tasks import bootstrap
|
from common.tasks import bootstrap
|
||||||
from common.tasks import locale
|
|
||||||
from common.tasks import apt
|
|
||||||
from tasks import boot
|
from tasks import boot
|
||||||
from common.tasks import boot as common_boot
|
from common.tasks import boot as common_boot
|
||||||
from common.tasks import security
|
from common.tasks import security
|
||||||
|
@ -23,28 +19,28 @@ def initialize():
|
||||||
|
|
||||||
|
|
||||||
def tasks(tasklist, manifest):
|
def tasks(tasklist, manifest):
|
||||||
tasklist.add(workspace.CreateWorkspace,
|
from common.task_sets import base_set
|
||||||
packages.HostPackages,
|
from common.task_sets import volume_set
|
||||||
common_packages.HostPackages,
|
from common.task_sets import mounting_set
|
||||||
|
from common.task_sets import apt_set
|
||||||
|
from common.task_sets import locale_set
|
||||||
|
tasklist.add(*base_set)
|
||||||
|
tasklist.add(*volume_set)
|
||||||
|
tasklist.add(*mounting_set)
|
||||||
|
tasklist.add(*apt_set)
|
||||||
|
tasklist.add(*locale_set)
|
||||||
|
|
||||||
|
if manifest.volume['partitions']['type'] != 'none':
|
||||||
|
from common.task_sets import partitioning_set
|
||||||
|
tasklist.add(*partitioning_set)
|
||||||
|
|
||||||
|
tasklist.add(packages.HostPackages,
|
||||||
packages.ImagePackages,
|
packages.ImagePackages,
|
||||||
common_packages.ImagePackages,
|
|
||||||
host.CheckPackages,
|
|
||||||
|
|
||||||
loopback.Create,
|
loopback.Create,
|
||||||
volume_tasks.Attach,
|
|
||||||
partitioning.PartitionVolume,
|
|
||||||
partitioning.MapPartitions,
|
|
||||||
filesystem.Format,
|
filesystem.Format,
|
||||||
filesystem.CreateMountDir,
|
|
||||||
filesystem.MountRoot,
|
|
||||||
|
|
||||||
bootstrap.Bootstrap,
|
bootstrap.Bootstrap,
|
||||||
filesystem.MountSpecials,
|
|
||||||
locale.GenerateLocale,
|
|
||||||
locale.SetTimezone,
|
|
||||||
apt.DisableDaemonAutostart,
|
|
||||||
apt.AptSources,
|
|
||||||
apt.AptUpgrade,
|
|
||||||
boot.ConfigureGrub,
|
boot.ConfigureGrub,
|
||||||
filesystem.FStab,
|
filesystem.FStab,
|
||||||
common_boot.BlackListModules,
|
common_boot.BlackListModules,
|
||||||
|
@ -57,40 +53,22 @@ def tasks(tasklist, manifest):
|
||||||
initd.InstallInitScripts,
|
initd.InstallInitScripts,
|
||||||
cleanup.ClearMOTD,
|
cleanup.ClearMOTD,
|
||||||
cleanup.CleanTMP,
|
cleanup.CleanTMP,
|
||||||
apt.PurgeUnusedPackages,
|
|
||||||
apt.AptClean,
|
|
||||||
apt.EnableDaemonAutostart,
|
|
||||||
filesystem.UnmountSpecials,
|
|
||||||
|
|
||||||
filesystem.UnmountRoot,
|
|
||||||
partitioning.UnmapPartitions,
|
|
||||||
volume_tasks.Detach,
|
|
||||||
filesystem.DeleteMountDir,
|
|
||||||
loopback.MoveImage,
|
loopback.MoveImage,
|
||||||
workspace.DeleteWorkspace)
|
workspace.DeleteWorkspace)
|
||||||
|
|
||||||
if manifest.bootstrapper.get('tarball', False):
|
if manifest.bootstrapper.get('tarball', False):
|
||||||
tasklist.add(bootstrap.MakeTarball)
|
tasklist.add(bootstrap.MakeTarball)
|
||||||
|
|
||||||
partitions = manifest.volume['partitions']
|
from common.task_sets import fs_specific_set
|
||||||
import re
|
for partition in manifest.volume['partitions']:
|
||||||
for key in ['boot', 'root']:
|
if 'filesystem' in partition:
|
||||||
if key not in partitions:
|
fs_tasks = fs_specific_set.get(partition['filesystem'], [])
|
||||||
continue
|
tasklist.add(fs_tasks)
|
||||||
if re.match('^ext[2-4]$', partitions[key]['filesystem']) is not None:
|
|
||||||
tasklist.add(filesystem.TuneVolumeFS)
|
|
||||||
break
|
|
||||||
for key in ['boot', 'root']:
|
|
||||||
if key not in partitions:
|
|
||||||
continue
|
|
||||||
if partitions[key]['filesystem'] == 'xfs':
|
|
||||||
tasklist.add(filesystem.AddXFSProgs)
|
|
||||||
break
|
|
||||||
|
|
||||||
if 'boot' in manifest.volume['partitions']:
|
if 'boot' in manifest.volume['partitions']:
|
||||||
tasklist.add(filesystem.CreateBootMountDir,
|
from common.task_sets import boot_partition_set
|
||||||
filesystem.MountBoot,
|
tasklist.add(*boot_partition_set)
|
||||||
filesystem.UnmountBoot)
|
|
||||||
|
|
||||||
|
|
||||||
def rollback_tasks(tasklist, tasks_completed, manifest):
|
def rollback_tasks(tasklist, tasks_completed, manifest):
|
||||||
|
|
Loading…
Add table
Reference in a new issue