mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Prebootstrapped plugin now autocreates a snapshot
of the bootstrapped plugin, if no snapshot ID is provided.
This commit is contained in:
parent
4e2503ad9c
commit
55741b822f
2 changed files with 24 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
|||
from tasks import CreateSnapshot
|
||||
from tasks import CreateVolumeFromSnapshot
|
||||
from providers.ec2.tasks import ebs
|
||||
|
||||
|
@ -5,12 +6,15 @@ from providers.ec2.tasks import ebs
|
|||
def tasks(tasklist, manifest):
|
||||
from providers.ec2.tasks import bootstrap
|
||||
from providers.ec2.tasks import filesystem
|
||||
tasklist.replace(ebs.CreateVolume, CreateVolumeFromSnapshot())
|
||||
tasklist.remove(filesystem.FormatVolume,
|
||||
filesystem.TuneVolumeFS,
|
||||
filesystem.AddXFSProgs,
|
||||
bootstrap.MakeTarball,
|
||||
bootstrap.Bootstrap)
|
||||
if manifest.plugins['prebootstrapped']['snapshot'] == "":
|
||||
tasklist.add(CreateSnapshot())
|
||||
else:
|
||||
tasklist.replace(ebs.CreateVolume, CreateVolumeFromSnapshot())
|
||||
tasklist.remove(filesystem.FormatVolume,
|
||||
filesystem.TuneVolumeFS,
|
||||
filesystem.AddXFSProgs,
|
||||
bootstrap.MakeTarball,
|
||||
bootstrap.Bootstrap)
|
||||
|
||||
|
||||
def rollback_tasks(tasklist, tasks_completed, manifest):
|
||||
|
|
|
@ -2,7 +2,10 @@ from base import Task
|
|||
from common import phases
|
||||
from providers.ec2.tasks import connection
|
||||
from providers.ec2.tasks import ebs
|
||||
from providers.ec2.tasks import bootstrap
|
||||
import time
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CreateVolumeFromSnapshot(Task):
|
||||
|
@ -20,3 +23,14 @@ class CreateVolumeFromSnapshot(Task):
|
|||
while info.volume.volume_state() != 'available':
|
||||
time.sleep(5)
|
||||
info.volume.update()
|
||||
|
||||
|
||||
class CreateSnapshot(ebs.CreateSnapshot):
|
||||
description = 'Creating a snapshot of the bootstrapped volume'
|
||||
phase = phases.os_installation
|
||||
after = [bootstrap.Bootstrap]
|
||||
|
||||
def run(self, info):
|
||||
super(CreateSnapshot, self).run(info)
|
||||
msg = 'A snapshot of the bootstrapped volume was created. ID: {id}'.format(id=info.snapshot.id)
|
||||
log.info(msg)
|
||||
|
|
Loading…
Add table
Reference in a new issue