Merge "Automate generation of volumes api-ref samples"

This commit is contained in:
Zuul 2019-02-06 19:28:36 +00:00 committed by Gerrit Code Review
commit e10f524529
45 changed files with 552 additions and 128 deletions

View File

@ -25,4 +25,4 @@
"version": "3.59"
}
]
}
}

View File

@ -1,34 +0,0 @@
{
"volume": {
"status": "creating",
"migration_status": null,
"user_id": "0eea4eabcf184061a3b6db1e0daaf010",
"attachments": [],
"links": [
{
"href": "http://23.253.248.171:8776/v3/bab7d5c60cd041a0a36f7c4b6e1dd978/volumes/6edbc2f4-1507-44f8-ac0d-eed1d2608d38",
"rel": "self"
},
{
"href": "http://23.253.248.171:8776/bab7d5c60cd041a0a36f7c4b6e1dd978/volumes/6edbc2f4-1507-44f8-ac0d-eed1d2608d38",
"rel": "bookmark"
}
],
"availability_zone": "nova",
"bootable": "false",
"encrypted": false,
"created_at": "2015-11-29T03:01:44.000000",
"description": null,
"updated_at": null,
"volume_type": "lvmdriver-1",
"name": "test-volume-attachments",
"replication_status": "disabled",
"consistencygroup_id": null,
"source_volid": null,
"snapshot_id": null,
"multiattach": false,
"metadata": {},
"id": "6edbc2f4-1507-44f8-ac0d-eed1d2608d38",
"size": 2
}
}

View File

@ -1,5 +0,0 @@
{
"meta": {
"name": "test"
}
}

View File

@ -1,31 +0,0 @@
{
"volume": {
"status": "available",
"attachments": [],
"links": [
{
"href": "http://localhost:8776/v3/0c2eba2c5af04d3f9e9d0d410b371fde/volumes/5aa119a8-d25b-45a7-8d1b-88e127885635",
"rel": "self"
},
{
"href": "http://localhost:8776/0c2eba2c5af04d3f9e9d0d410b371fde/volumes/5aa119a8-d25b-45a7-8d1b-88e127885635",
"rel": "bookmark"
}
],
"availability_zone": "nova",
"bootable": "false",
"os-vol-host-attr:host": "ip-10-168-107-25",
"source_volid": null,
"snapshot_id": null,
"id": "5aa119a8-d25b-45a7-8d1b-88e127885635",
"description": "Super volume.",
"name": "vol-002",
"created_at": "2013-02-25T02:40:21.000000",
"volume_type": null,
"os-vol-tenant-attr:tenant_id": "0c2eba2c5af04d3f9e9d0d410b371fde",
"size": 1,
"metadata": {
"contents": "not junk"
}
}
}

View File

@ -1,5 +0,0 @@
{
"addProjectAccess": {
"project": "f270b245cb11498ca4031deb7e141cfa"
}
}

View File

@ -1,6 +0,0 @@
{
"volume_type_access": {
"volume_type_id": "3c67e124-39ad-4ace-a507-8bb7bf510c26",
"project_id": "f270b245cb11498ca4031deb7e141cfa"
}
}

View File

@ -0,0 +1,5 @@
{
"addProjectAccess": {
"project": "6f70656e737461636b20342065766572"
}
}

View File

@ -0,0 +1,8 @@
{
"volume_type_access": [
{
"project_id": "6f70656e737461636b20342065766572",
"volume_type_id": "a5082c24-2a27-43a4-b48e-fcec1240e36b"
}
]
}

View File

@ -0,0 +1,22 @@
{
"volume": {
"size": 10,
"availability_zone": null,
"source_volid": null,
"description": null,
"multiattach": false,
"snapshot_id": null,
"backup_id": null,
"name": null,
"imageRef": null,
"volume_type": null,
"metadata": {},
"consistencygroup_id": null
},
"OS-SCH-HNT:scheduler_hints": {
"same_host": [
"a0cf03a5-d921-4877-bb5c-86d26cf818e1",
"8c19174f-4220-44f0-824a-cd1eeef10287"
]
}
}

View File

