Add os-volumes extension to api samples
Add samples and templates to api samples for volumes extensions Fixes: bug 1071338 Implements: blueprint nova-api-samples Change-Id: Ia021cc4d6c29ccaa3e81f4c5fdbb7e88d9f02dc6
This commit is contained in:
parent
11764e5250
commit
a94176e15b
24
doc/api_samples/os-volumes/os-volumes-detail-resp.json
Normal file
24
doc/api_samples/os-volumes/os-volumes-detail-resp.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"volumes": [
|
||||
{
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "3912f2b4-c5ba-4aec-9165-872876fe202e",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "1999-01-01T01:01:01",
|
||||
"displayDescription": "Volume Description",
|
||||
"displayName": "Volume Name",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
]
|
||||
}
|
9
doc/api_samples/os-volumes/os-volumes-detail-resp.xml
Normal file
9
doc/api_samples/os-volumes/os-volumes-detail-resp.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volumes>
|
||||
<volume status="in-use" displayDescription="Volume Description" availabilityZone="zone1:host1" displayName="Volume Name" volumeType="Backup" snapshotId="None" id="a26887c6-c47b-4654-abb5-dfadf7d3f803" createdAt="2008-12-01T11:01:55" size="100">
|
||||
<attachments>
|
||||
<attachment device="/" serverId="3912f2b4-c5ba-4aec-9165-872876fe202e" id="a26887c6-c47b-4654-abb5-dfadf7d3f803" volumeId="a26887c6-c47b-4654-abb5-dfadf7d3f803"/>
|
||||
</attachments>
|
||||
<metadata/>
|
||||
</volume>
|
||||
</volumes>
|
22
doc/api_samples/os-volumes/os-volumes-get-resp.json
Normal file
22
doc/api_samples/os-volumes/os-volumes-get-resp.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"volume": {
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "3912f2b4-c5ba-4aec-9165-872876fe202e",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "2013-02-18T14:51:18.528085",
|
||||
"displayDescription": "Volume Description",
|
||||
"displayName": "Volume Name",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
}
|
7
doc/api_samples/os-volumes/os-volumes-get-resp.xml
Normal file
7
doc/api_samples/os-volumes/os-volumes-get-resp.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volume status="in-use" displayDescription="Volume Description" availabilityZone="zone1:host1" displayName="Volume Name" volumeType="Backup" snapshotId="None" id="a26887c6-c47b-4654-abb5-dfadf7d3f803" createdAt="2008-12-01T11:01:55" size="100">
|
||||
<attachments>
|
||||
<attachment device="/" serverId="3912f2b4-c5ba-4aec-9165-872876fe202e" id="a26887c6-c47b-4654-abb5-dfadf7d3f803" volumeId="a26887c6-c47b-4654-abb5-dfadf7d3f803"/>
|
||||
</attachments>
|
||||
<metadata/>
|
||||
</volume>
|
24
doc/api_samples/os-volumes/os-volumes-index-resp.json
Normal file
24
doc/api_samples/os-volumes/os-volumes-index-resp.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"volumes": [
|
||||
{
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "3912f2b4-c5ba-4aec-9165-872876fe202e",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "2013-02-19T20:01:40.274897",
|
||||
"displayDescription": "Volume Description",
|
||||
"displayName": "Volume Name",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
]
|
||||
}
|
9
doc/api_samples/os-volumes/os-volumes-index-resp.xml
Normal file
9
doc/api_samples/os-volumes/os-volumes-index-resp.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volumes>
|
||||
<volume status="in-use" displayDescription="Volume Description" availabilityZone="zone1:host1" displayName="Volume Name" volumeType="Backup" snapshotId="None" id="a26887c6-c47b-4654-abb5-dfadf7d3f803" createdAt="2008-12-01T11:01:55" size="100">
|
||||
<attachments>
|
||||
<attachment device="/" serverId="3912f2b4-c5ba-4aec-9165-872876fe202e" id="a26887c6-c47b-4654-abb5-dfadf7d3f803" volumeId="a26887c6-c47b-4654-abb5-dfadf7d3f803"/>
|
||||
</attachments>
|
||||
<metadata/>
|
||||
</volume>
|
||||
</volumes>
|
9
doc/api_samples/os-volumes/os-volumes-post-req.json
Normal file
9
doc/api_samples/os-volumes/os-volumes-post-req.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"volume":
|
||||
{
|
||||
"availability_zone": "zone1:host1",
|
||||
"display_name": "Volume Name",
|
||||
"display_description": "Volume Description",
|
||||
"size": 100
|
||||
}
|
||||
}
|
3
doc/api_samples/os-volumes/os-volumes-post-req.xml
Normal file
3
doc/api_samples/os-volumes/os-volumes-post-req.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volume displayDescription="Volume Description" availabilityZone="zone1:host1" displayName="Volume Name" size="100"/>
|
||||
|
22
doc/api_samples/os-volumes/os-volumes-post-resp.json
Normal file
22
doc/api_samples/os-volumes/os-volumes-post-resp.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"volume": {
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "3912f2b4-c5ba-4aec-9165-872876fe202e",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "2013-02-18T14:51:17.970024",
|
||||
"displayDescription": "Volume Description",
|
||||
"displayName": "Volume Name",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
}
|
7
doc/api_samples/os-volumes/os-volumes-post-resp.xml
Normal file
7
doc/api_samples/os-volumes/os-volumes-post-resp.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volume status="in-use" displayDescription="Volume Description" availabilityZone="zone1:host1" displayName="Volume Name" volumeType="Backup" snapshotId="None" id="a26887c6-c47b-4654-abb5-dfadf7d3f803" createdAt="2008-12-01T11:01:55" size="100">
|
||||
<attachments>
|
||||
<attachment device="/" serverId="3912f2b4-c5ba-4aec-9165-872876fe202e" id="a26887c6-c47b-4654-abb5-dfadf7d3f803" volumeId="a26887c6-c47b-4654-abb5-dfadf7d3f803"/>
|
||||
</attachments>
|
||||
<metadata/>
|
||||
</volume>
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
"volumes": [
|
||||
{
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "%(uuid)s",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "%(uuid)s"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "%(timestamp)s",
|
||||
"displayDescription": "%(volume_desc)s",
|
||||
"displayName": "%(volume_name)s",
|
||||
"id": "%(uuid)s",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volumes>
|
||||
<volume status="in-use" displayDescription="%(volume_desc)s" availabilityZone="zone1:host1" displayName="%(volume_name)s" volumeType="Backup" snapshotId="None" id="%(uuid)s" createdAt="%(timestamp)s" size="100">
|
||||
<attachments>
|
||||
<attachment device="/" serverId="%(uuid)s" id="%(uuid)s" volumeId="%(uuid)s"/>
|
||||
</attachments>
|
||||
<metadata/>
|
||||
</volume>
|
||||
</volumes>
|
@ -0,0 +1,22 @@
|
||||
{
|
||||
"volume": {
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "%(uuid)s",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "%(uuid)s"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "%(timestamp)s",
|
||||
"displayDescription": "%(volume_desc)s",
|
||||
"displayName": "%(volume_name)s",
|
||||
"id": "%(uuid)s",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volume status="in-use" displayDescription="%(volume_desc)s" availabilityZone="zone1:host1" displayName="%(volume_name)s" volumeType="Backup" snapshotId="None" id="%(uuid)s" createdAt="%(timestamp)s" size="100">
|
||||
<attachments>
|
||||
<attachment device="/" serverId="%(uuid)s" id="%(uuid)s" volumeId="%(uuid)s"/>
|
||||
</attachments>
|
||||
<metadata/>
|
||||
</volume>
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
"volumes": [
|
||||
{
|
||||
"attachments": [
|
||||
{
|
||||
"device": "/",
|
||||
"id": "%(uuid)s",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "%(uuid)s"
|
||||
}
|
||||
],
|
||||
"availabilityZone": "zone1:host1",
|
||||
"createdAt": "%(timestamp)s",
|
||||
"displayDescription": "%(volume_desc)s",
|
||||
"displayName": "%(volume_name)s",
|
||||
"id": "%(uuid)s",
|
||||
"metadata": {},
|
||||
"size": 100,
|
||||
"snapshotId": null,
|
||||
"status": "in-use",
|
||||
"volumeType": "Backup"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volumes>
|
||||
<volume status="in-use" displayDescription="%(volume_desc)s" availabilityZone="zone1:host1" displayName="%(volume_name)s" volumeType="Backup" snapshotId="None" id="%(uuid)s" createdAt="%(timestamp)s" size="100">
|
||||
<attachments>
|
||||
<attachment device="/" serverId="%(uuid)s" id="%(uuid)s" volumeId="%(uuid)s"/>
|
||||
</attachments>
|
||||
<metadata/>
|
||||
</volume>
|
||||
</volumes>
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"volume":
|
||||
{
|
||||
"availability_zone": "zone1:host1",
|
||||
"display_name": "%(volume_name)s",
|
||||
"display_description": "%(volume_desc)s",
|
||||
"size": 100
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volume displayDescription="%(volume_desc)s" availabilityZone="zone1:host1" displayName="%(volume_name)s" size="100"/>
|
@ -0,0 +1,21 @@
|
||||
{
|
||||
"volume": {
|
||||
"status": "in-use",
|
||||
"displayDescription": "%(volume_desc)s",
|
||||
"availabilityZone": "zone1:host1",
|
||||
"displayName": "%(volume_name)s",
|
||||
"attachments": [
|
||||
{ "device": "/",
|
||||
"serverId": "%(uuid)s",
|
||||
"id": "%(uuid)s",
|
||||
"volumeId": "%(uuid)s"
|
||||
}
|
||||
],
|
||||
"volumeType": "Backup",
|
||||
"snapshotId": null,
|
||||
"metadata": {},
|
||||
"id": "%(uuid)s",
|
||||
"createdAt": "%(timestamp)s",
|
||||
"size": 100
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<volume status="in-use" displayDescription="%(volume_desc)s" availabilityZone="zone1:host1" displayName="%(volume_name)s" volumeType="Backup" snapshotId="None" id="%(uuid)s" createdAt="%(timestamp)s" size="100">
|
||||
<attachments>
|
||||
<attachment device="/" serverId="%(uuid)s" id="%(uuid)s" volumeId="%(uuid)s"/>
|
||||
</attachments>
|
||||
<metadata/>
|
||||
</volume>
|
@ -3752,3 +3752,116 @@ class VolumeAttachmentsSampleJsonTest(ServersSampleBase):
|
||||
|
||||
class VolumeAttachmentsSampleXmlTest(VolumeAttachmentsSampleJsonTest):
|
||||
ctype = 'xml'
|
||||
|
||||
|
||||
class VolumesSampleJsonTest(ServersSampleBase):
|
||||
extension_name = ("nova.api.openstack.compute.contrib.volumes.Volumes")
|
||||
|
||||
def _get_volume_id(self):
|
||||
return 'a26887c6-c47b-4654-abb5-dfadf7d3f803'
|
||||
|
||||
def _stub_volume(self, id, displayname="Volume Name",
|
||||
displaydesc="Volume Description", size=100):
|
||||
volume = {
|
||||
'id': id,
|
||||
'size': size,
|
||||
'availability_zone': 'zone1:host1',
|
||||
'instance_uuid': '3912f2b4-c5ba-4aec-9165-872876fe202e',
|
||||
'mountpoint': '/',
|
||||
'status': 'in-use',
|
||||
'attach_status': 'attached',
|
||||
'name': 'vol name',
|
||||
'display_name': displayname,
|
||||
'display_description': displaydesc,
|
||||
'created_at': "2008-12-01T11:01:55",
|
||||
'snapshot_id': None,
|
||||
'volume_type_id': 'fakevoltype',
|
||||
'volume_metadata': [],
|
||||
'volume_type': {'name': 'Backup'}
|
||||
}
|
||||
return volume
|
||||
|
||||
def _stub_volume_get(self, context, volume_id):
|
||||
return self._stub_volume(volume_id)
|
||||
|
||||
def _stub_volume_delete(self, context, *args, **param):
|
||||
pass
|
||||
|
||||
def _stub_volume_get_all(self, context, search_opts=None):
|
||||
id = self._get_volume_id()
|
||||
return [self._stub_volume(id)]
|
||||
|
||||
def _stub_volume_create(self, context, size, name, description, snapshot,
|
||||
**param):
|
||||
id = self._get_volume_id()
|
||||
return self._stub_volume(id)
|
||||
|
||||
def setUp(self):
|
||||
super(VolumesSampleJsonTest, self).setUp()
|
||||
fakes.stub_out_networking(self.stubs)
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
|
||||
self.stubs.Set(cinder.API, "delete", self._stub_volume_delete)
|
||||
self.stubs.Set(cinder.API, "get", self._stub_volume_get)
|
||||
self.stubs.Set(cinder.API, "get_all", self._stub_volume_get_all)
|
||||
|
||||
def _post_volume(self):
|
||||
subs_req = {
|
||||
'volume_name': "Volume Name",
|
||||
'volume_desc': "Volume Description",
|
||||
}
|
||||
|
||||
self.stubs.Set(cinder.API, "create", self._stub_volume_create)
|
||||
response = self._do_post('os-volumes', 'os-volumes-post-req',
|
||||
subs_req)
|
||||
self.assertEqual(response.status, 200)
|
||||
subs = self._get_regexes()
|
||||
subs.update(subs_req)
|
||||
return self._verify_response('os-volumes-post-resp', subs, response)
|
||||
|
||||
def test_volumes_show(self):
|
||||
subs = {
|
||||
'volume_name': "Volume Name",
|
||||
'volume_desc': "Volume Description",
|
||||
}
|
||||
vol_id = self._get_volume_id()
|
||||
response = self._do_get('os-volumes/%s' % vol_id)
|
||||
self.assertEqual(response.status, 200)
|
||||
subs.update(self._get_regexes())
|
||||
return self._verify_response('os-volumes-get-resp', subs, response)
|
||||
|
||||
def test_volumes_index(self):
|
||||
subs = {
|
||||
'volume_name': "Volume Name",
|
||||
'volume_desc': "Volume Description",
|
||||
}
|
||||
response = self._do_get('os-volumes')
|
||||
self.assertEqual(response.status, 200)
|
||||
subs.update(self._get_regexes())
|
||||
return self._verify_response('os-volumes-index-resp', subs, response)
|
||||
|
||||
def test_volumes_detail(self):
|
||||
# For now, index and detail are the same.
|
||||
# See the volumes api
|
||||
subs = {
|
||||
'volume_name': "Volume Name",
|
||||
'volume_desc': "Volume Description",
|
||||
}
|
||||
response = self._do_get('os-volumes/detail')
|
||||
self.assertEqual(response.status, 200)
|
||||
subs.update(self._get_regexes())
|
||||
return self._verify_response('os-volumes-detail-resp', subs, response)
|
||||
|
||||
def test_volumes_create(self):
|
||||
return self._post_volume()
|
||||
|
||||
def test_volumes_delete(self):
|
||||
self._post_volume()
|
||||
vol_id = self._get_volume_id()
|
||||
response = self._do_delete('os-volumes/%s' % vol_id)
|
||||
self.assertEqual(response.status, 202)
|
||||
self.assertEqual(response.read(), '')
|
||||
|
||||
|
||||
class VolumesSampleXmlTest(VolumesSampleJsonTest):
|
||||
ctype = 'xml'
|
||||
|
Loading…
x
Reference in New Issue
Block a user