summaryrefslogtreecommitdiff
path: root/nova/block_device.py
diff options
context:
space:
mode:
authorNikola Dipanov <ndipanov@redhat.com>2013-08-14 20:58:07 +0200
committerNikola Dipanov <ndipanov@redhat.com>2013-09-05 10:02:00 +0200
commitf9f247ef42c690bf1bd1ae65135c6e7fbd0d3c8c (patch)
treec5fb659b69b128de667e901ea479a2d8bea97b1f /nova/block_device.py
parent3b1f7c55c10eec9d438a7d147aba1124b5ff9452 (diff)
downloadnova-f9f247ef42c690bf1bd1ae65135c6e7fbd0d3c8c.tar.gz
Enable libvirt driver to use the new BDM format
This patch makes the necessary changes in the libvirt driver to enable it to use some of the features of the new block device mapping format. After this patch it will be possible to set the bus, and device_type per block device, and libvirt driver will honor these when spawning an instance (note that attaching a volume still does not use the new data format). It utilizes some of the existing code in the blockinfo module to be able to default device names (it does so by overriding the methods introduced in I84541f8ff6e1b5978734e5def69946d014c66fdf), and also assign default values to fields like device_type and disk_bus if it is not provided or if it is bogus. As this implies the driver changing the block devices in the database, a new virtapi method block_device_mapping_update is added to accommodate this. Some of the libvirt specific code paths in the general defaulting function in compute utils have been removed as they are not needed since the driver now takes care of this. Further to that, this patch modifies some of the code paths in the libvirt driver that use the block device info directly (and not through the blockinfo module) to be aware of the new format. Due to very nicely factored code - there were only a few instances of this in the driver itself. It also overrides the libvirt driver's need_legacy_block_device_info method to tell the compute manager to feed it the new format when needed. This patch concludes the blueprint: improve-block-device-handling Change-Id: I8efd6af6706a097fb540e040a86ccbeaf131631f
Diffstat (limited to 'nova/block_device.py')
-rw-r--r--nova/block_device.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/nova/block_device.py b/nova/block_device.py
index 9636e81f84..1f0ba62ccf 100644
--- a/nova/block_device.py
+++ b/nova/block_device.py
@@ -406,6 +406,11 @@ def strip_dev(device_name):
return _dev.sub('', device_name) if device_name else device_name
+def prepend_dev(device_name):
+ """Make sure there is a leading '/dev/'."""
+ return device_name and '/dev/' + strip_dev(device_name)
+
+
_pref = re.compile('^((x?v|s)d)')