@ -0,0 +1,34 @@
{
"volume": {
"attachments": [],
"availability_zone": "nova",
"bootable": "false",
"consistencygroup_id": null,
"created_at": "2018-11-28T06:21:12.715987",
"description": null,
"encrypted": false,
"id": "2b955850-f177-45f7-9f49-ecb2c256d161",
"links": [
{
"href": "http://127.0.0.1:33951/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/2b955850-f177-45f7-9f49-ecb2c256d161",
"rel": "self"
},
{
"href": "http://127.0.0.1:33951/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/2b955850-f177-45f7-9f49-ecb2c256d161",
"rel": "bookmark"
}
],
"metadata": {},
"migration_status": null,
"multiattach": false,
"name": null,
"replication_status": null,
"size": 10,
"snapshot_id": null,
"source_volid": null,
"status": "creating",
"updated_at": null,
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e",
"volume_type": null
}
}

View File

@ -0,0 +1,5 @@
{
"metadata": {
"name": "metadata0"
}
}

View File

@ -0,0 +1,5 @@
{
"meta": {
"name": "metadata1"
}
}

View File

@ -0,0 +1,5 @@
{
"meta": {
"name": "new_name"
}
}

View File

@ -0,0 +1,5 @@
{
"metadata": {
"name": "metadata1"
}
}

View File

@ -0,0 +1,38 @@
{
"volume": {
"attachments": [],
"availability_zone": "nova",
"bootable": "false",
"consistencygroup_id": null,
"created_at": "2018-11-29T06:50:07.770785",
"description": null,
"encrypted": false,
"id": "f7223234-1afc-4d19-bfa3-d19deb6235ef",
"links": [
{
"href": "http://127.0.0.1:45839/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/f7223234-1afc-4d19-bfa3-d19deb6235ef",
"rel": "self"
},
{
"href": "http://127.0.0.1:45839/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/f7223234-1afc-4d19-bfa3-d19deb6235ef",
"rel": "bookmark"
}
],
"metadata": {},
"migration_status": null,
"multiattach": false,
"name": null,
"os-vol-host-attr:host": null,
"os-vol-mig-status-attr:migstat": null,
"os-vol-mig-status-attr:name_id": null,
"os-vol-tenant-attr:tenant_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3",
"replication_status": null,
"size": 10,
"snapshot_id": null,
"source_volid": null,
"status": "creating",
"updated_at": null,
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e",
"volume_type": null
}
}

View File

@ -0,0 +1,9 @@
{
"volume": {
"name": "vol-003",
"description": "This is yet, another volume.",
"metadata": {
"name": "metadata0"
}
}
}

View File

@ -1,36 +1,36 @@
{
"volume": {
"status": "available",
"migration_status": null,
"user_id": "0eea4eabcf184061a3b6db1e0daaf010",
"attachments": [],
"availability_zone": "nova",
"bootable": "false",
"consistencygroup_id": null,
"created_at": "2018-11-29T06:59:23.679903",
"description": "This is yet, another volume.",
"encrypted": false,
"id": "8b2459d1-0059-4e14-a89f-dfa73a452af6",
"links": [
{
"href": "http://localhost:8776/v3/0c2eba2c5af04d3f9e9d0d410b371fde/volumes/5aa119a8-d25b-45a7-8d1b-88e127885635",
"href": "http://127.0.0.1:41467/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/8b2459d1-0059-4e14-a89f-dfa73a452af6",
"rel": "self"
},
{
"href": "http://localhost:8776/0c2eba2c5af04d3f9e9d0d410b371fde/volumes/5aa119a8-d25b-45a7-8d1b-88e127885635",
"href": "http://127.0.0.1:41467/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/8b2459d1-0059-4e14-a89f-dfa73a452af6",
"rel": "bookmark"
}
],
"availability_zone": "nova",
"bootable": "false",
"encrypted": false,
"created_at": "2015-11-29T03:01:44.000000",
"description": "This is yet, another volume.",
"updated_at": null,
"volume_type": "lvmdriver-1",
"name": "vol-003",
"replication_status": "disabled",
"consistencygroup_id": null,
"source_volid": null,
"snapshot_id": null,
"multiattach": false,
"metadata": {
"contents": "not junk"
"name": "metadata0"
},
"id": "5aa119a8-d25b-45a7-8d1b-88e127885635",
"size": 1
"migration_status": null,
"multiattach": false,
"name": "vol-003",
"replication_status": null,
"size": 10,
"snapshot_id": null,
"source_volid": null,
"status": "creating",
"updated_at": null,
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e",
"volume_type": null
}
}
}

