From 6fba7163e85a436d1fe0660d9932a53d06b1a343 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Fri, 5 Aug 2016 12:07:13 +0800 Subject: [PATCH] Set quota "per_volume_gigabytes", "backup_gigabytes" and "backups" "per_volume_gigabytes", "backup_gigabytes" and "backups" items can be shown in "openstack quota show" command, but can't be updated by "openstack quota set". This patch fix the issue. Change-Id: I47db5a69d4e4ef6e140f2735257c83e1fb052760 Closes-Bug: #1609767 --- doc/source/command-objects/quota.rst | 26 ++++++++++++++++--- openstackclient/common/quota.py | 12 ++++++++- .../tests/unit/common/test_quota.py | 22 ++++++++++++++++ .../notes/bug-1609767-0602edc4408c2dc6.yaml | 5 ++++ 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/bug-1609767-0602edc4408c2dc6.yaml diff --git a/doc/source/command-objects/quota.rst b/doc/source/command-objects/quota.rst index 381601db77..4dc5b17150 100644 --- a/doc/source/command-objects/quota.rst +++ b/doc/source/command-objects/quota.rst @@ -2,9 +2,10 @@ quota ===== -Resource quotas appear in multiple APIs, OpenStackClient presents them as a single object with multiple properties. +Resource quotas appear in multiple APIs, OpenStackClient presents them as a +single object with multiple properties. -Block Storage v1, Compute v2, Network v2 +Block Storage v1, v2, Compute v2, Network v2 quota set --------- @@ -29,7 +30,10 @@ Set quotas for project [--server-group-members ] # Block Storage settings + [--backups ] + [--backup-gigabytes ] [--gigabytes ] + [--per-volume-gigabytes ] [--snapshots ] [--volumes ] [--volume-type ] @@ -70,7 +74,10 @@ Set quotas for class [--server-group-members ] # Block Storage settings + [--backups ] + [--backup-gigabytes ] [--gigabytes ] + [--per-volume-gigabytes ] [--snapshots ] [--volumes ] @@ -136,10 +143,22 @@ Set quotas for class New value for the injected-path-size quota +.. option:: --backups + + New value for the backups quota + +.. option:: --backup-gigabytes + + New value for the backup gigabytes quota + .. option:: --gigabytes New value for the gigabytes quota +.. option:: --per-volume-gigabytes + + New value for the gigabytes quota of per volume + .. option:: --volumes New value for the volumes quota @@ -150,7 +169,8 @@ Set quotas for class .. option:: --volume-type - Set quotas for a specific + Set quotas for a specific . The supported quotas are: + gigabytes, snapshots, volumes. .. option:: --networks diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py index 5d53171c33..8ae6f7d485 100644 --- a/openstackclient/common/quota.py +++ b/openstackclient/common/quota.py @@ -43,11 +43,20 @@ COMPUTE_QUOTAS = { } VOLUME_QUOTAS = { + 'backups': 'backups', + 'backup_gigabytes': 'backup-gigabytes', 'gigabytes': 'gigabytes', + 'per_volume_gigabytes': 'per-volume-gigabytes', 'snapshots': 'snapshots', 'volumes': 'volumes', } +IMPACT_VOLUME_TYPE_QUOTAS = [ + 'gigabytes', + 'snapshots', + 'volumes', +] + NOVA_NETWORK_QUOTAS = { 'floating_ips': 'floating-ips', 'security_group_rules': 'secgroup-rules', @@ -128,7 +137,8 @@ class SetQuota(command.Command): for k, v in VOLUME_QUOTAS.items(): value = getattr(parsed_args, k, None) if value is not None: - if parsed_args.volume_type: + if (parsed_args.volume_type and + k in IMPACT_VOLUME_TYPE_QUOTAS): k = k + '_%s' % parsed_args.volume_type volume_kwargs[k] = value diff --git a/openstackclient/tests/unit/common/test_quota.py b/openstackclient/tests/unit/common/test_quota.py index 7edd4186b0..cbe4cb80ec 100644 --- a/openstackclient/tests/unit/common/test_quota.py +++ b/openstackclient/tests/unit/common/test_quota.py @@ -158,12 +158,20 @@ class TestQuotaSet(TestQuota): '--gigabytes', str(volume_fakes.QUOTA['gigabytes']), '--snapshots', str(volume_fakes.QUOTA['snapshots']), '--volumes', str(volume_fakes.QUOTA['volumes']), + '--backups', str(volume_fakes.QUOTA['backups']), + '--backup-gigabytes', str(volume_fakes.QUOTA['backup_gigabytes']), + '--per-volume-gigabytes', + str(volume_fakes.QUOTA['per_volume_gigabytes']), identity_fakes.project_name, ] verifylist = [ ('gigabytes', volume_fakes.QUOTA['gigabytes']), ('snapshots', volume_fakes.QUOTA['snapshots']), ('volumes', volume_fakes.QUOTA['volumes']), + ('backups', volume_fakes.QUOTA['backups']), + ('backup_gigabytes', volume_fakes.QUOTA['backup_gigabytes']), + ('per_volume_gigabytes', + volume_fakes.QUOTA['per_volume_gigabytes']), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -174,6 +182,9 @@ class TestQuotaSet(TestQuota): 'gigabytes': volume_fakes.QUOTA['gigabytes'], 'snapshots': volume_fakes.QUOTA['snapshots'], 'volumes': volume_fakes.QUOTA['volumes'], + 'backups': volume_fakes.QUOTA['backups'], + 'backup_gigabytes': volume_fakes.QUOTA['backup_gigabytes'], + 'per_volume_gigabytes': volume_fakes.QUOTA['per_volume_gigabytes'] } self.volume_quotas_mock.update.assert_called_once_with( @@ -188,6 +199,10 @@ class TestQuotaSet(TestQuota): '--gigabytes', str(volume_fakes.QUOTA['gigabytes']), '--snapshots', str(volume_fakes.QUOTA['snapshots']), '--volumes', str(volume_fakes.QUOTA['volumes']), + '--backups', str(volume_fakes.QUOTA['backups']), + '--backup-gigabytes', str(volume_fakes.QUOTA['backup_gigabytes']), + '--per-volume-gigabytes', + str(volume_fakes.QUOTA['per_volume_gigabytes']), '--volume-type', 'volume_type_backend', identity_fakes.project_name, ] @@ -195,6 +210,10 @@ class TestQuotaSet(TestQuota): ('gigabytes', volume_fakes.QUOTA['gigabytes']), ('snapshots', volume_fakes.QUOTA['snapshots']), ('volumes', volume_fakes.QUOTA['volumes']), + ('backups', volume_fakes.QUOTA['backups']), + ('backup_gigabytes', volume_fakes.QUOTA['backup_gigabytes']), + ('per_volume_gigabytes', + volume_fakes.QUOTA['per_volume_gigabytes']), ('volume_type', 'volume_type_backend'), ] @@ -206,6 +225,9 @@ class TestQuotaSet(TestQuota): 'gigabytes_volume_type_backend': volume_fakes.QUOTA['gigabytes'], 'snapshots_volume_type_backend': volume_fakes.QUOTA['snapshots'], 'volumes_volume_type_backend': volume_fakes.QUOTA['volumes'], + 'backups': volume_fakes.QUOTA['backups'], + 'backup_gigabytes': volume_fakes.QUOTA['backup_gigabytes'], + 'per_volume_gigabytes': volume_fakes.QUOTA['per_volume_gigabytes'] } self.volume_quotas_mock.update.assert_called_once_with( diff --git a/releasenotes/notes/bug-1609767-0602edc4408c2dc6.yaml b/releasenotes/notes/bug-1609767-0602edc4408c2dc6.yaml new file mode 100644 index 0000000000..edb241fbe9 --- /dev/null +++ b/releasenotes/notes/bug-1609767-0602edc4408c2dc6.yaml @@ -0,0 +1,5 @@ +--- +features: + - Support to update ``per_volume_gigabytes``, ``backup_gigabytes`` and + ``backups`` quota in ``quota set`` command. + [Bug `1609767 `_]