2013-09-15 13:19:45 +02:00
|
|
|
|
|
|
|
|
2014-01-19 01:02:29 +01:00
|
|
|
def load_volume(data, bootloader):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""Instantiates a volume that corresponds to the data in the manifest
|
|
|
|
|
2014-05-04 19:31:53 +02:00
|
|
|
:param dict data: The 'volume' section from the manifest
|
|
|
|
:param str bootloader: Name of the bootloader the system will boot with
|
|
|
|
|
|
|
|
:return: The volume that represents all information pertaining to the volume we bootstrap on.
|
|
|
|
:rtype: Volume
|
2014-03-23 16:04:03 +01:00
|
|
|
"""
|
|
|
|
# Create a mapping between valid partition maps in the manifest and their corresponding classes
|
2013-09-18 00:46:58 +02:00
|
|
|
from partitionmaps.gpt import GPTPartitionMap
|
2014-01-18 21:23:54 +00:00
|
|
|
from partitionmaps.msdos import MSDOSPartitionMap
|
2013-09-18 00:46:58 +02:00
|
|
|
from partitionmaps.none import NoPartitions
|
2013-09-15 13:19:45 +02:00
|
|
|
partition_maps = {'none': NoPartitions,
|
2013-09-18 00:46:58 +02:00
|
|
|
'gpt': GPTPartitionMap,
|
2014-01-18 21:23:54 +00:00
|
|
|
'msdos': MSDOSPartitionMap,
|
2013-09-15 13:19:45 +02:00
|
|
|
}
|
2014-03-23 16:04:03 +01:00
|
|
|
# Instantiate the partition map
|
2014-01-19 01:02:29 +01:00
|
|
|
partition_map = partition_maps.get(data['partitions']['type'])(data['partitions'], bootloader)
|
2014-04-07 21:45:45 +02:00
|
|
|
|
2014-03-23 16:04:03 +01:00
|
|
|
# Create a mapping between valid volume backings in the manifest and their corresponding classes
|
2014-04-07 21:45:45 +02:00
|
|
|
from bootstrapvz.common.fs.loopbackvolume import LoopbackVolume
|
|
|
|
from bootstrapvz.providers.ec2.ebsvolume import EBSVolume
|
|
|
|
from bootstrapvz.common.fs.virtualdiskimage import VirtualDiskImage
|
|
|
|
from bootstrapvz.common.fs.virtualmachinedisk import VirtualMachineDisk
|
2013-09-15 13:19:45 +02:00
|
|
|
volume_backings = {'raw': LoopbackVolume,
|
2013-10-27 12:55:03 +01:00
|
|
|
's3': LoopbackVolume,
|
2013-12-28 14:01:34 +01:00
|
|
|
'vdi': VirtualDiskImage,
|
2013-12-28 14:02:28 +01:00
|
|
|
'vmdk': VirtualMachineDisk,
|
2013-09-15 13:19:45 +02:00
|
|
|
'ebs': EBSVolume
|
|
|
|
}
|
2014-04-27 11:05:53 -03:00
|
|
|
# Create the volume with the partition map as an argument
|
2013-09-15 13:19:45 +02:00
|
|
|
return volume_backings.get(data['backing'])(partition_map)
|