diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index 9c7f32c..412b90f 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -66,7 +66,8 @@ def tasks(tasklist, manifest): filesystem.UnmountSpecials(), filesystem.UnmountVolume(), ebs.DetachVolume(), - filesystem.DeleteMountDir()) + filesystem.DeleteMountDir(), + ebs.CreateSnapshot()) from common.tasks import TriggerRollback tasklist.add(TriggerRollback()) diff --git a/providers/ec2/tasks/ebs.py b/providers/ec2/tasks/ebs.py index 0fd6328..a07b1a8 100644 --- a/providers/ec2/tasks/ebs.py +++ b/providers/ec2/tasks/ebs.py @@ -63,6 +63,17 @@ class DetachVolume(Task): info.volume.update() +class CreateSnapshot(Task): + description = 'Creating a snapshot of the EBS volume' + phase = phases.image_registration + + def run(self, info): + info.snapshot = info.volume.create_snapshot() + while info.snapshot.status != 'completed': + time.sleep(2) + info.snapshot.update() + + class DeleteVolume(Task): phase = phases.cleaning after = []