From 9f85cdf9094a2c092f66694e7f1d9b6543e25bdf Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Sat, 13 Jul 2013 13:55:12 +0200 Subject: [PATCH] Remove 'Volume' part from ebs tasks. It's kind of obvious that we are working with volumes in the ebs module. --- plugins/prebootstrapped/__init__.py | 10 +++++----- plugins/prebootstrapped/tasks.py | 8 ++++---- providers/ec2/__init__.py | 14 +++++++------- providers/ec2/tasks/ami.py | 4 ++-- providers/ec2/tasks/ebs.py | 13 ++++++------- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/plugins/prebootstrapped/__init__.py b/plugins/prebootstrapped/__init__.py index 7e5bfc7..72f9102 100644 --- a/plugins/prebootstrapped/__init__.py +++ b/plugins/prebootstrapped/__init__.py @@ -1,5 +1,5 @@ -from tasks import CreateSnapshot -from tasks import CreateVolumeFromSnapshot +from tasks import Snapshot +from tasks import CreateFromSnapshot from providers.ec2.tasks import ebs @@ -7,9 +7,9 @@ def tasks(tasklist, manifest): from providers.ec2.tasks import bootstrap from providers.ec2.tasks import filesystem if manifest.plugins['prebootstrapped']['snapshot'] == "": - tasklist.add(CreateSnapshot()) + tasklist.add(Snapshot()) else: - tasklist.replace(ebs.CreateVolume, CreateVolumeFromSnapshot()) + tasklist.replace(ebs.Create, CreateFromSnapshot()) tasklist.remove(filesystem.FormatVolume, filesystem.TuneVolumeFS, filesystem.AddXFSProgs, @@ -24,7 +24,7 @@ def rollback_tasks(tasklist, tasks_completed, manifest): if task in completed and counter not in completed: tasklist.add(counter()) - counter_task(CreateVolumeFromSnapshot, ebs.DeleteVolume) + counter_task(CreateFromSnapshot, ebs.Delete) def validate_manifest(data, schema_validate): diff --git a/plugins/prebootstrapped/tasks.py b/plugins/prebootstrapped/tasks.py index 4d8e52a..6de08a1 100644 --- a/plugins/prebootstrapped/tasks.py +++ b/plugins/prebootstrapped/tasks.py @@ -8,11 +8,11 @@ import logging log = logging.getLogger(__name__) -class CreateVolumeFromSnapshot(Task): +class CreateFromSnapshot(Task): description = 'Creating EBS volume from a snapshot' phase = phases.volume_creation after = [connection.Connect] - before = [ebs.AttachVolume] + before = [ebs.Attach] def run(self, info): volume_size = int(info.manifest.volume['size']/1024) @@ -25,12 +25,12 @@ class CreateVolumeFromSnapshot(Task): info.volume.update() -class CreateSnapshot(ebs.CreateSnapshot): +class Snapshot(ebs.Snapshot): description = 'Creating a snapshot of the bootstrapped volume' phase = phases.os_installation after = [bootstrap.Bootstrap] def run(self, info): - super(CreateSnapshot, self).run(info) + super(Snapshot, self).run(info) msg = 'A snapshot of the bootstrapped volume was created. ID: {id}'.format(id=info.snapshot.id) log.info(msg) diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index aca29e3..e4abbe7 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -30,8 +30,8 @@ def tasks(tasklist, manifest): ami.AMIName(), connection.Connect()) if manifest.volume['backing'].lower() == 'ebs': - tasklist.add(ebs.CreateVolume(), - ebs.AttachVolume()) + tasklist.add(ebs.Create(), + ebs.Attach()) tasklist.add(filesystem.FormatVolume()) if manifest.volume['filesystem'].lower() == 'xfs': tasklist.add(filesystem.AddXFSProgs()) @@ -70,9 +70,9 @@ def tasks(tasklist, manifest): filesystem.UnmountVolume(), filesystem.DeleteMountDir()) if manifest.volume['backing'].lower() == 'ebs': - tasklist.add(ebs.DetachVolume(), - ebs.CreateSnapshot(), - ebs.DeleteVolume()) + tasklist.add(ebs.Detach(), + ebs.Snapshot(), + ebs.Delete()) tasklist.add(ami.RegisterAMI()) @@ -84,8 +84,8 @@ def rollback_tasks(tasklist, tasks_completed, manifest): tasklist.add(counter()) if manifest.volume['backing'].lower() == 'ebs': - counter_task(ebs.CreateVolume, ebs.DeleteVolume) - counter_task(ebs.AttachVolume, ebs.DetachVolume) + counter_task(ebs.Create, ebs.Delete) + counter_task(ebs.Attach, ebs.Detach) counter_task(filesystem.CreateMountDir, filesystem.DeleteMountDir) counter_task(filesystem.MountVolume, filesystem.UnmountVolume) counter_task(filesystem.MountSpecials, filesystem.UnmountSpecials) diff --git a/providers/ec2/tasks/ami.py b/providers/ec2/tasks/ami.py index a692c0a..600b68e 100644 --- a/providers/ec2/tasks/ami.py +++ b/providers/ec2/tasks/ami.py @@ -1,6 +1,6 @@ from base import Task from common import phases -from ebs import CreateSnapshot +from ebs import Snapshot from connection import Connect from common.exceptions import TaskError @@ -38,7 +38,7 @@ class AMIName(Task): class RegisterAMI(Task): description = 'Registering the image as an AMI' phase = phases.image_registration - after = [CreateSnapshot] + after = [Snapshot] kernel_mapping = {'us-east-1': {'amd64': 'aki-88aa75e1', 'i386': 'aki-b6aa75df'}, diff --git a/providers/ec2/tasks/ebs.py b/providers/ec2/tasks/ebs.py index 49e5ba5..b54a31c 100644 --- a/providers/ec2/tasks/ebs.py +++ b/providers/ec2/tasks/ebs.py @@ -5,7 +5,7 @@ from filesystem import UnmountVolume import time -class CreateVolume(Task): +class Create(Task): description = 'Creating an EBS volume for bootstrapping' phase = phases.volume_creation @@ -17,10 +17,10 @@ class CreateVolume(Task): info.volume.update() -class AttachVolume(Task): +class Attach(Task): description = 'Attaching the EBS volume' phase = phases.volume_creation - after = [CreateVolume] + after = [Create] def run(self, info): def char_range(c1, c2): @@ -45,7 +45,7 @@ class AttachVolume(Task): info.volume.update() -class DetachVolume(Task): +class Detach(Task): description = 'Detaching the EBS volume' phase = phases.volume_unmounting after = [UnmountVolume] @@ -57,7 +57,7 @@ class DetachVolume(Task): info.volume.update() -class CreateSnapshot(Task): +class Snapshot(Task): description = 'Creating a snapshot of the EBS volume' phase = phases.image_registration @@ -68,10 +68,9 @@ class CreateSnapshot(Task): info.snapshot.update() -class DeleteVolume(Task): +class Delete(Task): description = 'Deleting the EBS volume' phase = phases.cleaning - after = [] def run(self, info): info.volume.delete()