diff --git a/providers/ec2/manifest.py b/providers/ec2/manifest.py index d2e0f2c..01813a7 100644 --- a/providers/ec2/manifest.py +++ b/providers/ec2/manifest.py @@ -1,4 +1,5 @@ import base +from common.exceptions import ManifestError class Manifest(base.Manifest): @@ -7,9 +8,14 @@ class Manifest(base.Manifest): from os import path schema_path = path.join(path.dirname(__file__), 'manifest-schema.json') self.schema_validate(data, schema_path) + if data['volume']['backing'] == 'ebs' and data['volume']['size'] % 1024 != 0: + msg = 'The volume size must be a multiple of 1024 when using EBS backing' + raise ManifestError(msg, self) def parse(self, data): super(Manifest, self).parse(data) self.credentials = data['credentials'] self.virtualization = data['virtualization'] self.image = data['image'] + if data['volume']['backing'] == 'ebs': + self.ebs_volume_size = data['volume']['size'] / 1024 diff --git a/providers/ec2/tasks/ami.py b/providers/ec2/tasks/ami.py index fbabbf3..575527c 100644 --- a/providers/ec2/tasks/ami.py +++ b/providers/ec2/tasks/ami.py @@ -66,7 +66,7 @@ class RegisterAMI(Task): from boto.ec2.blockdevicemapping import BlockDeviceType from boto.ec2.blockdevicemapping import BlockDeviceMapping block_device = BlockDeviceType(snapshot_id=info.snapshot.id, delete_on_termination=True, - size=int(info.manifest.volume['size']/1024)) + size=info.manifest.ebs_volume_size) block_device_map = BlockDeviceMapping() block_device_map['/dev/sda1'] = block_device diff --git a/providers/ec2/tasks/ebs.py b/providers/ec2/tasks/ebs.py index 453fe29..49e5ba5 100644 --- a/providers/ec2/tasks/ebs.py +++ b/providers/ec2/tasks/ebs.py @@ -10,9 +10,8 @@ class CreateVolume(Task): phase = phases.volume_creation def run(self, info): - volume_size = int(info.manifest.volume['size']/1024) - - info.volume = info.connection.create_volume(volume_size, info.host['availabilityZone']) + info.volume = info.connection.create_volume(info.manifest.ebs_volume_size, + info.host['availabilityZone']) while info.volume.volume_state() != 'available': time.sleep(5) info.volume.update()