From 4a1d27c4ade3c40bc28455a49eeef5a199b5098c Mon Sep 17 00:00:00 2001 From: Tiago Mello Date: Tue, 26 Feb 2013 14:17:54 -0300 Subject: Adds API Sample tests for Volume Attachments Partially implements bp nova-api-samples Fixes Bug 1126204 Change-Id: I4b061f1916d688ad97c6a6ba4011dd13431a4fcb --- .../os-volumes/attach-volume-to-server-req.json | 6 ++ .../os-volumes/attach-volume-to-server-req.xml | 2 + .../os-volumes/attach-volume-to-server-resp.json | 8 ++ .../os-volumes/attach-volume-to-server-resp.xml | 2 + .../os-volumes/list-volume-attachments-resp.json | 16 ++++ .../os-volumes/list-volume-attachments-resp.xml | 5 ++ doc/api_samples/os-volumes/server-post-req.json | 16 ++++ doc/api_samples/os-volumes/server-post-req.xml | 19 +++++ doc/api_samples/os-volumes/server-post-resp.json | 16 ++++ doc/api_samples/os-volumes/server-post-resp.xml | 6 ++ .../os-volumes/volume-attachment-detail-resp.json | 8 ++ .../os-volumes/volume-attachment-detail-resp.xml | 2 + .../attach-volume-to-server-req.json.tpl | 6 ++ .../os-volumes/attach-volume-to-server-req.xml.tpl | 2 + .../attach-volume-to-server-resp.json.tpl | 8 ++ .../attach-volume-to-server-resp.xml.tpl | 2 + .../list-volume-attachments-resp.json.tpl | 16 ++++ .../list-volume-attachments-resp.xml.tpl | 5 ++ .../os-volumes/server-post-req.json.tpl | 16 ++++ .../api_samples/os-volumes/server-post-req.xml.tpl | 19 +++++ .../os-volumes/server-post-resp.json.tpl | 16 ++++ .../os-volumes/server-post-resp.xml.tpl | 6 ++ .../volume-attachment-detail-resp.json.tpl | 8 ++ .../volume-attachment-detail-resp.xml.tpl | 2 + nova/tests/integrated/test_api_samples.py | 92 ++++++++++++++++++++++ 25 files changed, 304 insertions(+) create mode 100644 doc/api_samples/os-volumes/attach-volume-to-server-req.json create mode 100644 doc/api_samples/os-volumes/attach-volume-to-server-req.xml create mode 100644 doc/api_samples/os-volumes/attach-volume-to-server-resp.json create mode 100644 doc/api_samples/os-volumes/attach-volume-to-server-resp.xml create mode 100644 doc/api_samples/os-volumes/list-volume-attachments-resp.json create mode 100644 doc/api_samples/os-volumes/list-volume-attachments-resp.xml create mode 100644 doc/api_samples/os-volumes/server-post-req.json create mode 100644 doc/api_samples/os-volumes/server-post-req.xml create mode 100644 doc/api_samples/os-volumes/server-post-resp.json create mode 100644 doc/api_samples/os-volumes/server-post-resp.xml create mode 100644 doc/api_samples/os-volumes/volume-attachment-detail-resp.json create mode 100644 doc/api_samples/os-volumes/volume-attachment-detail-resp.xml create mode 100644 nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/list-volume-attachments-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/list-volume-attachments-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/server-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/server-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/server-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/server-post-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/volume-attachment-detail-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-volumes/volume-attachment-detail-resp.xml.tpl diff --git a/doc/api_samples/os-volumes/attach-volume-to-server-req.json b/doc/api_samples/os-volumes/attach-volume-to-server-req.json new file mode 100644 index 000000000..4062687fc --- /dev/null +++ b/doc/api_samples/os-volumes/attach-volume-to-server-req.json @@ -0,0 +1,6 @@ +{ + "volumeAttachment": { + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803", + "device": "/dev/vdd" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-volumes/attach-volume-to-server-req.xml b/doc/api_samples/os-volumes/attach-volume-to-server-req.xml new file mode 100644 index 000000000..eedfc329a --- /dev/null +++ b/doc/api_samples/os-volumes/attach-volume-to-server-req.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/doc/api_samples/os-volumes/attach-volume-to-server-resp.json b/doc/api_samples/os-volumes/attach-volume-to-server-resp.json new file mode 100644 index 000000000..2e512ac99 --- /dev/null +++ b/doc/api_samples/os-volumes/attach-volume-to-server-resp.json @@ -0,0 +1,8 @@ +{ + "volumeAttachment": { + "device": "/dev/vdd", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", + "serverId": "0c92f3f6-c253-4c9b-bd43-e880a8d2eb0a", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-volumes/attach-volume-to-server-resp.xml b/doc/api_samples/os-volumes/attach-volume-to-server-resp.xml new file mode 100644 index 000000000..aaa85dd43 --- /dev/null +++ b/doc/api_samples/os-volumes/attach-volume-to-server-resp.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/doc/api_samples/os-volumes/list-volume-attachments-resp.json b/doc/api_samples/os-volumes/list-volume-attachments-resp.json new file mode 100644 index 000000000..9ae9b4a2a --- /dev/null +++ b/doc/api_samples/os-volumes/list-volume-attachments-resp.json @@ -0,0 +1,16 @@ +{ + "volumeAttachments": [ + { + "device": "/dev/sdd", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", + "serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" + }, + { + "device": "/dev/sdc", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f804", + "serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804" + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/os-volumes/list-volume-attachments-resp.xml b/doc/api_samples/os-volumes/list-volume-attachments-resp.xml new file mode 100644 index 000000000..7d70882c0 --- /dev/null +++ b/doc/api_samples/os-volumes/list-volume-attachments-resp.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/doc/api_samples/os-volumes/server-post-req.json b/doc/api_samples/os-volumes/server-post-req.json new file mode 100644 index 000000000..d88eb4122 --- /dev/null +++ b/doc/api_samples/os-volumes/server-post-req.json @@ -0,0 +1,16 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", + "flavorRef" : "http://openstack.example.com/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-volumes/server-post-req.xml b/doc/api_samples/os-volumes/server-post-req.xml new file mode 100644 index 000000000..0a3c8bb53 --- /dev/null +++ b/doc/api_samples/os-volumes/server-post-req.xml @@ -0,0 +1,19 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + \ No newline at end of file diff --git a/doc/api_samples/os-volumes/server-post-resp.json b/doc/api_samples/os-volumes/server-post-resp.json new file mode 100644 index 000000000..6ae553403 --- /dev/null +++ b/doc/api_samples/os-volumes/server-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "8VqALQcVB9MT", + "id": "a80b9477-84c1-4242-9731-14a3c2a04241", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/a80b9477-84c1-4242-9731-14a3c2a04241", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/a80b9477-84c1-4242-9731-14a3c2a04241", + "rel": "bookmark" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-volumes/server-post-resp.xml b/doc/api_samples/os-volumes/server-post-resp.xml new file mode 100644 index 000000000..b2474027d --- /dev/null +++ b/doc/api_samples/os-volumes/server-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/doc/api_samples/os-volumes/volume-attachment-detail-resp.json b/doc/api_samples/os-volumes/volume-attachment-detail-resp.json new file mode 100644 index 000000000..5375033bb --- /dev/null +++ b/doc/api_samples/os-volumes/volume-attachment-detail-resp.json @@ -0,0 +1,8 @@ +{ + "volumeAttachment": { + "device": "/dev/sdd", + "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", + "serverId": "2390fb4d-1693-45d7-b309-e29c4af16538", + "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-volumes/volume-attachment-detail-resp.xml b/doc/api_samples/os-volumes/volume-attachment-detail-resp.xml new file mode 100644 index 000000000..dea235292 --- /dev/null +++ b/doc/api_samples/os-volumes/volume-attachment-detail-resp.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-req.json.tpl b/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-req.json.tpl new file mode 100644 index 000000000..3d360a57b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-req.json.tpl @@ -0,0 +1,6 @@ +{ + "volumeAttachment": { + "volumeId": "%(volume_id)s", + "device": "%(device)s" + } +} diff --git a/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-req.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-req.xml.tpl new file mode 100644 index 000000000..ffb20ad1e --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-req.xml.tpl @@ -0,0 +1,2 @@ + + diff --git a/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-resp.json.tpl b/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-resp.json.tpl new file mode 100644 index 000000000..4730b3c19 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-resp.json.tpl @@ -0,0 +1,8 @@ +{ + "volumeAttachment": { + "device": "%(device)s", + "id": "%(volume_id)s", + "serverId": "%(uuid)s", + "volumeId": "%(volume_id)s" + } +} diff --git a/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-resp.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-resp.xml.tpl new file mode 100644 index 000000000..efad2fd02 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/attach-volume-to-server-resp.xml.tpl @@ -0,0 +1,2 @@ + + diff --git a/nova/tests/integrated/api_samples/os-volumes/list-volume-attachments-resp.json.tpl b/nova/tests/integrated/api_samples/os-volumes/list-volume-attachments-resp.json.tpl new file mode 100644 index 000000000..6c1da07ef --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/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/integrated/api_samples/os-volumes/list-volume-attachments-resp.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/list-volume-attachments-resp.xml.tpl new file mode 100644 index 000000000..351646d81 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/list-volume-attachments-resp.xml.tpl @@ -0,0 +1,5 @@ + + + + + diff --git a/nova/tests/integrated/api_samples/os-volumes/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-volumes/server-post-req.json.tpl new file mode 100644 index 000000000..d3916d1aa --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/server-post-req.json.tpl @@ -0,0 +1,16 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "%(host)s/openstack/images/%(image_id)s", + "flavorRef" : "%(host)s/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-volumes/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/server-post-req.xml.tpl new file mode 100644 index 000000000..f92614984 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/server-post-req.xml.tpl @@ -0,0 +1,19 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + diff --git a/nova/tests/integrated/api_samples/os-volumes/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-volumes/server-post-resp.json.tpl new file mode 100644 index 000000000..d5f030c87 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/server-post-resp.json.tpl @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "%(password)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(uuid)s", + "rel": "bookmark" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-volumes/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/server-post-resp.xml.tpl new file mode 100644 index 000000000..3bb13e69b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/server-post-resp.xml.tpl @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/api_samples/os-volumes/volume-attachment-detail-resp.json.tpl b/nova/tests/integrated/api_samples/os-volumes/volume-attachment-detail-resp.json.tpl new file mode 100644 index 000000000..86099eeb8 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/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/integrated/api_samples/os-volumes/volume-attachment-detail-resp.xml.tpl b/nova/tests/integrated/api_samples/os-volumes/volume-attachment-detail-resp.xml.tpl new file mode 100644 index 000000000..45fd19979 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-volumes/volume-attachment-detail-resp.xml.tpl @@ -0,0 +1,2 @@ + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index be17c020c..8469e7bb4 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -33,6 +33,7 @@ from nova.api.openstack.compute.contrib import fping # Import extensions to pull in osapi_compute_extension CONF option used below. from nova.cloudpipe import pipelib from nova.compute import api as compute_api +from nova.compute import manager as compute_manager from nova import context from nova import db from nova.db.sqlalchemy import models @@ -3660,3 +3661,94 @@ class SnapshotsSampleJsonTests(ApiSampleTestBase): class SnapshotsSampleXmlTests(SnapshotsSampleJsonTests): ctype = "xml" + + +class VolumeAttachmentsSampleJsonTest(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib.volumes.Volumes") + + def test_attach_volume_to_server(self): + device_name = '/dev/vdd' + self.stubs.Set(cinder.API, 'get', fakes.stub_volume_get) + self.stubs.Set(cinder.API, 'check_attach', lambda *a, **k: None) + self.stubs.Set(cinder.API, 'reserve_volume', lambda *a, **k: None) + self.stubs.Set(compute_manager.ComputeManager, + "reserve_block_device_name", + lambda *a, **k: 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 + } + server_id = self._post_server() + response = self._do_post('servers/%s/os-volume_attachments' + % server_id, + 'attach-volume-to-server-req', subs) + + self.assertEqual(response.status, 200) + subs.update(self._get_regexes()) + self._verify_response('attach-volume-to-server-resp', + subs, response) + + def _stub_compute_api_get_instance_bdms(self, server_id): + + def fake_compute_api_get_instance_bdms(self, context, instance): + bdms = [ + {'volume_id': 'a26887c6-c47b-4654-abb5-dfadf7d3f803', + 'instance_uuid': server_id, + 'device_name': '/dev/sdd'}, + {'volume_id': 'a26887c6-c47b-4654-abb5-dfadf7d3f804', + 'instance_uuid': server_id, + 'device_name': '/dev/sdc'} + ] + return bdms + + self.stubs.Set(compute_api.API, "get_instance_bdms", + fake_compute_api_get_instance_bdms) + + def _stub_compute_api_get(self): + + def fake_compute_api_get(self, context, instance_id): + return {'uuid': instance_id} + + self.stubs.Set(compute_api.API, 'get', fake_compute_api_get) + + def test_list_volume_attachments(self): + server_id = self._post_server() + + self._stub_compute_api_get_instance_bdms(server_id) + + response = self._do_get('servers/%s/os-volume_attachments' + % server_id) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + self._verify_response('list-volume-attachments-resp', + subs, response) + + def test_volume_attachment_detail(self): + server_id = self._post_server() + attach_id = "a26887c6-c47b-4654-abb5-dfadf7d3f803" + self._stub_compute_api_get_instance_bdms(server_id) + self._stub_compute_api_get() + response = self._do_get('servers/%s/os-volume_attachments/%s' + % (server_id, attach_id)) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + self._verify_response('volume-attachment-detail-resp', + subs, response) + + def test_volume_attachment_delete(self): + server_id = self._post_server() + attach_id = "a26887c6-c47b-4654-abb5-dfadf7d3f803" + self._stub_compute_api_get_instance_bdms(server_id) + self._stub_compute_api_get() + self.stubs.Set(compute_api.API, 'detach_volume', lambda *a, **k: None) + response = self._do_delete('servers/%s/os-volume_attachments/%s' + % (server_id, attach_id)) + self.assertEqual(response.status, 202) + self.assertEqual(response.read(), '') + + +class VolumeAttachmentsSampleXmlTest(VolumeAttachmentsSampleJsonTest): + ctype = 'xml' -- cgit