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
This commit is contained in:
Cloud User 2020-10-01 22:24:44 +00:00 committed by Carlos Eduardo
parent 5f433b59ba
commit 6bb021375c
4 changed files with 33 additions and 4 deletions

View File

@ -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

View File

@ -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.

View File

@ -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"]

View File

@ -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