From 3ec364d1fd1f060a2dbd2c73c17e6ccc55bdcf55 Mon Sep 17 00:00:00 2001 From: Goutham Pacha Ravi Date: Fri, 26 Jan 2024 11:43:49 -0800 Subject: [PATCH] Fix "per_share_gigabytes" in "openstack quota set" The "per_share_gigabytes" quota param was introduced in API version 2.62; when using older API versions, we shouldn't be setting this parameter. Closes-Bug: #2047249 Change-Id: I1eceee52726cef3494648521e4516010ca02f095 --- manilaclient/osc/v2/quotas.py | 1 - manilaclient/tests/unit/osc/v2/test_quotas.py | 24 +++++++++++++------ ...-per-share-gigabytes-fcff7f8ce2cc3c75.yaml | 6 +++++ 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 releasenotes/notes/bug-2047249-fix-osc-quota-set-per-share-gigabytes-fcff7f8ce2cc3c75.yaml diff --git a/manilaclient/osc/v2/quotas.py b/manilaclient/osc/v2/quotas.py index 532ffdb7c..bde7d341e 100644 --- a/manilaclient/osc/v2/quotas.py +++ b/manilaclient/osc/v2/quotas.py @@ -160,7 +160,6 @@ class QuotaSet(command.Command): "gigabytes": parsed_args.gigabytes, "snapshot_gigabytes": parsed_args.snapshot_gigabytes, "share_networks": parsed_args.share_networks, - "per_share_gigabytes": parsed_args.per_share_gigabytes, } if parsed_args.share_type is not None: diff --git a/manilaclient/tests/unit/osc/v2/test_quotas.py b/manilaclient/tests/unit/osc/v2/test_quotas.py index d3cb93b34..3de794693 100644 --- a/manilaclient/tests/unit/osc/v2/test_quotas.py +++ b/manilaclient/tests/unit/osc/v2/test_quotas.py @@ -78,8 +78,7 @@ class TestQuotaSet(TestQuotas): share_networks=None, shares=40, snapshot_gigabytes=None, - snapshots=None, - per_share_gigabytes=None) + snapshots=None) self.assertIsNone(result) mock_find_resource.assert_not_called() self.quotas_mock.assert_not_called() @@ -107,7 +106,6 @@ class TestQuotaSet(TestQuotas): shares=40, snapshot_gigabytes=None, snapshots=None, - per_share_gigabytes=None, tenant_id=self.project.id, user_id=None) self.assertIsNone(result) @@ -135,7 +133,6 @@ class TestQuotaSet(TestQuotas): shares=None, snapshot_gigabytes=None, snapshots=None, - per_share_gigabytes=None, tenant_id=self.project.id, user_id=None) self.assertIsNone(result) @@ -164,7 +161,6 @@ class TestQuotaSet(TestQuotas): shares=None, snapshot_gigabytes=None, snapshots=None, - per_share_gigabytes=None, tenant_id=self.project.id, user_id=None) self.assertIsNone(result) @@ -195,7 +191,6 @@ class TestQuotaSet(TestQuotas): snapshot_gigabytes=None, snapshots=None, tenant_id=self.project.id, - per_share_gigabytes=None, user_id=None) self.assertIsNone(result) @@ -290,7 +285,6 @@ class TestQuotaSet(TestQuotas): shares=None, snapshot_gigabytes=None, snapshots=None, - per_share_gigabytes=None, tenant_id=self.project.id, user_id=None) self.assertIsNone(result) @@ -311,6 +305,22 @@ class TestQuotaSet(TestQuotas): self.assertRaises( exceptions.CommandError, self.cmd.take_action, parsed_args) + def test_quota_set_per_share_gigabytes_exception(self): + self.app.client_manager.share.api_version = api_versions.APIVersion( + '2.61') + arglist = [ + self.project.id, + '--per-share-gigabytes', '10', + ] + verifylist = [ + ('project', self.project.id), + ('per_share_gigabytes', 10) + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + self.assertRaises( + exceptions.CommandError, self.cmd.take_action, parsed_args) + def test_quota_set_per_share_gigabytes(self): arglist = [ self.project.id, diff --git a/releasenotes/notes/bug-2047249-fix-osc-quota-set-per-share-gigabytes-fcff7f8ce2cc3c75.yaml b/releasenotes/notes/bug-2047249-fix-osc-quota-set-per-share-gigabytes-fcff7f8ce2cc3c75.yaml new file mode 100644 index 000000000..646eaba6e --- /dev/null +++ b/releasenotes/notes/bug-2047249-fix-osc-quota-set-per-share-gigabytes-fcff7f8ce2cc3c75.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + The `openstack share quota set` command has been fixed to not set + `per_share_gigabytes` unless the user has specified the parameter, and + unless the user requests, and the server supports API version 2.62.