diff options
author | zhangbailin <zhangbailin@inspur.com> | 2018-09-26 23:04:46 -0400 |
---|---|---|
committer | Matt Riedemann <mriedem.os@gmail.com> | 2018-10-11 16:04:53 -0400 |
commit | 686dbc3640f12a85f450ffa75c2a152e355d0b79 (patch) | |
tree | 5c707dc0eb93634973eae9c6f5155f059781ee1e /nova/tests/unit/volume | |
parent | 88766d33a39e9b628f251b49d83c52e163dd0a58 (diff) | |
download | nova-686dbc3640f12a85f450ffa75c2a152e355d0b79.tar.gz |
Add compute API validation for when a volume_type is requested
This adds validation in the compute API for when a
block_device_mapping_v2 request specifies a volume_type. Note that
this is all noop code right now since users cannot specify that field in
the API until the microversion is added which enables that feature.
In other words, this is just plumbing.
Part of bp boot-instance-specific-storage-backend
Change-Id: I45bd42908d44a0f05e1231febab926b23232b57b
Diffstat (limited to 'nova/tests/unit/volume')
-rw-r--r-- | nova/tests/unit/volume/test_cinder.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/nova/tests/unit/volume/test_cinder.py b/nova/tests/unit/volume/test_cinder.py index 47f500615f..1451de952f 100644 --- a/nova/tests/unit/volume/test_cinder.py +++ b/nova/tests/unit/volume/test_cinder.py @@ -70,6 +70,12 @@ class FakeSnapshot(object): self.project_id = 'fake_project' +class FakeVolumeType(object): + def __init__(self, volume_type_name, volume_type_id): + self.id = volume_type_id + self.name = volume_type_name + + class FakeAttachment(object): def __init__(self): @@ -896,6 +902,27 @@ class CinderApiTestCase(test.NoDBTestCase): 'snapshot_id', {'status': 'error', 'progress': '90%'}) @mock.patch('nova.volume.cinder.cinderclient') + def test_get_all_volume_types(self, mock_cinderclient): + volume_type1 = FakeVolumeType('lvm_1', 'volume_type_id1') + volume_type2 = FakeVolumeType('lvm_2', 'volume_type_id2') + volume_type_list = [volume_type1, volume_type2] + + mock_volume_types = mock.MagicMock() + mock_cinderclient.return_value = mock.MagicMock( + volume_types=mock_volume_types) + mock_volume_types.list.return_value = volume_type_list + + volume_types = self.api.get_all_volume_types(self.ctx) + self.assertEqual(2, len(volume_types)) + self.assertEqual(['volume_type_id1', 'volume_type_id2'], + [vol_type['id'] for vol_type in volume_types]) + self.assertEqual(['lvm_1', 'lvm_2'], + [vol_type['name'] for vol_type in volume_types]) + + mock_cinderclient.assert_called_once_with(self.ctx) + mock_volume_types.list.assert_called_once_with() + + @mock.patch('nova.volume.cinder.cinderclient') def test_get_volume_encryption_metadata(self, mock_cinderclient): mock_volumes = mock.MagicMock() mock_cinderclient.return_value = mock.MagicMock(volumes=mock_volumes) |