mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 09:50:37 +00:00
Add get_standard_rollback_tasks()
This simplifies the the providser rollback_tasks fn considerably
This commit is contained in:
parent
26f0702ae1
commit
0a2cd86b4b
10 changed files with 40 additions and 47 deletions
|
@ -105,7 +105,7 @@ def run(opts):
|
|||
rollback_tasklist.tasks.add(counter)
|
||||
# Ask the provider and plugins for tasks they'd like to add to the rollback tasklist
|
||||
# Any additional arguments beyond the first two are passed directly to the provider and plugins
|
||||
rollback_tasklist.load('resolve_rollback_tasks', manifest, counter_task)
|
||||
rollback_tasklist.load('resolve_rollback_tasks', manifest, tasklist.tasks_completed, counter_task)
|
||||
|
||||
# Run the rollback tasklist
|
||||
rollback_tasklist.run(info=bootstrap_info, dry_run=opts['--dry-run'])
|
||||
|
|
|
@ -4,6 +4,7 @@ from tasks import host
|
|||
from tasks import boot
|
||||
from tasks import bootstrap
|
||||
from tasks import volume
|
||||
from tasks import loopback
|
||||
from tasks import filesystem
|
||||
from tasks import partitioning
|
||||
from tasks import cleanup
|
||||
|
@ -144,3 +145,23 @@ def get_fs_specific_group(manifest):
|
|||
cleanup_group = [cleanup.ClearMOTD,
|
||||
cleanup.CleanTMP,
|
||||
]
|
||||
|
||||
|
||||
rollback_map = {workspace.CreateWorkspace: workspace.DeleteWorkspace,
|
||||
loopback.Create: volume.Delete,
|
||||
volume.Attach: volume.Detach,
|
||||
partitioning.MapPartitions: partitioning.UnmapPartitions,
|
||||
filesystem.CreateMountDir: filesystem.DeleteMountDir,
|
||||
filesystem.MountRoot: filesystem.UnmountRoot,
|
||||
}
|
||||
|
||||
|
||||
def get_standard_rollback_tasks(completed):
|
||||
rollback_tasks = set()
|
||||
for task in completed:
|
||||
if task not in rollback_map:
|
||||
continue
|
||||
counter = rollback_map[task]
|
||||
if task in completed and counter not in completed:
|
||||
rollback_tasks.add(counter)
|
||||
return rollback_tasks
|
||||
|
|
|
@ -21,5 +21,5 @@ def resolve_tasks(taskset, manifest):
|
|||
taskset.add(tasks.ShrinkVolume)
|
||||
|
||||
|
||||
def resolve_rollback_tasks(taskset, manifest, counter_task):
|
||||
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
|
||||
counter_task(tasks.AddFolderMounts, tasks.RemoveFolderMounts)
|
||||
|
|
|
@ -50,7 +50,7 @@ def resolve_tasks(taskset, manifest):
|
|||
taskset.add(CopyImage)
|
||||
|
||||
|
||||
def resolve_rollback_tasks(taskset, manifest, counter_task):
|
||||
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
|
||||
if manifest.volume['backing'] == 'ebs':
|
||||
counter_task(CreateFromSnapshot, volume.Delete)
|
||||
else:
|
||||
|
|
|
@ -30,5 +30,5 @@ def resolve_tasks(taskset, manifest):
|
|||
])
|
||||
|
||||
|
||||
def resolve_rollback_tasks(taskset, manifest, counter_task):
|
||||
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
|
||||
counter_task(tasks.CreateVagrantBoxDir, tasks.RemoveVagrantBoxDir)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from bootstrapvz.common import task_groups
|
||||
import tasks.packages
|
||||
import tasks.boot
|
||||
import tasks.image
|
||||
|
@ -24,7 +25,6 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
from bootstrapvz.common import task_groups
|
||||
taskset.update(task_groups.get_standard_groups(manifest))
|
||||
|
||||
taskset.update([tasks.packages.DefaultPackages,
|
||||
|
@ -39,10 +39,5 @@ def resolve_tasks(taskset, manifest):
|
|||
])
|
||||
|
||||
|
||||
def resolve_rollback_tasks(taskset, manifest, counter_task):
|
||||
counter_task(loopback.Create, volume.Delete)
|
||||
counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir)
|
||||
counter_task(partitioning.MapPartitions, partitioning.UnmapPartitions)
|
||||
counter_task(filesystem.MountRoot, filesystem.UnmountRoot)
|
||||
counter_task(volume.Attach, volume.Detach)
|
||||
counter_task(workspace.CreateWorkspace, workspace.DeleteWorkspace)
|
||||
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
|
||||
taskset.update(task_groups.get_standard_rollback_tasks(completed))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from bootstrapvz.common import task_groups
|
||||
import tasks.packages
|
||||
import tasks.connection
|
||||
import tasks.host
|
||||
|
@ -47,7 +48,6 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
from bootstrapvz.common import task_groups
|
||||
taskset.update(task_groups.get_standard_groups(manifest))
|
||||
taskset.update(task_groups.ssh_group)
|
||||
|
||||
|
@ -97,17 +97,8 @@ def resolve_tasks(taskset, manifest):
|
|||
])
|
||||
|
||||
|
||||
def resolve_rollback_tasks(taskset, manifest, counter_task):
|
||||
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
|
||||
taskset.update(task_groups.get_standard_rollback_tasks(completed))
|
||||
counter_task(tasks.ebs.Create, volume.Delete)
|
||||
counter_task(tasks.ebs.Attach, volume.Detach)
|
||||
|
||||
counter_task(loopback.Create, volume.Delete)
|
||||
counter_task(volume.Attach, volume.Detach)
|
||||
|
||||
counter_task(partitioning.MapPartitions, partitioning.UnmapPartitions)
|
||||
counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir)
|
||||
|
||||
counter_task(filesystem.MountRoot, filesystem.UnmountRoot)
|
||||
counter_task(volume.Attach, volume.Detach)
|
||||
counter_task(workspace.CreateWorkspace, workspace.DeleteWorkspace)
|
||||
counter_task(tasks.ami.BundleImage, tasks.ami.RemoveBundle)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import bootstrapvz.common.task_groups
|
||||
import tasks.apt
|
||||
import tasks.boot
|
||||
import tasks.configuration
|
||||
|
@ -48,10 +49,5 @@ def resolve_tasks(tasklist, manifest):
|
|||
tasklist.add(tasks.image.RegisterImage)
|
||||
|
||||
|
||||
def resolve_rollback_tasks(tasklist, manifest, counter_task):
|
||||
counter_task(loopback.Create, volume.Delete)
|
||||
counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir)
|
||||
counter_task(partitioning.MapPartitions, partitioning.UnmapPartitions)
|
||||
counter_task(filesystem.MountRoot, filesystem.UnmountRoot)
|
||||
counter_task(volume.Attach, volume.Detach)
|
||||
counter_task(workspace.CreateWorkspace, workspace.DeleteWorkspace)
|
||||
def resolve_rollback_tasks(tasklist, manifest, completed, counter_task):
|
||||
taskset.update(task_groups.get_standard_rollback_tasks(completed))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from bootstrapvz.common import task_groups
|
||||
import tasks.packages
|
||||
from bootstrapvz.common.tasks import volume
|
||||
from bootstrapvz.common.tasks import loopback
|
||||
|
@ -22,7 +23,6 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
from bootstrapvz.common import task_groups
|
||||
taskset.update(task_groups.get_standard_groups(manifest))
|
||||
|
||||
taskset.update([tasks.packages.DefaultPackages,
|
||||
|
@ -39,10 +39,5 @@ def resolve_tasks(taskset, manifest):
|
|||
taskset.update([virtio.VirtIO])
|
||||
|
||||
|
||||
def resolve_rollback_tasks(taskset, manifest, counter_task):
|
||||
counter_task(loopback.Create, volume.Delete)
|
||||
counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir)
|
||||
counter_task(partitioning.MapPartitions, partitioning.UnmapPartitions)
|
||||
counter_task(filesystem.MountRoot, filesystem.UnmountRoot)
|
||||
counter_task(volume.Attach, volume.Detach)
|
||||
counter_task(workspace.CreateWorkspace, workspace.DeleteWorkspace)
|
||||
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
|
||||
taskset.update(task_groups.get_standard_rollback_tasks(completed))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from bootstrapvz.common import task_groups
|
||||
import tasks.packages
|
||||
from bootstrapvz.common.tasks import volume
|
||||
from bootstrapvz.common.tasks import loopback
|
||||
|
@ -20,7 +21,6 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
|
||||
def resolve_tasks(taskset, manifest):
|
||||
from bootstrapvz.common import task_groups
|
||||
taskset.update(task_groups.get_standard_groups(manifest))
|
||||
|
||||
taskset.update([tasks.packages.DefaultPackages,
|
||||
|
@ -36,10 +36,5 @@ def resolve_tasks(taskset, manifest):
|
|||
])
|
||||
|
||||
|
||||
def resolve_rollback_tasks(taskset, manifest, counter_task):
|
||||
counter_task(loopback.Create, volume.Delete)
|
||||
counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir)
|
||||
counter_task(partitioning.MapPartitions, partitioning.UnmapPartitions)
|
||||
counter_task(filesystem.MountRoot, filesystem.UnmountRoot)
|
||||
counter_task(volume.Attach, volume.Detach)
|
||||
counter_task(workspace.CreateWorkspace, workspace.DeleteWorkspace)
|
||||
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
|
||||
taskset.update(task_groups.get_standard_rollback_tasks(completed))
|
||||
|
|
Loading…
Add table
Reference in a new issue