From df1b9e4f8ca877a7caddcbb9afc66de225a8dd21 Mon Sep 17 00:00:00 2001 From: Rajat Dhasmana Date: Tue, 15 Apr 2025 14:05:15 +0530 Subject: [PATCH] Fix: Quota show defaults The ``quota show --default`` command has the URL ``os-quota-sets/{project_id}/defaults`` whereas we used ``os-quota-sets/defaults`` which results in passes "defaults" as the project ID. This was uncovered by adding project ID validation in the cinder quotas API[2]. Closes-Bug: #2107375 [1] https://docs.openstack.org/api-ref/block-storage/v3/#get-default-quotas-for-a-project [2] https://review.opendev.org/c/openstack/cinder/+/784763 Change-Id: Ibc8a084dbf41f18af28ab5592d9f5638f481c007 --- openstack/block_storage/v3/_proxy.py | 4 +++- openstack/tests/unit/block_storage/v3/test_proxy.py | 5 +++-- .../notes/fix-quota-show-defaults-0a8c388926eae18b.yaml | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/fix-quota-show-defaults-0a8c388926eae18b.yaml diff --git a/openstack/block_storage/v3/_proxy.py b/openstack/block_storage/v3/_proxy.py index b7cfef0c6..421644aa0 100644 --- a/openstack/block_storage/v3/_proxy.py +++ b/openstack/block_storage/v3/_proxy.py @@ -2024,7 +2024,9 @@ class Proxy(proxy.Proxy): res = self._get_resource( _quota_set.QuotaSet, None, project_id=project.id ) - return res.fetch(self, base_path='/os-quota-sets/defaults') + return res.fetch( + self, base_path=(f'/os-quota-sets/{project.id}/defaults') + ) def revert_quota_set(self, project, **query): """Reset Quota for the project/user. diff --git a/openstack/tests/unit/block_storage/v3/test_proxy.py b/openstack/tests/unit/block_storage/v3/test_proxy.py index 67f8778a7..eb4cbfe8e 100644 --- a/openstack/tests/unit/block_storage/v3/test_proxy.py +++ b/openstack/tests/unit/block_storage/v3/test_proxy.py @@ -1176,14 +1176,15 @@ class TestQuotaSet(TestVolumeProxy): ) def test_quota_set_get_defaults(self): + project_id = 'prj' self._verify( 'openstack.resource.Resource.fetch', self.proxy.get_quota_set_defaults, - method_args=['prj'], + method_args=[project_id], expected_args=[ self.proxy, False, - '/os-quota-sets/defaults', + f'/os-quota-sets/{project_id}/defaults', None, False, ], diff --git a/releasenotes/notes/fix-quota-show-defaults-0a8c388926eae18b.yaml b/releasenotes/notes/fix-quota-show-defaults-0a8c388926eae18b.yaml new file mode 100644 index 000000000..428abef0e --- /dev/null +++ b/releasenotes/notes/fix-quota-show-defaults-0a8c388926eae18b.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixed issue with ``quota show --default`` command by + correcting the API URL.