Merge "Include image block device maps in info" into stable/havana

This commit is contained in:
Jenkins 2013-12-17 16:37:29 +00:00 committed by Gerrit Code Review
commit 251a9403eb
2 changed files with 35 additions and 1 deletions

View File

@ -1510,7 +1510,8 @@ class ComputeManager(manager.SchedulerDependentManager):
legacy=False) legacy=False)
block_device_mapping = ( block_device_mapping = (
driver_block_device.convert_volumes(bdms) + 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 not refresh_conn_info:
# if the block_device_mapping has no value in connection_info # if the block_device_mapping has no value in connection_info

View File

@ -2192,6 +2192,39 @@ class ComputeTestCase(BaseTestCase):
self._test_reboot(False, fail_reboot=True, self._test_reboot(False, fail_reboot=True,
fail_running=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): def test_set_admin_password(self):
# Ensure instance can have its admin password set. # Ensure instance can have its admin password set.
instance = jsonutils.to_primitive(self._create_fake_instance()) instance = jsonutils.to_primitive(self._create_fake_instance())