mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-08 01:40:31 +00:00
prebootstrapped: Support folder backing (for docker)
This commit is contained in:
parent
2ffc4dd6c3
commit
df7df19fb9
4 changed files with 51 additions and 12 deletions
|
@ -21,6 +21,8 @@ Settings
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
- ``snapshot``: ID of the EBS snapshot to use. This setting only works
|
- ``snapshot``: ID of the EBS snapshot to use. This setting only works
|
||||||
with EBS backed EC2 configurations.
|
with the volume backing ``ebs``.
|
||||||
- ``image``: Path to the loopbackvolume snapshot. This setting works
|
- ``image``: Path to the loopbackvolume snapshot. This setting works
|
||||||
with all configurable volume backings except EBS.
|
with the volume backings ``raw``, ``s3``, ``vdi``, ``vmdk``
|
||||||
|
- ``folder``: Path to the folder copy. This setting works
|
||||||
|
with the volume backing ``folder``
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
from tasks import Snapshot
|
import tasks
|
||||||
from tasks import CopyImage
|
|
||||||
from tasks import CreateFromSnapshot
|
|
||||||
from tasks import CreateFromImage
|
|
||||||
from bootstrapvz.providers.ec2.tasks import ebs
|
from bootstrapvz.providers.ec2.tasks import ebs
|
||||||
from bootstrapvz.providers.virtualbox.tasks import guest_additions
|
from bootstrapvz.providers.virtualbox.tasks import guest_additions
|
||||||
from bootstrapvz.common.tasks import loopback
|
from bootstrapvz.common.tasks import loopback
|
||||||
from bootstrapvz.common.tasks import volume
|
from bootstrapvz.common.tasks import volume
|
||||||
|
from bootstrapvz.common.tasks import folder
|
||||||
from bootstrapvz.common.tasks import locale
|
from bootstrapvz.common.tasks import locale
|
||||||
from bootstrapvz.common.tasks import apt
|
from bootstrapvz.common.tasks import apt
|
||||||
from bootstrapvz.common.tasks import bootstrap
|
from bootstrapvz.common.tasks import bootstrap
|
||||||
|
@ -23,6 +21,7 @@ def resolve_tasks(taskset, manifest):
|
||||||
settings = manifest.plugins['prebootstrapped']
|
settings = manifest.plugins['prebootstrapped']
|
||||||
skip_tasks = [ebs.Create,
|
skip_tasks = [ebs.Create,
|
||||||
loopback.Create,
|
loopback.Create,
|
||||||
|
folder.Create,
|
||||||
|
|
||||||
filesystem.Format,
|
filesystem.Format,
|
||||||
partitioning.PartitionVolume,
|
partitioning.PartitionVolume,
|
||||||
|
@ -38,20 +37,28 @@ def resolve_tasks(taskset, manifest):
|
||||||
]
|
]
|
||||||
if manifest.volume['backing'] == 'ebs':
|
if manifest.volume['backing'] == 'ebs':
|
||||||
if settings.get('snapshot', None) is not None:
|
if settings.get('snapshot', None) is not None:
|
||||||
taskset.add(CreateFromSnapshot)
|
taskset.add(tasks.CreateFromSnapshot)
|
||||||
[taskset.discard(task) for task in skip_tasks]
|
[taskset.discard(task) for task in skip_tasks]
|
||||||
else:
|
else:
|
||||||
taskset.add(Snapshot)
|
taskset.add(tasks.Snapshot)
|
||||||
|
elif manifest.volume['backing'] == 'folder':
|
||||||
|
if settings.get('folder', None) is not None:
|
||||||
|
taskset.add(tasks.CreateFromFolder)
|
||||||
|
[taskset.discard(task) for task in skip_tasks]
|
||||||
|
else:
|
||||||
|
taskset.add(tasks.CopyFolder)
|
||||||
else:
|
else:
|
||||||
if settings.get('image', None) is not None:
|
if settings.get('image', None) is not None:
|
||||||
taskset.add(CreateFromImage)
|
taskset.add(tasks.CreateFromImage)
|
||||||
[taskset.discard(task) for task in skip_tasks]
|
[taskset.discard(task) for task in skip_tasks]
|
||||||
else:
|
else:
|
||||||
taskset.add(CopyImage)
|
taskset.add(tasks.CopyImage)
|
||||||
|
|
||||||
|
|
||||||
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
|
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
|
||||||
if manifest.volume['backing'] == 'ebs':
|
if manifest.volume['backing'] == 'ebs':
|
||||||
counter_task(taskset, CreateFromSnapshot, volume.Delete)
|
counter_task(taskset, tasks.CreateFromSnapshot, volume.Delete)
|
||||||
|
elif manifest.volume['backing'] == 'folder':
|
||||||
|
counter_task(taskset, tasks.CreateFromFolder, folder.Delete)
|
||||||
else:
|
else:
|
||||||
counter_task(taskset, CreateFromImage, volume.Delete)
|
counter_task(taskset, tasks.CreateFromImage, volume.Delete)
|
||||||
|
|
|
@ -14,6 +14,7 @@ properties:
|
||||||
- s3
|
- s3
|
||||||
- vdi
|
- vdi
|
||||||
- vmdk
|
- vmdk
|
||||||
|
- folder
|
||||||
required: [backing]
|
required: [backing]
|
||||||
plugins:
|
plugins:
|
||||||
type: object
|
type: object
|
||||||
|
@ -23,4 +24,5 @@ properties:
|
||||||
properties:
|
properties:
|
||||||
image: {type: string}
|
image: {type: string}
|
||||||
snapshot: {type: string}
|
snapshot: {type: string}
|
||||||
|
folder: {type: string}
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
|
|
@ -5,6 +5,7 @@ from bootstrapvz.common.tasks import packages
|
||||||
from bootstrapvz.providers.virtualbox.tasks import guest_additions
|
from bootstrapvz.providers.virtualbox.tasks import guest_additions
|
||||||
from bootstrapvz.providers.ec2.tasks import ebs
|
from bootstrapvz.providers.ec2.tasks import ebs
|
||||||
from bootstrapvz.common.fs import unmounted
|
from bootstrapvz.common.fs import unmounted
|
||||||
|
from bootstrapvz.common.tools import log_check_call
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
import os.path
|
import os.path
|
||||||
import time
|
import time
|
||||||
|
@ -75,6 +76,33 @@ class CreateFromImage(Task):
|
||||||
set_fs_states(info.volume)
|
set_fs_states(info.volume)
|
||||||
|
|
||||||
|
|
||||||
|
class CopyFolder(Task):
|
||||||
|
description = 'Creating a copy of the bootstrap folder'
|
||||||
|
phase = phases.package_installation
|
||||||
|
predecessors = [packages.InstallPackages, guest_additions.InstallGuestAdditions]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def run(cls, info):
|
||||||
|
folder_backup_name = '{id}.{ext}.backup'.format(id=info.run_id, ext=info.volume.extension)
|
||||||
|
destination = os.path.join(info.manifest.bootstrapper['workspace'], folder_backup_name)
|
||||||
|
log_check_call(['cp', '-a', info.volume.path, destination])
|
||||||
|
msg = 'A copy of the bootstrapped volume was created. Path: ' + destination
|
||||||
|
log.info(msg)
|
||||||
|
|
||||||
|
|
||||||
|
class CreateFromFolder(Task):
|
||||||
|
description = 'Creating bootstrap folder from a copy'
|
||||||
|
phase = phases.volume_creation
|
||||||
|
successors = [volume.Attach]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def run(cls, info):
|
||||||
|
info.root = os.path.join(info.workspace, 'root')
|
||||||
|
log_check_call(['cp', '-a', info.manifest.plugins['prebootstrapped']['folder'], info.root])
|
||||||
|
info.volume.path = info.root
|
||||||
|
info.volume.fsm.current = 'attached'
|
||||||
|
|
||||||
|
|
||||||
def set_fs_states(volume):
|
def set_fs_states(volume):
|
||||||
volume.fsm.current = 'detached'
|
volume.fsm.current = 'detached'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue