Skip to content

Commit 7416024

Browse files
lyarwoodnotartom
authored andcommitted
fake: Ensure need_legacy_block_device_info returns False
The legacy block_device_info format has not been used for a while in the virt drivers and the Fake virt drivers shouldn't be using it anymore. Some compute tests have been updated as they were previously asserting the legacy format incorrectly. TODOs are also left to remove support for the legacy format in a follow up change. Change-Id: I066fb5617bae944a03273049117fc2b5bf329283 (cherry picked from commit d102b75)
1 parent 6e9ad14 commit 7416024

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

nova/tests/unit/compute/test_compute.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,6 +3194,7 @@ def test_get_instance_block_device_info_source_image(self):
31943194
'image_id': uuids.image,
31953195
'boot_index': 0
31963196
})])
3197+
driver_bdms = driver_block_device.convert_all_volumes(*bdms)
31973198

31983199
with (mock.patch.object(
31993200
objects.BlockDeviceMappingList,
@@ -3208,13 +3209,7 @@ def test_get_instance_block_device_info_source_image(self):
32083209
'swap': None,
32093210
'ephemerals': [],
32103211
'root_device_name': None,
3211-
'block_device_mapping': [{
3212-
'connection_info': {
3213-
'driver_volume_type': 'rbd'
3214-
},
3215-
'mount_device': '/dev/vda',
3216-
'delete_on_termination': False
3217-
}]
3212+
'block_device_mapping': driver_bdms
32183213
}
32193214
self.assertTrue(mock_get_by_instance.called)
32203215
self.assertEqual(block_device_info, expected)
@@ -3229,6 +3224,8 @@ def test_get_instance_block_device_info_passed_bdms(self):
32293224
'source_type': 'volume',
32303225
'destination_type': 'volume'})
32313226
])
3227+
driver_bdms = driver_block_device.convert_all_volumes(*bdms)
3228+
32323229
with (mock.patch.object(
32333230
objects.BlockDeviceMappingList,
32343231
'get_by_instance_uuid')) as mock_get_by_instance:
@@ -3240,13 +3237,7 @@ def test_get_instance_block_device_info_passed_bdms(self):
32403237
'swap': None,
32413238
'ephemerals': [],
32423239
'root_device_name': None,
3243-
'block_device_mapping': [{
3244-
'connection_info': {
3245-
'driver_volume_type': 'rbd'
3246-
},
3247-
'mount_device': '/dev/vdd',
3248-
'delete_on_termination': False
3249-
}]
3240+
'block_device_mapping': driver_bdms
32503241
}
32513242
self.assertFalse(mock_get_by_instance.called)
32523243
self.assertEqual(block_device_info, expected)
@@ -3302,11 +3293,27 @@ def test_get_instance_block_device_info_swap_and_ephemerals(self):
33023293
'get_by_instance_uuid', return_value=bdms)
33033294
) as mock_get_by_instance_uuid:
33043295
expected_block_device_info = {
3305-
'swap': {'device_name': '/dev/vdd', 'swap_size': 1},
3306-
'ephemerals': [{'device_name': '/dev/vdb', 'num': 0, 'size': 1,
3307-
'virtual_name': 'ephemeral0'},
3308-
{'device_name': '/dev/vdc', 'num': 1, 'size': 2,
3309-
'virtual_name': 'ephemeral1'}],
3296+
'swap': {
3297+
'device_name': '/dev/vdd',
3298+
'swap_size': 1,
3299+
'disk_bus': 'virtio'
3300+
},
3301+
'ephemerals': [
3302+
{
3303+
'device_name': '/dev/vdb',
3304+
'device_type': 'disk',
3305+
'disk_bus': 'virtio',
3306+
'guest_format': None,
3307+
'size': 1
3308+
},
3309+
{
3310+
'device_name': '/dev/vdc',
3311+
'device_type': 'disk',
3312+
'disk_bus': 'virtio',
3313+
'guest_format': None,
3314+
'size': 2
3315+
}
3316+
],
33103317
'block_device_mapping': [],
33113318
'root_device_name': None
33123319
}

nova/virt/driver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,7 @@ def delete_instance_files(self, instance):
16171617
"""
16181618
return True
16191619

1620+
# TODO(lyarwood): This is no longer used and should be removed.
16201621
@property
16211622
def need_legacy_block_device_info(self):
16221623
"""Tell the caller if the driver requires legacy block device info.

nova/virt/fake.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,10 @@ def quiesce(self, context, instance, image_meta):
654654
def unquiesce(self, context, instance, image_meta):
655655
pass
656656

657+
@property
658+
def need_legacy_block_device_info(self):
659+
return False
660+
657661

658662
class FakeVirtAPI(virtapi.VirtAPI):
659663
@contextlib.contextmanager

0 commit comments

Comments
 (0)