Include image block device maps in info
In cases for example soft/hard reboot, we were just getting volume and
snapshot block device maps. For block devices with a source type image,
Nova would fall back on a local disk location and fail.
This change allows us to include block devices with a source of an
image, so that we correctly get the right the location of the block
device.
Closes-Bug: #1245719
Change-Id: I1f726293e85183d4b84c05b635a7c606a092992f
(cherry picked from commit 85d0ace169
)
This commit is contained in:
parent
f7cfc1cc6b
commit
dfde60b4bb
|
@ -1500,7 +1500,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||
legacy=False)
|
||||
block_device_mapping = (
|
||||
driver_block_device.convert_volumes(bdms) +
|
||||
driver_block_device.convert_snapshots(bdms))
|
||||
driver_block_device.convert_snapshots(bdms) +
|
||||
driver_block_device.convert_images(bdms))
|
||||
|
||||
if not refresh_conn_info:
|
||||
# if the block_device_mapping has no value in connection_info
|
||||
|
|
|
@ -2192,6 +2192,39 @@ class ComputeTestCase(BaseTestCase):
|
|||
self._test_reboot(False, fail_reboot=True,
|
||||
fail_running=True)
|
||||
|
||||
def test_get_instance_volume_block_device_info_source_image(self):
|
||||
def _fake_get_instance_volume_bdms(context, instance, legacy=True):
|
||||
bdms = [{
|
||||
'id': 3,
|
||||
'volume_id': u'4cbc9e62-6ba0-45dd-b647-934942ead7d6',
|
||||
'instance_uuid': 'fake-instance',
|
||||
'device_name': '/dev/vda',
|
||||
'connection_info': '{"driver_volume_type": "rbd"}',
|
||||
'source_type': 'image',
|
||||
'destination_type': 'volume',
|
||||
'image_id': 'fake-image-id-1',
|
||||
'boot_index': 0
|
||||
}]
|
||||
|
||||
return bdms
|
||||
|
||||
with mock.patch.object(self.compute, '_get_instance_volume_bdms',
|
||||
_fake_get_instance_volume_bdms):
|
||||
block_device_info = (
|
||||
self.compute._get_instance_volume_block_device_info(
|
||||
self.context, self._create_fake_instance())
|
||||
)
|
||||
expected = {
|
||||
'block_device_mapping': [{
|
||||
'connection_info': {
|
||||
'driver_volume_type': 'rbd'
|
||||
},
|
||||
'mount_device': '/dev/vda',
|
||||
'delete_on_termination': None
|
||||
}]
|
||||
}
|
||||
self.assertEqual(block_device_info, expected)
|
||||
|
||||
def test_set_admin_password(self):
|
||||
# Ensure instance can have its admin password set.
|
||||
instance = jsonutils.to_primitive(self._create_fake_instance())
|
||||
|
|
Loading…
Reference in New Issue