From 6bb021375ca837d218d9d9db23d025073ac3d4eb Mon Sep 17 00:00:00 2001 From: Cloud User Date: Thu, 1 Oct 2020 22:24:44 +0000 Subject: [PATCH] Fix missing group and group_snapshots in absolute limits Modified limits API to make it return the max number of share_groups and share_group_snapshots, as well as the total number of resources used Change-Id: Ia4e69219b107fc0630cb9e97401b9a8bda5b1adc Closes-Bug: #1868644 --- manila/api/openstack/api_version_request.py | 4 +++- manila/api/openstack/rest_api_version_history.rst | 8 ++++++-- manila/api/views/limits.py | 10 ++++++++++ manila/tests/api/v1/test_limits.py | 15 ++++++++++++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/manila/api/openstack/api_version_request.py b/manila/api/openstack/api_version_request.py index d4541b6591..d7a9cf41eb 100644 --- a/manila/api/openstack/api_version_request.py +++ b/manila/api/openstack/api_version_request.py @@ -156,13 +156,15 @@ REST_API_VERSION_HISTORY = """ 'share_server_migration_start' 'share_server_migration_get_progress' 'share_server_reset_task_state' + * 2.58 - Added 'share_groups' and 'share_group_snapshots' to the limits + view. """ # The minimum and maximum versions of the API supported # The default api version request is defined to be the # minimum version of the API supported. _MIN_API_VERSION = "2.0" -_MAX_API_VERSION = "2.57" +_MAX_API_VERSION = "2.58" DEFAULT_API_VERSION = _MIN_API_VERSION diff --git a/manila/api/openstack/rest_api_version_history.rst b/manila/api/openstack/rest_api_version_history.rst index 3b8beecd6f..04d22f6e91 100644 --- a/manila/api/openstack/rest_api_version_history.rst +++ b/manila/api/openstack/rest_api_version_history.rst @@ -310,7 +310,11 @@ user documentation. ---- Share replication feature is no longer considered experimental. -2.57 ----- +2.57 (Maximum in Victoria) +-------------------------- Added share server migration feature. A two-phase approach that migrates a share server and all its resources to a new host. + +2.58 +---- + Added 'share_groups' and 'share_group_snapshots' to the limits view. diff --git a/manila/api/views/limits.py b/manila/api/views/limits.py index 1f499f503a..9df28166b5 100644 --- a/manila/api/views/limits.py +++ b/manila/api/views/limits.py @@ -25,6 +25,7 @@ class ViewBuilder(common.ViewBuilder): _collection_name = "limits" _detail_version_modifiers = [ "add_share_replica_quotas", + "add_share_group_quotas" ] def build(self, request, rate_limits, absolute_limits): @@ -110,6 +111,15 @@ class ViewBuilder(common.ViewBuilder): "next-available": utils.isotime(at=next_avail), } + @common.ViewBuilder.versioned_method("2.58") + def add_share_group_quotas(self, request, limit_names, absolute_limits): + limit_names["limit"]["share_groups"] = ["maxTotalShareGroups"] + limit_names["limit"]["share_group_snapshots"] = ( + ["maxTotalShareGroupSnapshots"]) + limit_names["in_use"]["share_groups"] = ["totalShareGroupsUsed"] + limit_names["in_use"]["share_group_snapshots"] = ( + ["totalShareGroupSnapshotsUsed"]) + @common.ViewBuilder.versioned_method("2.53") def add_share_replica_quotas(self, request, limit_names, absolute_limits): limit_names["limit"]["share_replicas"] = ["maxTotalShareReplicas"] diff --git a/manila/tests/api/v1/test_limits.py b/manila/tests/api/v1/test_limits.py index 0444d8b66b..b13ffa6321 100644 --- a/manila/tests/api/v1/test_limits.py +++ b/manila/tests/api/v1/test_limits.py @@ -39,7 +39,8 @@ TEST_LIMITS = [ limits.Limit("PUT", "*", "", 10, limits.PER_MINUTE), limits.Limit("PUT", "/shares", "^/shares", 5, limits.PER_MINUTE), ] -SHARE_REPLICAS_LIMIT_MICROVERSION = "2.53" +SHARE_REPLICAS_LIMIT_MICROVERSION = "2.58" +SHARE_GROUP_QUOTA_MICROVERSION = "2.40" class BaseLimitTestSuite(test.TestCase): @@ -130,6 +131,12 @@ class LimitsControllerTest(BaseLimitTestSuite): }, } + if microversion == SHARE_GROUP_QUOTA_MICROVERSION: + self.absolute_limits['limit']['share_groups'] = 20 + self.absolute_limits['limit']['share_group_snapshots'] = 20 + self.absolute_limits['in_use']['share_groups'] = 3 + self.absolute_limits['in_use']['share_group_snapshots'] = 3 + if microversion == SHARE_REPLICAS_LIMIT_MICROVERSION: self.absolute_limits['limit']['share_replicas'] = 20 self.absolute_limits['limit']['replica_gigabytes'] = 20 @@ -190,6 +197,12 @@ class LimitsControllerTest(BaseLimitTestSuite): }, }, } + if microversion == SHARE_GROUP_QUOTA_MICROVERSION: + expected['limits']['absolute']["maxTotalShareGroups"] = 20 + expected['limits']['absolute']["totalShareGroupsUsed"] = 3 + expected['limits']['absolute']["maxTotalShareGroupSnapshots"] = 20 + expected['limits']['absolute']["totalShareGroupSnapshots"] = 3 + if microversion == SHARE_REPLICAS_LIMIT_MICROVERSION: expected['limits']['absolute']["maxTotalShareReplicas"] = 20 expected['limits']['absolute']["totalShareReplicasUsed"] = 3