mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
Ensure the volume size is a multiple of 1024 when using EBS
This commit is contained in:
parent
55741b822f
commit
e355e99189
3 changed files with 9 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue