summaryrefslogtreecommitdiff
path: root/nova/virt/block_device.py
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2018-01-31 19:06:46 -0500
committerMatt Riedemann <mriedem.os@gmail.com>2018-02-02 15:00:30 -0500
commitcafe3d066ef7021c18961d4b239a10f61db23f2d (patch)
tree9dbc12232f6e20749dc9b6450799b0f19411b2b2 /nova/virt/block_device.py
parentc1442d3c8cf9ab8a3cc6fe7e169c71e39abe1faf (diff)
downloadnova-cafe3d066ef7021c18961d4b239a10f61db23f2d.tar.gz
libvirt: fix native luks encryption failure to find volume_id
Not all volume types put a 'volume_id' entry in the connection_info['data'] dict. This change uses a new utility method to look up the volume_id in the connection_info data dict and if not found there, uses the 'serial' value from the connection_info, which we know at least gets set when the DriverVolumeBlockDevice code attaches the volume. This also has to update pre_live_migration since the connection_info dict doesn't have a 'volume_id' key in it. It's unclear what this code was expecting, or if it ever really worked, but since an attached volume represented by a BlockDeviceMapping here has a volume_id attribute, we can just use that. As that code path was never tested, this updates related unit tests and refactors the tests to actually use the type of DriverVolumeBlockDevice objects that the ComputeManager would be sending down to the driver pre_live_migration method. The hard-to-read squashed dicts in the tests are also re-formatted so a human can actually read them. Change-Id: Ie02d298cd92d5b5ebcbbcd2b0e8be01f197bfafb Closes-Bug: #1746609
Diffstat (limited to 'nova/virt/block_device.py')
-rw-r--r--nova/virt/block_device.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/nova/virt/block_device.py b/nova/virt/block_device.py
index ab5cd09f69..4100928528 100644
--- a/nova/virt/block_device.py
+++ b/nova/virt/block_device.py
@@ -880,3 +880,13 @@ def is_block_device_mapping(bdm):
return (bdm.source_type in ('image', 'volume', 'snapshot', 'blank')
and bdm.destination_type == 'volume'
and is_implemented(bdm))
+
+
+def get_volume_id(connection_info):
+ if connection_info:
+ # Check for volume_id in 'data' and if not there, fallback to
+ # the 'serial' that the DriverVolumeBlockDevice adds during attach.
+ volume_id = connection_info.get('data', {}).get('volume_id')
+ if not volume_id:
+ volume_id = connection_info.get('serial')
+ return volume_id