Merge "Return share_type UUID instead of name in Share API"
This commit is contained in:
commit
40a1f9538a
@ -51,6 +51,7 @@ REST_API_VERSION_HISTORY = """
|
||||
* 2.3 - Share instances admin API
|
||||
* 2.4 - Consistency Group support
|
||||
* 2.5 - Share Migration admin API
|
||||
* 2.6 - Return share_type UUID instead of name in Share API
|
||||
|
||||
"""
|
||||
|
||||
@ -58,7 +59,7 @@ REST_API_VERSION_HISTORY = """
|
||||
# The default api version request is defined to be the
|
||||
# the minimum version of the API supported.
|
||||
_MIN_API_VERSION = "2.0"
|
||||
_MAX_API_VERSION = "2.5"
|
||||
_MAX_API_VERSION = "2.6"
|
||||
DEFAULT_API_VERSION = _MIN_API_VERSION
|
||||
|
||||
|
||||
|
@ -56,3 +56,8 @@ user documentation.
|
||||
2.5
|
||||
---
|
||||
Share Migration admin API.
|
||||
|
||||
2.6
|
||||
---
|
||||
Return share_type UUID instead of name in Share API and add share_type_name
|
||||
field.
|
||||
|
@ -20,7 +20,10 @@ class ViewBuilder(common.ViewBuilder):
|
||||
"""Model a server API response as a python dictionary."""
|
||||
|
||||
_collection_name = 'shares'
|
||||
_detail_version_modifiers = ["add_consistency_group_fields"]
|
||||
_detail_version_modifiers = [
|
||||
"add_consistency_group_fields",
|
||||
"modify_share_type_field",
|
||||
]
|
||||
|
||||
def summary_list(self, request, shares):
|
||||
"""Show a list of shares without many details."""
|
||||
@ -92,6 +95,19 @@ class ViewBuilder(common.ViewBuilder):
|
||||
share_dict['source_cgsnapshot_member_id'] = share.get(
|
||||
'source_cgsnapshot_member_id')
|
||||
|
||||
@common.ViewBuilder.versioned_method("2.6")
|
||||
def modify_share_type_field(self, share_dict, share):
|
||||
share_type = share.get('share_type_id')
|
||||
|
||||
share_type_name = None
|
||||
if share.get('share_type'):
|
||||
share_type_name = share.get('share_type').get('name')
|
||||
|
||||
share_dict.update({
|
||||
'share_type_name': share_type_name,
|
||||
'share_type': share_type,
|
||||
})
|
||||
|
||||
def _list_view(self, func, request, shares):
|
||||
"""Provide a view for a list of shares."""
|
||||
shares_list = [func(request, share)['share'] for share in shares]
|
||||
|
@ -425,6 +425,15 @@ class ShareApiTest(test.TestCase):
|
||||
expected['share']['source_cgsnapshot_member_id'] = None
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
def test_share_show_with_share_type_name(self):
|
||||
req = fakes.HTTPRequest.blank('/shares/1', version='2.6')
|
||||
res_dict = self.controller.show(req, '1')
|
||||
expected = self._get_expected_share_detailed_response()
|
||||
expected['share']['consistency_group_id'] = None
|
||||
expected['share']['source_cgsnapshot_member_id'] = None
|
||||
expected['share']['share_type_name'] = None
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
def test_share_show_admin(self):
|
||||
req = fakes.HTTPRequest.blank('/shares/1', use_admin_context=True)
|
||||
res_dict = self.controller.show(req, '1')
|
||||
|
47
manila/tests/api/views/test_shares.py
Normal file
47
manila/tests/api/views/test_shares.py
Normal file
@ -0,0 +1,47 @@
|
||||
# Copyright (c) 2015 Mirantis, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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 manila.api.views import shares
|
||||
from manila import test
|
||||
from manila.tests.api import fakes
|
||||
|
||||
|
||||
class ViewBuilderTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ViewBuilderTestCase, self).setUp()
|
||||
self.builder = shares.ViewBuilder()
|
||||
self.req = fakes.HTTPRequest.blank('/shares', version="2.6")
|
||||
|
||||
def test__collection_name(self):
|
||||
self.assertEqual('shares', self.builder._collection_name)
|
||||
|
||||
def test_detail_v_2_6(self):
|
||||
fake_share = {
|
||||
'id': 'fake_id',
|
||||
'share_type_id': 'fake_share_type_id',
|
||||
'share_type': {'name': 'fake_share_type_name'}
|
||||
}
|
||||
|
||||
actual_result = self.builder.detail(self.req, fake_share)
|
||||
|
||||
self.assertSubDictMatch(
|
||||
{
|
||||
'id': fake_share['id'],
|
||||
'share_type': fake_share['share_type_id'],
|
||||
'share_type_name': fake_share['share_type']['name'],
|
||||
},
|
||||
actual_result['share']
|
||||
)
|
@ -36,7 +36,7 @@ ShareGroup = [
|
||||
help="The minimum api microversion is configured to be the "
|
||||
"value of the minimum microversion supported by Manila."),
|
||||
cfg.StrOpt("max_api_microversion",
|
||||
default="2.5",
|
||||
default="2.6",
|
||||
help="The maximum api microversion is configured to be the "
|
||||
"value of the latest microversion supported by Manila."),
|
||||
cfg.StrOpt("region",
|
||||
|
@ -67,9 +67,19 @@ class ShareMultiBackendTest(base.BaseSharesAdminTest):
|
||||
def test_share_share_type(self):
|
||||
# Share type should be the same as provided with share creation
|
||||
for i in [0, 1]:
|
||||
get = self.shares_client.get_share(self.shares[i]['id'])
|
||||
get = self.shares_v2_client.get_share(self.shares[i]['id'],
|
||||
version="2.5")
|
||||
self.assertEqual(get["share_type"], self.sts[i]["name"])
|
||||
|
||||
@test.attr(type=["gate", "smoke", ])
|
||||
def test_share_share_type_v_2_6(self):
|
||||
# Share type should be the same as provided with share creation
|
||||
for i in [0, 1]:
|
||||
get = self.shares_v2_client.get_share(self.shares[i]['id'],
|
||||
version="2.6")
|
||||
self.assertEqual(get["share_type"], self.sts[i]["id"])
|
||||
self.assertEqual(get["share_type_name"], self.sts[i]["name"])
|
||||
|
||||
@test.attr(type=["gate", ])
|
||||
def test_share_export_locations(self):
|
||||
# Different backends have different IPs on interfaces
|
||||
|
@ -107,13 +107,16 @@ class ManageNFSShareTest(base.BaseSharesAdminTest):
|
||||
self.shares_client.wait_for_share_status(share['id'], 'available')
|
||||
|
||||
# Verify data of managed share
|
||||
get = self.shares_client.get_share(share['id'])
|
||||
get = self.shares_v2_client.get_share(share['id'], version="2.5")
|
||||
self.assertEqual(name, get['name'])
|
||||
self.assertEqual(description, get['description'])
|
||||
self.assertEqual(self.share1['host'], get['host'])
|
||||
self.assertEqual(self.share1['share_proto'], get['share_proto'])
|
||||
self.assertEqual(self.st['share_type']['name'], get['share_type'])
|
||||
|
||||
get = self.shares_v2_client.get_share(share['id'], version="2.6")
|
||||
self.assertEqual(self.st['share_type']['id'], get['share_type'])
|
||||
|
||||
# Delete share
|
||||
self.shares_client.delete_share(share['id'])
|
||||
self.shares_client.wait_for_resource_deletion(share_id=share['id'])
|
||||
|
@ -107,11 +107,15 @@ class ShareTypesAdminTest(base.BaseSharesAdminTest):
|
||||
self.shares_client.wait_for_share_status(share["id"], "available")
|
||||
|
||||
# Verify share info
|
||||
get = self.shares_client.get_share(share["id"])
|
||||
get = self.shares_v2_client.get_share(share["id"], version="2.5")
|
||||
self.assertEqual(share_name, get["name"])
|
||||
self.assertEqual(share["id"], get["id"])
|
||||
self.assertEqual(shr_type_name, get["share_type"])
|
||||
|
||||
get = self.shares_v2_client.get_share(share["id"], version="2.6")
|
||||
self.assertEqual(st_create["share_type"]["id"], get["share_type"])
|
||||
self.assertEqual(shr_type_name, get["share_type_name"])
|
||||
|
||||
def test_private_share_type_access(self):
|
||||
name = data_utils.rand_name("tempest-manila")
|
||||
extra_specs = self.add_required_extra_specs_to_dict({"key": "value", })
|
||||
|
Loading…
Reference in New Issue
Block a user