View File

@ -0,0 +1,40 @@
{
"volumes": [
{
"attachments": [],
"availability_zone": "nova",
"bootable": "false",
"consistencygroup_id": null,
"created_at": "2018-11-28T06:25:15.288987",
"description": null,
"encrypted": false,
"id": "cb49b381-9012-40cb-b8ee-80c19a4801b5",
"links": [
{
"href": "http://127.0.0.1:43543/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/cb49b381-9012-40cb-b8ee-80c19a4801b5",
"rel": "self"
},
{
"href": "http://127.0.0.1:43543/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/cb49b381-9012-40cb-b8ee-80c19a4801b5",
"rel": "bookmark"
}
],
"metadata": {},
"migration_status": null,
"multiattach": false,
"name": null,
"os-vol-host-attr:host": null,
"os-vol-mig-status-attr:migstat": null,
"os-vol-mig-status-attr:name_id": null,
"os-vol-tenant-attr:tenant_id": "89afd400-b646-4bbc-b12b-c0a4d63e5bd3",
"replication_status": null,
"size": 10,
"snapshot_id": null,
"source_volid": null,
"status": "creating",
"updated_at": null,
"user_id": "c853ca26-e8ea-4797-8a52-ee124a013d0e",
"volume_type": null
}
]
}

View File

@ -0,0 +1,18 @@
{
"volumes": [
{
"id": "efa54464-8fab-47cd-a05a-be3e6b396188",
"links": [
{
"href": "http://127.0.0.1:37097/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/efa54464-8fab-47cd-a05a-be3e6b396188",
"rel": "self"
},
{
"href": "http://127.0.0.1:37097/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/efa54464-8fab-47cd-a05a-be3e6b396188",
"rel": "bookmark"
}
],
"name": null
}
]
}

View File

@ -41,7 +41,7 @@ Request
Request Example
---------------
.. literalinclude:: ./samples/volume-type-access-add-request.json
.. literalinclude:: ./samples/volume_type/volume-type-access-add-request.json
:language: javascript
@ -115,5 +115,5 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volume-type-access-list-response.json
.. literalinclude:: ./samples/volume_type/volume-type-access-list-response.json
:language: javascript

View File

@ -137,7 +137,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volumes-list-detailed-response.json
.. literalinclude:: ./samples/volumes/volumes-list-detailed-response.json
:language: javascript
@ -211,7 +211,7 @@ Request
Request Example
---------------
.. literalinclude:: ./samples/volume-create-request.json
.. literalinclude:: ./samples/volumes/volume-create-request.json
:language: javascript
@ -248,7 +248,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volume-create-response.json
.. literalinclude:: ./samples/volumes/volume-create-response.json
:language: javascript
@ -305,7 +305,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volumes-list-response.json
.. literalinclude:: ./samples/volumes/volumes-list-response.json
:language: javascript
@ -378,7 +378,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volume-show-response.json
.. literalinclude:: ./samples/volumes/volume-show-response.json
:language: javascript
@ -414,7 +414,7 @@ Request
Request Example
---------------
.. literalinclude:: ./samples/volume-update-request.json
.. literalinclude:: ./samples/volumes/volume-update-request.json
:language: javascript
@ -451,7 +451,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volume-update-response.json
.. literalinclude:: ./samples/volumes/volume-update-response.json
:language: javascript
@ -535,7 +535,7 @@ Request
Request Example
---------------
.. literalinclude:: ./samples/volume-metadata-create-request.json
.. literalinclude:: ./samples/volumes/volume-metadata-create-request.json
:language: javascript
@ -551,7 +551,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volume-metadata-create-response.json
.. literalinclude:: ./samples/volumes/volume-metadata-create-response.json
:language: javascript
@ -592,7 +592,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volume-metadata-show-response.json
.. literalinclude:: ./samples/volumes/volume-metadata-show-response.json
:language: javascript
@ -624,7 +624,7 @@ Request
Request Example
---------------
.. literalinclude:: ./samples/volume-metadata-update-request.json
.. literalinclude:: ./samples/volumes/volume-metadata-update-request.json
:language: javascript
@ -641,7 +641,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volume-metadata-update-response.json
.. literalinclude:: ./samples/volumes/volume-metadata-update-response.json
:language: javascript
@ -682,7 +682,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volume-metadata-show-key-response.json
.. literalinclude:: ./samples/volumes/volume-metadata-show-key-response.json
:language: javascript
@ -741,7 +741,7 @@ Request
Request Example
---------------
.. literalinclude:: ./samples/volume-metadata-update-key-request.json
.. literalinclude:: ./samples/volumes/volume-metadata-update-key-request.json
:language: javascript
Response Parameters
@ -754,7 +754,7 @@ Response Parameters
Response Example
----------------
.. literalinclude:: ./samples/volume-metadata-update-key-response.json
.. literalinclude:: ./samples/volumes/volume-metadata-update-key-response.json
:language: javascript

