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
This commit is contained in:
Rui Chen 2016-08-05 12:07:13 +08:00
parent 4e71e9da6b
commit 6fba7163e8
4 changed files with 61 additions and 4 deletions

View File

@ -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 <num-server-group-members>]
# Block Storage settings
[--backups <new-backups>]
[--backup-gigabytes <new-backup-gigabytes>]
[--gigabytes <new-gigabytes>]
[--per-volume-gigabytes <new-per-volume-gigabytes>]
[--snapshots <new-snapshots>]
[--volumes <new-volumes>]
[--volume-type <volume-type>]
@ -70,7 +74,10 @@ Set quotas for class
[--server-group-members <num-server-group-members>]
# Block Storage settings
[--backups <new-backups>]
[--backup-gigabytes <new-backup-gigabytes>]
[--gigabytes <new-gigabytes>]
[--per-volume-gigabytes <new-per-volume-gigabytes>]
[--snapshots <new-snapshots>]
[--volumes <new-volumes>]
@ -136,10 +143,22 @@ Set quotas for class
New value for the injected-path-size quota
.. option:: --backups <new-backups>
New value for the backups quota
.. option:: --backup-gigabytes <new-backup-gigabytes>
New value for the backup gigabytes quota
.. option:: --gigabytes <new-gigabytes>
New value for the gigabytes quota
.. option:: --per-volume-gigabytes <new-per-volume-gigabytes>
New value for the gigabytes quota of per volume
.. option:: --volumes <new-volumes>
New value for the volumes quota
@ -150,7 +169,8 @@ Set quotas for class
.. option:: --volume-type <volume-type>
Set quotas for a specific <volume-type>
Set quotas for a specific <volume-type>. The supported quotas are:
gigabytes, snapshots, volumes.
.. option:: --networks <num-networks>

View File

@ -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

View File

@ -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(

View File

@ -0,0 +1,5 @@
---
features:
- Support to update ``per_volume_gigabytes``, ``backup_gigabytes`` and
``backups`` quota in ``quota set`` command.
[Bug `1609767 <https://bugs.launchpad.net/python-openstackclient/+bug/1609767>`_]