bootstrap-vz/plugins/prebootstrapped/tasks.py

24 lines
761 B
Python
Raw Normal View History

from base import Task
from common import phases
2013-06-30 23:56:09 +02:00
from providers.ec2.tasks import connection
from providers.ec2.tasks import ebs
import time
class CreateVolumeFromSnapshot(Task):
phase = phases.volume_creation
2013-06-30 23:56:09 +02:00
after = [connection.Connect]
before = [ebs.AttachVolume]
2013-06-30 23:56:09 +02:00
description = 'Creating EBS volume from a snapshot'
def run(self, info):
volume_size = int(info.manifest.volume['size']/1024)
2013-06-30 23:56:09 +02:00
snapshot = info.manifest.plugins['prebootstrapped']['snapshot']
info.volume = info.connection.create_volume(volume_size,
info.host['availabilityZone'],
2013-06-30 23:56:09 +02:00
snapshot=snapshot)
while info.volume.volume_state() != 'available':
time.sleep(5)
info.volume.update()