mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
SetBootMountDir task in prebootstrapped plugin
This commit is contained in:
parent
854ab4f202
commit
38bcb12c72
2 changed files with 19 additions and 4 deletions
|
@ -2,6 +2,7 @@ from tasks import Snapshot
|
||||||
from tasks import CopyImage
|
from tasks import CopyImage
|
||||||
from tasks import CreateFromSnapshot
|
from tasks import CreateFromSnapshot
|
||||||
from tasks import CreateFromImage
|
from tasks import CreateFromImage
|
||||||
|
from tasks import SetBootMountDir
|
||||||
from providers.ec2.tasks import ebs
|
from providers.ec2.tasks import ebs
|
||||||
from common.tasks import loopback
|
from common.tasks import loopback
|
||||||
from common.tasks import volume
|
from common.tasks import volume
|
||||||
|
@ -23,12 +24,16 @@ def tasks(tasklist, manifest):
|
||||||
if 'snapshot' in settings and settings['snapshot'] is not None:
|
if 'snapshot' in settings and settings['snapshot'] is not None:
|
||||||
tasklist.replace(ebs.Create, CreateFromSnapshot)
|
tasklist.replace(ebs.Create, CreateFromSnapshot)
|
||||||
tasklist.remove(*skip_tasks)
|
tasklist.remove(*skip_tasks)
|
||||||
|
if 'boot' in manifest.volume['partitions']:
|
||||||
|
tasklist.add(SetBootMountDir)
|
||||||
else:
|
else:
|
||||||
tasklist.add(Snapshot)
|
tasklist.add(Snapshot)
|
||||||
else:
|
else:
|
||||||
if 'image' in settings and settings['image'] is not None:
|
if 'image' in settings and settings['image'] is not None:
|
||||||
tasklist.replace(loopback.Create, CreateFromImage)
|
tasklist.replace(loopback.Create, CreateFromImage)
|
||||||
tasklist.remove(*skip_tasks)
|
tasklist.remove(*skip_tasks)
|
||||||
|
if 'boot' in manifest.volume['partitions']:
|
||||||
|
tasklist.add(SetBootMountDir)
|
||||||
else:
|
else:
|
||||||
tasklist.add(CopyImage)
|
tasklist.add(CopyImage)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@ from common import phases
|
||||||
from providers.ec2.tasks import ebs
|
from providers.ec2.tasks import ebs
|
||||||
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 shutil import copyfile
|
||||||
|
import os.path
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -43,8 +46,6 @@ class CopyImage(Task):
|
||||||
after = [bootstrap.Bootstrap]
|
after = [bootstrap.Bootstrap]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
import os.path
|
|
||||||
from shutil import copyfile
|
|
||||||
loopback_backup_name = 'volume-{id:x}.{ext}.backup'.format(id=info.run_id, ext=info.volume.extension)
|
loopback_backup_name = 'volume-{id:x}.{ext}.backup'.format(id=info.run_id, ext=info.volume.extension)
|
||||||
destination = os.path.join(info.manifest.bootstrapper['workspace'], loopback_backup_name)
|
destination = os.path.join(info.manifest.bootstrapper['workspace'], loopback_backup_name)
|
||||||
copyfile(info.volume.image_path, destination)
|
copyfile(info.volume.image_path, destination)
|
||||||
|
@ -58,14 +59,23 @@ class CreateFromImage(Task):
|
||||||
before = [volume.Attach]
|
before = [volume.Attach]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
import os.path
|
|
||||||
from shutil import copyfile
|
|
||||||
info.volume.image_path = os.path.join(info.workspace, 'volume.{ext}'.format(ext=info.volume.extension))
|
info.volume.image_path = os.path.join(info.workspace, 'volume.{ext}'.format(ext=info.volume.extension))
|
||||||
loopback_backup_path = info.manifest.plugins['prebootstrapped']['image']
|
loopback_backup_path = info.manifest.plugins['prebootstrapped']['image']
|
||||||
copyfile(loopback_backup_path, info.volume.image_path)
|
copyfile(loopback_backup_path, info.volume.image_path)
|
||||||
|
|
||||||
set_fs_states(info.volume)
|
set_fs_states(info.volume)
|
||||||
|
|
||||||
|
|
||||||
|
class SetBootMountDir(Task):
|
||||||
|
description = 'Setting mountpoint for the boot partition'
|
||||||
|
phase = phases.volume_mounting
|
||||||
|
after = [filesystem.MountRoot]
|
||||||
|
before = [filesystem.MountBoot]
|
||||||
|
|
||||||
|
def run(self, info):
|
||||||
|
info.boot_dir = os.path.join(info.root, 'boot')
|
||||||
|
|
||||||
|
|
||||||
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