mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00

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.
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import bootstrapvz.common.tasks.host as host
|
|
import bootstrapvz.common.tasks.volume as volume
|
|
from bootstrapvz.base import Task
|
|
from bootstrapvz.common import phases
|
|
|
|
|
|
class AddRequiredCommands(Task):
|
|
description = 'Adding commands required for creating and mounting logical volumes'
|
|
phase = phases.validation
|
|
successors = [host.CheckExternalCommands]
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
from bootstrapvz.common.fs.logicalvolume import LogicalVolume
|
|
if type(info.volume) is LogicalVolume:
|
|
info.host_dependencies['lvcreate'] = 'lvm2'
|
|
info.host_dependencies['losetup'] = 'mount'
|
|
|
|
|
|
class Create(Task):
|
|
description = 'Creating a Logical volume'
|
|
phase = phases.volume_creation
|
|
successors = [volume.Attach]
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
info.volume.create(volumegroup=info.manifest.volume['volumegroup'],
|
|
logicalvolume=info.manifest.volume['logicalvolume'])
|
|
|
|
|
|
class Delete(Task):
|
|
description = 'Deleting a Logical volume'
|
|
phase = phases.cleaning
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
info.volume.delete()
|