View File

@ -0,0 +1,5 @@
{
"addProjectAccess": {
"project": "6f70656e737461636b20342065766572"
}
}

View File

@ -0,0 +1,8 @@
{
"volume_type_access": [
{
"project_id": "%(user_id)s",
"volume_type_id": "%(uuid)s"
}
]
}

View File

@ -2,7 +2,7 @@
"volume_type": {
"name": "%(name)s",
"description": "%(description)s",
"os-volume-type-access:is_public": true,
"os-volume-type-access:is_public": "%(bool)s",
"extra_specs": {
"capabilities": "gpu"
}

View File

@ -0,0 +1,34 @@
{
"volume": {
"attachments": [],
"availability_zone": "nova",
"bootable": "false",
"consistencygroup_id": null,
"created_at": "%(strtime)s",
"description": null,
"encrypted": false,
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "bookmark"
}
],
"metadata": {},
"migration_status": null,
"multiattach": false,
"name": null,
"replication_status": null,
"size": 10,
"snapshot_id": null,
"source_volid": null,
"status": "creating",
"updated_at": null,
"user_id": "%(uuid)s",
"volume_type": null
}
}

View File

@ -0,0 +1,5 @@
{
"metadata": {
"name": "metadata0"
}
}

View File

@ -0,0 +1,5 @@
{
"meta": {
"name": "metadata1"
}
}

View File

@ -0,0 +1,5 @@
{
"meta": {
"name": "new_name"
}
}

View File

@ -0,0 +1,5 @@
{
"metadata": {
"name": "metadata1"
}
}

View File

@ -0,0 +1,38 @@
{
"volume": {
"attachments": [],
"availability_zone": "nova",
"bootable": "false",
"consistencygroup_id": null,
"created_at": "%(strtime)s",
"description": null,
"encrypted": false,
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "bookmark"
}
],
"metadata": {},
"migration_status": null,
"multiattach": false,
"name": null,
"os-vol-host-attr:host": null,
"os-vol-mig-status-attr:migstat": null,
"os-vol-mig-status-attr:name_id": null,
"os-vol-tenant-attr:tenant_id": "%(uuid)s",
"replication_status": null,
"size": 10,
"snapshot_id": null,
"source_volid": null,
"status": "creating",
"updated_at": null,
"user_id": "%(uuid)s",
"volume_type": null
}
}

View File

@ -0,0 +1,36 @@
{
"volume": {
"attachments": [],
"availability_zone": "nova",
"bootable": "false",
"consistencygroup_id": null,
"created_at": "%(strtime)s",
"description": "This is yet, another volume.",
"encrypted": false,
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "bookmark"
}
],
"metadata": {
"name": "metadata0"
},
"migration_status": null,
"multiattach": false,
"name": "vol-003",
"replication_status": null,
"size": 10,
"snapshot_id": null,
"source_volid": null,
"status": "creating",
"updated_at": null,
"user_id": "%(uuid)s",
"volume_type": null
}
}

View File

@ -0,0 +1,40 @@
{
"volumes": [
{
"attachments": [],
"availability_zone": "nova",
"bootable": "false",
"consistencygroup_id": null,
"created_at": "%(strtime)s",
"description": null,
"encrypted": false,
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "bookmark"
}
],
"metadata": {},
"migration_status": null,
"multiattach": false,
"name": null,
"os-vol-host-attr:host": null,
"os-vol-mig-status-attr:migstat": null,
"os-vol-mig-status-attr:name_id": null,
"os-vol-tenant-attr:tenant_id": "%(uuid)s",
"replication_status": null,
"size": 10,
"snapshot_id": null,
"source_volid": null,
"status": "creating",
"updated_at": null,
"user_id": "%(uuid)s",
"volume_type": null
}
]
}

