diff --git a/doc/api_samples/os-volumes/v2.49/attach-volume-to-server-resp.json b/doc/api_samples/os-volumes/v2.49/attach-volume-to-server-resp.json index 5f610bcaebea..df5b887e2186 100644 --- a/doc/api_samples/os-volumes/v2.49/attach-volume-to-server-resp.json +++ b/doc/api_samples/os-volumes/v2.49/attach-volume-to-server-resp.json @@ -1,8 +1,8 @@ { "volumeAttachment": { - "device": "/dev/sdb", + "device": "/dev/vdd", "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", - "serverId": "84ffbfa0-daf4-4e23-bf4b-dc532c459d4e", + "serverId": "189dc814-35bc-428b-bba4-8d5ac0d1e087", "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" } -} +} \ No newline at end of file diff --git a/doc/api_samples/os-volumes/v2.49/list-volume-attachments-resp.json b/doc/api_samples/os-volumes/v2.49/list-volume-attachments-resp.json new file mode 100644 index 000000000000..01623c372335 --- /dev/null +++ b/doc/api_samples/os-volumes/v2.49/list-volume-attachments-resp.json @@ -0,0 +1,16 @@ +{ + "volumeAttachments": [ + { + "device": "/dev/sdd", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", + "serverId": "4bcb3ae6-68aa-4e89-aac3-97b3dac2f714", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" + }, + { + "device": "/dev/sdc", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f804", + "serverId": "4bcb3ae6-68aa-4e89-aac3-97b3dac2f714", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804" + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/os-volumes/v2.49/update-volume-req.json b/doc/api_samples/os-volumes/v2.49/update-volume-req.json new file mode 100644 index 000000000000..bba735eec834 --- /dev/null +++ b/doc/api_samples/os-volumes/v2.49/update-volume-req.json @@ -0,0 +1,5 @@ +{ + "volumeAttachment": { + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f805" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-volumes/v2.49/volume-attachment-detail-resp.json b/doc/api_samples/os-volumes/v2.49/volume-attachment-detail-resp.json new file mode 100644 index 000000000000..9e483ea66030 --- /dev/null +++ b/doc/api_samples/os-volumes/v2.49/volume-attachment-detail-resp.json @@ -0,0 +1,8 @@ +{ + "volumeAttachment": { + "device": "/dev/sdd", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", + "serverId": "3dc0a2a6-e1bb-4643-8b6f-c146684d676d", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" + } +} \ No newline at end of file diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-volumes/v2.49/list-volume-attachments-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-volumes/v2.49/list-volume-attachments-resp.json.tpl new file mode 100644 index 000000000000..6c1da07ef6f9 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-volumes/v2.49/list-volume-attachments-resp.json.tpl @@ -0,0 +1,16 @@ +{ + "volumeAttachments": [ + { + "device": "/dev/sdd", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", + "serverId": "%(uuid)s", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" + }, + { + "device": "/dev/sdc", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f804", + "serverId": "%(uuid)s", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804" + } + ] +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-volumes/v2.49/update-volume-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-volumes/v2.49/update-volume-req.json.tpl new file mode 100644 index 000000000000..41411472ab09 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-volumes/v2.49/update-volume-req.json.tpl @@ -0,0 +1,5 @@ +{ + "volumeAttachment": { + "volumeId": "%(volume_id)s" + } +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-volumes/v2.49/volume-attachment-detail-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-volumes/v2.49/volume-attachment-detail-resp.json.tpl new file mode 100644 index 000000000000..86099eeb8718 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-volumes/v2.49/volume-attachment-detail-resp.json.tpl @@ -0,0 +1,8 @@ +{ + "volumeAttachment": { + "device": "/dev/sdd", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", + "serverId": "%(uuid)s", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" + } +} diff --git a/nova/tests/functional/api_sample_tests/test_volumes.py b/nova/tests/functional/api_sample_tests/test_volumes.py index 63893c26f6ff..1d70f4899767 100644 --- a/nova/tests/functional/api_sample_tests/test_volumes.py +++ b/nova/tests/functional/api_sample_tests/test_volumes.py @@ -245,6 +245,10 @@ class VolumeAttachmentsSample(test_servers.ServersSampleBase): self.stub_out('nova.compute.api.API.get', fake_compute_api_get) + def _get_vol_attachment_subs(self, subs): + """Allows subclasses to override/supplement request/response subs""" + return subs + def test_attach_volume_to_server(self): self.stub_out('nova.objects.Service.get_minimum_version', lambda *a, **k: COMPUTE_VERSION_OLD_ATTACH_FLOW) @@ -268,6 +272,7 @@ class VolumeAttachmentsSample(test_servers.ServersSampleBase): 'device': device_name } server_id = self._post_server() + subs = self._get_vol_attachment_subs(subs) response = self._do_post('servers/%s/os-volume_attachments' % server_id, 'attach-volume-to-server-req', subs) @@ -300,6 +305,7 @@ class VolumeAttachmentsSample(test_servers.ServersSampleBase): 'device': device_name } server_id = self._post_server() + subs = self._get_vol_attachment_subs(subs) response = self._do_post('servers/%s/os-volume_attachments' % server_id, 'attach-volume-to-server-req', subs) @@ -362,7 +368,7 @@ class VolumeAttachmentsSample(test_servers.ServersSampleBase): self.assertEqual('', response.text) -class VolumeAttachmentsSampleV249(test_servers.ServersSampleBase): +class VolumeAttachmentsSampleV249(VolumeAttachmentsSample): sample_dir = "os-volumes" microversion = '2.49' scenarios = [('v2_49', {'api_major_version': 'v2.1'})] @@ -371,53 +377,5 @@ class VolumeAttachmentsSampleV249(test_servers.ServersSampleBase): super(VolumeAttachmentsSampleV249, self).setUp() self.useFixture(fixtures.CinderFixtureNewAttachFlow(self)) - def test_attach_volume_to_server(self): - device_name = '/dev/sdb' - bdm = objects.BlockDeviceMapping() - bdm['device_name'] = device_name - volume = fakes.stub_volume_get(None, context.get_admin_context(), - 'a26887c6-c47b-4654-abb5-dfadf7d3f803') - subs = { - 'volume_id': volume['id'], - 'device': device_name, - 'tag': 'foo', - } - server_id = self._post_server() - response = self._do_post('servers/%s/os-volume_attachments' - % server_id, - 'attach-volume-to-server-req', subs) - - self._verify_response('attach-volume-to-server-resp', subs, - response, 200) - - -class VolumeAttachmentsSampleV249OldCinderFlow(test_servers.ServersSampleBase): - - sample_dir = "os-volumes" - microversion = '2.49' - scenarios = [('v2_49', {'api_major_version': 'v2.1'})] - - def setUp(self): - super(VolumeAttachmentsSampleV249OldCinderFlow, self).setUp() - self.useFixture(fixtures.CinderFixture(self)) - - def test_attach_volume_to_server(self): - device_name = '/dev/sdb' - bdm = objects.BlockDeviceMapping() - bdm['device_name'] = device_name - volume = fakes.stub_volume_get(None, context.get_admin_context(), - 'a26887c6-c47b-4654-abb5-dfadf7d3f803') - self.stub_out('nova.objects.Service.get_minimum_version', - lambda *a, **k: COMPUTE_VERSION_OLD_ATTACH_FLOW) - subs = { - 'volume_id': volume['id'], - 'device': device_name, - 'tag': 'foo', - } - server_id = self._post_server() - response = self._do_post('servers/%s/os-volume_attachments' - % server_id, - 'attach-volume-to-server-req', subs) - - self._verify_response('attach-volume-to-server-resp', subs, - response, 200) + def _get_vol_attachment_subs(self, subs): + return dict(subs, tag='foo')