This repository has been archived by the owner on Jun 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 142
Add LVM as a disk backend #381
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from bootstrapvz.base.fs.volume import Volume | ||
from bootstrapvz.common.tools import log_check_call | ||
import os | ||
|
||
|
||
class LogicalVolume(Volume): | ||
|
||
def __init__(self, partitionmap): | ||
super(LogicalVolume, self).__init__(partitionmap) | ||
self.vg = '' | ||
self.lv = '' | ||
|
||
def create(self, volumegroup, logicalvolume): | ||
self.vg = volumegroup | ||
self.lv = logicalvolume | ||
image_path = os.path.join(os.sep, 'dev', self.vg, self.lv) | ||
self.fsm.create(image_path=image_path) | ||
|
||
def _before_create(self, e): | ||
self.image_path = e.image_path | ||
lv_size = str(self.size.bytes.get_qty_in('MiB')) | ||
log_check_call(['lvcreate', '--size', '{mib}M'.format(mib=lv_size), | ||
'--name', self.lv, self.vg]) | ||
|
||
def _before_attach(self, e): | ||
log_check_call(['lvchange', '--activate', 'y', self.image_path]) | ||
[self.loop_device_path] = log_check_call(['losetup', '--show', '--find', '--partscan', self.image_path]) | ||
self.device_path = self.loop_device_path | ||
|
||
def _before_detach(self, e): | ||
log_check_call(['losetup', '--detach', self.loop_device_path]) | ||
log_check_call(['lvchange', '--activate', 'n', self.image_path]) | ||
del self.loop_device_path | ||
self.device_path = None | ||
|
||
def delete(self): | ||
log_check_call(['lvremove', '-f', self.image_path]) | ||
del self.image_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
name: debian-lvm-example | ||
provider: | ||
name: kvm | ||
bootstrapper: | ||
workspace: /target | ||
system: | ||
release: jessie | ||
architecture: amd64 | ||
bootloader: grub | ||
charmap: UTF-8 | ||
locale: en_US | ||
timezone: UTC | ||
volume: | ||
backing: lvm | ||
logicalvolume: lvtest | ||
volumegroup: vgtest | ||
partitions: | ||
type: gpt | ||
root: | ||
filesystem: ext4 | ||
size: 1GB | ||
packages: {} | ||
plugins: | ||
root_password: | ||
password: test |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of only supporting this on kvm, you could modify
volume_group
intask_groups.py
to be a function and add the commands there. The same would actually work for the loopback tasks as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which providers do you have in mind ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come to think of it, there might not be any. This is pretty kvm specific, since the volume is kind of tied to the host machine, correct?
I'm ok with merging this if you squash your commits :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commits have been squashed.