libvirt: Create correct BDM object type for conn info update

This path needs to use different types for devices with
an image vs. volume source_type.

Validation will fail for image sources if only the volume
type is used.

Closes-Bug: #1411847

Change-Id: I711c34d340e4f87fa29ec604eb534ce6cd357196
This commit is contained in:
Eric Harney 2015-01-21 13:57:50 -05:00
parent fc7603e4e9
commit 4b0fee091f
1 changed files with 7 additions and 1 deletions

View File

@ -1647,7 +1647,13 @@ class LibvirtDriver(driver.ComputeDriver):
def _volume_refresh_connection_info(self, context, instance, volume_id):
bdm = objects.BlockDeviceMapping.get_by_volume_id(context,
volume_id)
driver_bdm = driver_block_device.DriverVolumeBlockDevice(bdm)
if bdm['source_type'] == 'image':
driver_bdm = driver_block_device.DriverImageBlockDevice(bdm)
else:
# source_type = 'volume'
driver_bdm = driver_block_device.DriverVolumeBlockDevice(bdm)
driver_bdm.refresh_connection_info(context, instance,
self._volume_api, self)