Update V2 API to return detailed volume information on create
Current implementation returns only summary information, so cinderclient requires additional GET call to get details. Updated the api to return the details by default so the GET in cinderclient can be removed. Closes-Bug: #1265893 Change-Id: I56d4d79c4a942d8bf53318e46737674dc0bf9b56
This commit is contained in:
parent
01cc78d9ec
commit
c32302c5d5
|
@ -398,7 +398,7 @@ class VolumeController(wsgi.Controller):
|
|||
|
||||
self._add_visible_admin_metadata(context, new_volume)
|
||||
|
||||
retval = self._view_builder.summary(req, new_volume)
|
||||
retval = self._view_builder.detail(req, new_volume)
|
||||
|
||||
return retval
|
||||
|
||||
|
|
|
@ -82,23 +82,32 @@ class VolumeApiTest(test.TestCase):
|
|||
body = {"volume": vol}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes')
|
||||
res_dict = self.controller.create(req, body)
|
||||
expected = {
|
||||
'volume': {
|
||||
'name': 'Volume Test Name',
|
||||
'id': '1',
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
'href': 'http://localhost/fake/volumes/1',
|
||||
'rel': 'bookmark'
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
self.assertEqual(res_dict, expected)
|
||||
ex = {'volume': {'attachments':
|
||||
[{'device': '/',
|
||||
'host_name': None,
|
||||
'id': '1',
|
||||
'server_id': 'fakeuuid',
|
||||
'volume_id': '1'}],
|
||||
'availability_zone': 'zone1:host1',
|
||||
'bootable': 'false',
|
||||
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
|
||||
'description': 'Volume Test Desc',
|
||||
'id': '1',
|
||||
'links':
|
||||
[{'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'rel': 'self'},
|
||||
{'href': 'http://localhost/fake/volumes/1',
|
||||
'rel': 'bookmark'}],
|
||||
'metadata': {'attached_mode': 'rw',
|
||||
'readonly': 'False'},
|
||||
'name': 'Volume Test Name',
|
||||
'size': 100,
|
||||
'snapshot_id': None,
|
||||
'source_volid': None,
|
||||
'status': 'fakestatus',
|
||||
'user_id': 'fakeuser',
|
||||
'volume_type': 'vol_type_name'}}
|
||||
self.assertEqual(res_dict, ex)
|
||||
|
||||
def test_volume_create_with_type(self):
|
||||
vol_type = db.volume_type_create(
|
||||
|
@ -176,26 +185,34 @@ class VolumeApiTest(test.TestCase):
|
|||
"description": "Volume Test Desc",
|
||||
"availability_zone": "nova",
|
||||
"imageRef": 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'}
|
||||
expected = {
|
||||
'volume': {
|
||||
'name': 'Volume Test Name',
|
||||
'id': '1',
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
'href': 'http://localhost/fake/volumes/1',
|
||||
'rel': 'bookmark'
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
ex = {'volume': {'attachments': [{'device': '/',
|
||||
'host_name': None,
|
||||
'id': '1',
|
||||
'server_id': 'fakeuuid',
|
||||
'volume_id': '1'}],
|
||||
'availability_zone': 'nova',
|
||||
'bootable': 'false',
|
||||
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
|
||||
'description': 'Volume Test Desc',
|
||||
'id': '1',
|
||||
'links':
|
||||
[{'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'rel': 'self'},
|
||||
{'href': 'http://localhost/fake/volumes/1',
|
||||
'rel': 'bookmark'}],
|
||||
'metadata': {'attached_mode': 'rw',
|
||||
'readonly': 'False'},
|
||||
'name': 'Volume Test Name',
|
||||
'size': '1',
|
||||
'snapshot_id': None,
|
||||
'source_volid': None,
|
||||
'status': 'fakestatus',
|
||||
'user_id': 'fakeuser',
|
||||
'volume_type': 'vol_type_name'}}
|
||||
body = {"volume": vol}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes')
|
||||
res_dict = self.controller.create(req, body)
|
||||
self.assertEqual(res_dict, expected)
|
||||
self.assertEqual(res_dict, ex)
|
||||
|
||||
def test_volume_create_with_image_id_is_integer(self):
|
||||
self.stubs.Set(volume_api.API, "create", stubs.stub_volume_create)
|
||||
|
|
Loading…
Reference in New Issue