Fix EBS part of the prebootstrapped plugin

This commit is contained in:
Anders Ingemann 2013-12-06 00:31:49 +01:00
parent d3dc44bc48
commit 3fef39d4d5

View file

@ -2,7 +2,7 @@ from base import Task
from common import phases from common import phases
from common.tasks import volume from common.tasks import volume
from common.tasks import bootstrap from common.tasks import bootstrap
from common.tasks import filesystem from providers.ec2.tasks import ebs
from common.fs import remount from common.fs import remount
from shutil import copyfile from shutil import copyfile
import os.path import os.path
@ -27,18 +27,19 @@ class Snapshot(Task):
class CreateFromSnapshot(Task): class CreateFromSnapshot(Task):
description = 'Creating EBS volume from a snapshot' description = 'Creating EBS volume from a snapshot'
phase = phases.volume_creation phase = phases.volume_creation
successors = [volume.Attach] successors = [ebs.Attach]
def run(self, info): def run(self, info):
volume_size = int(info.manifest.volume['size'] / 1024) volume_size = int(info.volume.partition_map.get_total_size() / 1024)
snapshot = info.manifest.plugins['prebootstrapped']['snapshot'] snapshot = info.manifest.plugins['prebootstrapped']['snapshot']
info.volume.volume = info.connection.create_volume(volume_size, ebs_volume = info.connection.create_volume(volume_size,
info.host['availabilityZone'], info.host['availabilityZone'],
snapshot=snapshot) snapshot=snapshot)
while info.volume.volume_state() != 'available': while ebs_volume.volume_state() != 'available':
time.sleep(5) time.sleep(5)
info.volume.update() ebs_volume.update()
info.volume.volume = ebs_volume
set_fs_states(info.volume) set_fs_states(info.volume)