Skip to content

Commit

Permalink
Include image block device maps in info
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Thingee committed Nov 20, 2013
1 parent 84bddb0 commit 85d0ace
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nova/compute/manager.py
Expand Up @@ -1529,7 +1529,8 @@ def _get_instance_volume_block_device_info(self, context, instance,
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
Expand Down
33 changes: 33 additions & 0 deletions nova/tests/compute/test_compute.py
Expand Up @@ -2191,6 +2191,39 @@ def test_reboot_fail_running(self):
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())
Expand Down

0 comments on commit 85d0ace

Please sign in to comment.