diff --git a/openstack_dashboard/api/cinder.py b/openstack_dashboard/api/cinder.py index aeacc95f99..fddd0ffda2 100644 --- a/openstack_dashboard/api/cinder.py +++ b/openstack_dashboard/api/cinder.py @@ -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: diff --git a/openstack_dashboard/api/microversions.py b/openstack_dashboard/api/microversions.py index a1fba3cb48..a1091eabff 100644 --- a/openstack_dashboard/api/microversions.py +++ b/openstack_dashboard/api/microversions.py @@ -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"], } } diff --git a/openstack_dashboard/test/unit/api/test_cinder.py b/openstack_dashboard/test/unit/api/test_cinder.py index be714c5a8d..5805824ed0 100644 --- a/openstack_dashboard/test/unit/api/test_cinder.py +++ b/openstack_dashboard/test/unit/api/test_cinder.py @@ -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):