Merge "Use correct cinder API version for tenant_absolute_limits"

This commit is contained in:
Zuul 2019-02-12 21:47:21 +00:00 committed by Gerrit Code Review
commit 8bbc18703d
3 changed files with 20 additions and 3 deletions

View File

@ -988,10 +988,24 @@ def qos_specs_list(request):
return [QosSpecs(s) for s in qos_spec_list(request)]
def _cinderclient_with_limits_project_id_query(request):
version = get_microversion(request, ['limits_project_id_query'])
if version is None:
cinder_microversions = microversions.MICROVERSION_FEATURES['cinder']
LOG.warning('Insufficient microversion for GET limits with '
'project_id query. One of the following API micro '
'version is required: %s',
cinder_microversions['limits_project_id_query'])
else:
version = version.get_string()
return cinderclient(request, version=version)
@profiler.trace
@memoized
def tenant_absolute_limits(request, tenant_id=None):
limits = cinderclient(request).limits.get(tenant_id=tenant_id).absolute
_cinderclient = _cinderclient_with_limits_project_id_query(request)
limits = _cinderclient.limits.get(tenant_id=tenant_id).absolute
limits_dict = {}
for limit in limits:
if limit.value < 0:

View File

@ -39,7 +39,8 @@ MICROVERSION_FEATURES = {
"cinder": {
"groups": ["3.27", "3.43", "3.48"],
"consistency_groups": ["2.0", "3.10"],
"message_list": ["3.5", "3.29"]
"message_list": ["3.5", "3.29"],
"limits_project_id_query": ["3.43", "3.50", "3.55"],
}
}

View File

@ -394,7 +394,8 @@ class CinderApiTests(test.APIMockTestCase):
qos_associations_mock.assert_called_once_with(qos_specs_only_one[0].id)
self.assertEqual(associate_spec, qos_specs_only_one[0].name)
@mock.patch.object(api.cinder, 'cinderclient')
@mock.patch.object(api.cinder,
'_cinderclient_with_limits_project_id_query')
def test_absolute_limits_with_negative_values(self, mock_cinderclient):
values = {"maxTotalVolumes": -1, "totalVolumesUsed": -1}
expected_results = {"maxTotalVolumes": float("inf"),
@ -421,6 +422,7 @@ class CinderApiTests(test.APIMockTestCase):
self.assertEqual(expected_results[key], ret_val[key])
mock_limit.assert_called_once()
mock_cinderclient.assert_called_once_with(self.request)
@mock.patch.object(api.cinder, 'cinderclient')
def test_pool_list(self, mock_cinderclient):