bootstrap-vz/bootstrapvz/providers/kvm/__init__.py
Brendan Harley 511a44f72e Add LVM as a disk backend
Enables the use of Logical Volumes as disk backends.

It uses an existing volume group and has no support for creating a new one.
It will not override an existing logical volume and fail gracefully.

The lv is created, activated and then mounted as a loop device.
The boostraping process is then launched on the loop device.
Once the process is completed, the lv is unmounted and desactivated.

The created lv will be deleted should the boostraping process fail.

The lv must be activated before use.

A manifest has been included for testing purposes.
2017-06-08 17:05:48 +02:00

37 lines
1.3 KiB
Python

from bootstrapvz.common import task_groups
import tasks.packages
from bootstrapvz.common.tasks import image, loopback, initd, ssh, logicalvolume
def validate_manifest(data, validator, error):
from bootstrapvz.common.tools import rel_path
validator(data, rel_path(__file__, 'manifest-schema.yml'))
def resolve_tasks(taskset, manifest):
taskset.update(task_groups.get_standard_groups(manifest))
taskset.update([tasks.packages.DefaultPackages,
initd.InstallInitScripts,
ssh.AddOpenSSHPackage,
ssh.ShredHostkeys,
ssh.AddSSHKeyGeneration,
])
if manifest.volume.get('logicalvolume', []):
taskset.update([logicalvolume.AddRequiredCommands,
logicalvolume.Create,
])
else:
taskset.update([loopback.AddRequiredCommands,
loopback.Create,
image.MoveImage,
])
if manifest.provider.get('virtio', []):
from tasks import virtio
taskset.update([virtio.VirtIO])
def resolve_rollback_tasks(taskset, manifest, completed, counter_task):
taskset.update(task_groups.get_standard_rollback_tasks(completed))
counter_task(taskset, logicalvolume.Create, logicalvolume.Delete)