diff --git a/common/fs/__init__.py b/common/fs/__init__.py index 314e008..3cde7cf 100644 --- a/common/fs/__init__.py +++ b/common/fs/__init__.py @@ -28,11 +28,12 @@ def remount(volume, fn): p_map.root.unmount() if not isinstance(p_map, NoPartitions): p_map.unmap(volume) - fn() + result = fn() p_map.map(volume) else: - fn() + result = fn() p_map.root.mount(root_dir) if hasattr(p_map, 'boot'): p_map.boot.mount(boot_dir) volume.mount_specials() + return result diff --git a/plugins/prebootstrapped/tasks.py b/plugins/prebootstrapped/tasks.py index ab7acee..d5fcb57 100644 --- a/plugins/prebootstrapped/tasks.py +++ b/plugins/prebootstrapped/tasks.py @@ -1,9 +1,9 @@ from base import Task from common import phases -from providers.ec2.tasks import ebs from common.tasks import volume from common.tasks import bootstrap from common.tasks import filesystem +from common.fs import remount from shutil import copyfile import os.path import time @@ -11,14 +11,16 @@ import logging log = logging.getLogger(__name__) -class Snapshot(ebs.Snapshot): +class Snapshot(Task): description = 'Creating a snapshot of the bootstrapped volume' phase = phases.os_installation - after = [bootstrap.Bootstrap] + after = [bootstrap.Bootstrap, filesystem.MountSpecials] def run(self, info): - super(Snapshot, self).run(info) - msg = 'A snapshot of the bootstrapped volume was created. ID: {id}'.format(id=info.snapshot.id) + def mk_snapshot(): + return info.volume.snapshot() + snapshot = remount(info.volume, mk_snapshot) + msg = 'A snapshot of the bootstrapped volume was created. ID: {id}'.format(id=snapshot.id) log.info(msg) @@ -43,7 +45,7 @@ class CreateFromSnapshot(Task): class CopyImage(Task): description = 'Creating a snapshot of the bootstrapped volume' phase = phases.os_installation - after = [bootstrap.Bootstrap] + after = [bootstrap.Bootstrap, filesystem.MountSpecials] def run(self, info): loopback_backup_name = 'volume-{id:x}.{ext}.backup'.format(id=info.run_id, ext=info.volume.extension)