summaryrefslogtreecommitdiffstats
path: root/nova/block_device.py
diff options
context:
space:
mode:
authorNikola Dipanov <ndipanov@redhat.com>2013-05-15 16:00:05 +0200
committerChris Behrens <cbehrens@codestud.com>2013-06-10 23:10:39 +0000
commit41eb083d228f159e8d4e566148db5994ad49143c (patch)
tree41f8828730de39290c2b03f5fe1e08e691580caa /nova/block_device.py
parent0d5fb06b39e8244429be72f05e2066d24572dc2e (diff)
downloadnova-41eb083d228f159e8d4e566148db5994ad49143c.tar.gz
nova-41eb083d228f159e8d4e566148db5994ad49143c.tar.xz
nova-41eb083d228f159e8d4e566148db5994ad49143c.zip
Create an image BDM for every instance
This patch makes every boot create a block device mapping if the instance was started with an image. These block devices are not used anywhere at the moment but will be used in the future as part of a more flexible block device API. This patch also makes sure they are deleted once the instance is deleted as well. Change-Id: Ia89d531be71c460f1f82fcfce34b270639a23061 blueprint: improve-block-device-handling
Diffstat (limited to 'nova/block_device.py')
-rw-r--r--nova/block_device.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/nova/block_device.py b/nova/block_device.py
index 1094ef3ae..746fd6bb4 100644
--- a/nova/block_device.py
+++ b/nova/block_device.py
@@ -166,6 +166,21 @@ def is_safe_for_update(block_device_dict):
bdm_db_only_fields)
+def create_image_bdm(image_ref, boot_index=0):
+ """Create a block device dict based on the image_ref.
+
+ This is useful in the API layer to keep the compatibility
+ with having an image_ref as a field in the instance requests
+ """
+ return BlockDeviceDict(
+ {'source_type': 'image',
+ 'image_id': image_ref,
+ 'delete_on_termination': True,
+ 'boot_index': boot_index,
+ 'device_type': 'disk',
+ 'destination_type': 'local'})
+
+
def legacy_mapping(block_device_mapping):
"""Transform a list of block devices of an instance back to the
legacy data format."""