View File

@ -0,0 +1,18 @@
{
"volumes": [
{
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/v3/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/89afd400-b646-4bbc-b12b-c0a4d63e5bd3/volumes/%(uuid)s",
"rel": "bookmark"
}
],
"name": null
}
]
}

View File

@ -26,7 +26,8 @@ class VolumeTypesSampleJsonTest(api_samples_test_base.ApiSampleTestBase):
self.volume_type_name = "vol-type-001"
self.subs = {
"name": self.volume_type_name,
"description": "volume type 0001"
"description": "volume type 0001",
"bool": "True"
}
CONF.set_override("default_volume_type",
"vol-type-001")
@ -101,7 +102,8 @@ class VolumeTypesSampleJsonTest(api_samples_test_base.ApiSampleTestBase):
subs = {
"name": "vol-type-002",
"description": "volume type 0002"
"description": "volume type 0002",
"bool": "True"
}
self._volume_type_create()
self._volume_type_create(subs)
@ -144,3 +146,16 @@ class VolumeTypesSampleJsonTest(api_samples_test_base.ApiSampleTestBase):
'encryption-type-update-request')
self._verify_response('encryption-type-update-response',
self.subs, response, 200)
def test_private_volume_type_access_add_list(self):
subs = self.subs
subs['bool'] = "False"
res = self._volume_type_create(subs)
res = jsonutils.loads(res.content)['volume_type']
self._do_post('types/%s/action' % res['id'],
'volume-type-access-add-request')
response = self._do_get(
'types/%s/os-volume-type-access' % res['id'])
self._verify_response('volume-type-access-list-response',
{}, response, 200)

View File

@ -0,0 +1,94 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_serialization import jsonutils
from cinder.tests.functional import api_samples_test_base
class VolumesSampleJsonTest(api_samples_test_base.ApiSampleTestBase):
sample_dir = "volumes"
def setUp(self):
super(VolumesSampleJsonTest, self).setUp()
self.response = self._create_volume()
def _create_volume(self, subs=None):
response = self._do_post('volumes',
'volume-create-request',
subs)
return response
def test_volume_list_detail(self):
response = self._do_get('volumes/detail')
self._verify_response('volumes-list-detailed-response',
{}, response, 200)
def test_volume_create(self):
self._verify_response('volume-create-response',
{}, self.response, 202)
def test_volume_list(self):
response = self._do_get('volumes')
self._verify_response('volumes-list-response',
{}, response, 200)
def test_volume_show_detail(self):
res = jsonutils.loads(self.response.content)['volume']
response = self._do_get('volumes/%s' % res['id'])
self._verify_response('volume-show-response',
{}, response, 200)
def test_volume_update(self):
res = jsonutils.loads(self.response.content)['volume']
response = self._do_put('volumes/%s' % res['id'],
'volume-update-request')
self._verify_response('volume-update-response',
{}, response, 200)
def test_volume_metadata_create(self):
res = jsonutils.loads(self.response.content)['volume']
response = self._do_post('volumes/%s/metadata' % res['id'],
'volume-metadata-create-request')
self._verify_response('volume-metadata-create-response',
{}, response, 200)
def test_volume_metadata_show(self):
res = jsonutils.loads(self.response.content)['volume']
response = self._do_get('volumes/%s/metadata' % res['id'])
self._verify_response('volume-metadata-show-response',
{}, response, 200)
def test_volume_metadata_update(self):
res = jsonutils.loads(self.response.content)['volume']
response = self._do_put('volumes/%s/metadata' % res['id'],
'volume-metadata-update-request')
self._verify_response('volume-metadata-update-response',
{}, response, 200)
def test_volume_metadata_show_specific_key(self):
res = jsonutils.loads(self.response.content)['volume']
self._do_put('volumes/%s/metadata' % res['id'],
'volume-metadata-update-request')
response = self._do_get('volumes/%s/metadata/name' % res['id'])
self._verify_response('volume-metadata-show-key-response',
{}, response, 200)