mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Generalize VirtualBoxVolume, introduce QEMUVolume
This commit is contained in:
parent
61b5dd2ef0
commit
51041f6aa2
3 changed files with 18 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
||||||
def load_volume(data):
|
def load_volume(data):
|
||||||
from common.fs.loopbackvolume import LoopbackVolume
|
from common.fs.loopbackvolume import LoopbackVolume
|
||||||
from providers.ec2.ebsvolume import EBSVolume
|
from providers.ec2.ebsvolume import EBSVolume
|
||||||
from providers.virtualbox.volume import VirtualBoxVolume
|
from common.fs.virtualdiskimage import VirtualDiskImage
|
||||||
from partitionmaps.gpt import GPTPartitionMap
|
from partitionmaps.gpt import GPTPartitionMap
|
||||||
from partitionmaps.mbr import MBRPartitionMap
|
from partitionmaps.mbr import MBRPartitionMap
|
||||||
from partitionmaps.none import NoPartitions
|
from partitionmaps.none import NoPartitions
|
||||||
|
@ -14,7 +14,7 @@ def load_volume(data):
|
||||||
partition_map = partition_maps.get(data['partitions']['type'])(data['partitions'])
|
partition_map = partition_maps.get(data['partitions']['type'])(data['partitions'])
|
||||||
volume_backings = {'raw': LoopbackVolume,
|
volume_backings = {'raw': LoopbackVolume,
|
||||||
's3': LoopbackVolume,
|
's3': LoopbackVolume,
|
||||||
'vdi': VirtualBoxVolume,
|
'vdi': VirtualDiskImage,
|
||||||
'ebs': EBSVolume
|
'ebs': EBSVolume
|
||||||
}
|
}
|
||||||
return volume_backings.get(data['backing'])(partition_map)
|
return volume_backings.get(data['backing'])(partition_map)
|
||||||
|
|
|
@ -4,13 +4,11 @@ from common.tools import log_check_call
|
||||||
from common.fs import get_partitions
|
from common.fs import get_partitions
|
||||||
|
|
||||||
|
|
||||||
class VirtualBoxVolume(LoopbackVolume):
|
class QEMUVolume(LoopbackVolume):
|
||||||
|
|
||||||
extension = 'vdi'
|
|
||||||
|
|
||||||
def _before_create(self, e):
|
def _before_create(self, e):
|
||||||
self.image_path = e.image_path
|
self.image_path = e.image_path
|
||||||
log_check_call(['/usr/bin/qemu-img', 'create', '-f', 'vdi', self.image_path, str(self.size) + 'M'])
|
log_check_call(['/usr/bin/qemu-img', 'create', '-f', self.qemu_format, self.image_path, str(self.size) + 'M'])
|
||||||
|
|
||||||
def _check_nbd_module(self):
|
def _check_nbd_module(self):
|
||||||
from base.fs.partitionmaps.none import NoPartitions
|
from base.fs.partitionmaps.none import NoPartitions
|
14
common/fs/virtualdiskimage.py
Normal file
14
common/fs/virtualdiskimage.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from common.fs.qemuvolume import QEMUVolume
|
||||||
|
|
||||||
|
|
||||||
|
class VirtualDiskImage(QEMUVolume):
|
||||||
|
|
||||||
|
extension = 'vdi'
|
||||||
|
qemu_format = 'vdi'
|
||||||
|
ovf_uri = None
|
||||||
|
|
||||||
|
def get_uuid(self):
|
||||||
|
import uuid
|
||||||
|
with open(self.image_path) as image:
|
||||||
|
image.seek(392)
|
||||||
|
return uuid.UUID(bytes_le=image.read(16))
|
Loading…
Add table
Reference in a new issue