Skip to content

Commit ed4454c

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Set quota "per_volume_gigabytes", "backup_gigabytes" and "backups""
2 parents c8ecd9a + 6fba716 commit ed4454c

4 files changed

Lines changed: 61 additions & 4 deletions

File tree

doc/source/command-objects/quota.rst

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
quota
33
=====
44

5-
Resource quotas appear in multiple APIs, OpenStackClient presents them as a single object with multiple properties.
5+
Resource quotas appear in multiple APIs, OpenStackClient presents them as a
6+
single object with multiple properties.
67

7-
Block Storage v1, Compute v2, Network v2
8+
Block Storage v1, v2, Compute v2, Network v2
89

910
quota set
1011
---------
@@ -29,7 +30,10 @@ Set quotas for project
2930
[--server-group-members <num-server-group-members>]
3031
3132
# Block Storage settings
33+
[--backups <new-backups>]
34+
[--backup-gigabytes <new-backup-gigabytes>]
3235
[--gigabytes <new-gigabytes>]
36+
[--per-volume-gigabytes <new-per-volume-gigabytes>]
3337
[--snapshots <new-snapshots>]
3438
[--volumes <new-volumes>]
3539
[--volume-type <volume-type>]
@@ -70,7 +74,10 @@ Set quotas for class
7074
[--server-group-members <num-server-group-members>]
7175
7276
# Block Storage settings
77+
[--backups <new-backups>]
78+
[--backup-gigabytes <new-backup-gigabytes>]
7379
[--gigabytes <new-gigabytes>]
80+
[--per-volume-gigabytes <new-per-volume-gigabytes>]
7481
[--snapshots <new-snapshots>]
7582
[--volumes <new-volumes>]
7683
@@ -136,10 +143,22 @@ Set quotas for class
136143

137144
New value for the injected-path-size quota
138145

146+
.. option:: --backups <new-backups>
147+
148+
New value for the backups quota
149+
150+
.. option:: --backup-gigabytes <new-backup-gigabytes>
151+
152+
New value for the backup gigabytes quota
153+
139154
.. option:: --gigabytes <new-gigabytes>
140155

141156
New value for the gigabytes quota
142157

158+
.. option:: --per-volume-gigabytes <new-per-volume-gigabytes>
159+
160+
New value for the gigabytes quota of per volume
161+
143162
.. option:: --volumes <new-volumes>
144163

145164
New value for the volumes quota
@@ -150,7 +169,8 @@ Set quotas for class
150169

151170
.. option:: --volume-type <volume-type>
152171

153-
Set quotas for a specific <volume-type>
172+
Set quotas for a specific <volume-type>. The supported quotas are:
173+
gigabytes, snapshots, volumes.
154174

155175
.. option:: --networks <num-networks>
156176

openstackclient/common/quota.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,20 @@
4343
}
4444

4545
VOLUME_QUOTAS = {
46+
'backups': 'backups',
47+
'backup_gigabytes': 'backup-gigabytes',
4648
'gigabytes': 'gigabytes',
49+
'per_volume_gigabytes': 'per-volume-gigabytes',
4750
'snapshots': 'snapshots',
4851
'volumes': 'volumes',
4952
}
5053

54+
IMPACT_VOLUME_TYPE_QUOTAS = [
55+
'gigabytes',
56+
'snapshots',
57+
'volumes',
58+
]
59+
5160
NOVA_NETWORK_QUOTAS = {
5261
'floating_ips': 'floating-ips',
5362
'security_group_rules': 'secgroup-rules',
@@ -128,7 +137,8 @@ def take_action(self, parsed_args):
128137
for k, v in VOLUME_QUOTAS.items():
129138
value = getattr(parsed_args, k, None)
130139
if value is not None:
131-
if parsed_args.volume_type:
140+
if (parsed_args.volume_type and
141+
k in IMPACT_VOLUME_TYPE_QUOTAS):
132142
k = k + '_%s' % parsed_args.volume_type
133143
volume_kwargs[k] = value
134144

openstackclient/tests/unit/common/test_quota.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,20 @@ def test_quota_set_volume(self):
158158
'--gigabytes', str(volume_fakes.QUOTA['gigabytes']),
159159
'--snapshots', str(volume_fakes.QUOTA['snapshots']),
160160
'--volumes', str(volume_fakes.QUOTA['volumes']),
161+
'--backups', str(volume_fakes.QUOTA['backups']),
162+
'--backup-gigabytes', str(volume_fakes.QUOTA['backup_gigabytes']),
163+
'--per-volume-gigabytes',
164+
str(volume_fakes.QUOTA['per_volume_gigabytes']),
161165
identity_fakes.project_name,
162166
]
163167
verifylist = [
164168
('gigabytes', volume_fakes.QUOTA['gigabytes']),
165169
('snapshots', volume_fakes.QUOTA['snapshots']),
166170
('volumes', volume_fakes.QUOTA['volumes']),
171+
('backups', volume_fakes.QUOTA['backups']),
172+
('backup_gigabytes', volume_fakes.QUOTA['backup_gigabytes']),
173+
('per_volume_gigabytes',
174+
volume_fakes.QUOTA['per_volume_gigabytes']),
167175
]
168176

169177
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -174,6 +182,9 @@ def test_quota_set_volume(self):
174182
'gigabytes': volume_fakes.QUOTA['gigabytes'],
175183
'snapshots': volume_fakes.QUOTA['snapshots'],
176184
'volumes': volume_fakes.QUOTA['volumes'],
185+
'backups': volume_fakes.QUOTA['backups'],
186+
'backup_gigabytes': volume_fakes.QUOTA['backup_gigabytes'],
187+
'per_volume_gigabytes': volume_fakes.QUOTA['per_volume_gigabytes']
177188
}
178189

179190
self.volume_quotas_mock.update.assert_called_once_with(
@@ -188,13 +199,21 @@ def test_quota_set_volume_with_volume_type(self):
188199
'--gigabytes', str(volume_fakes.QUOTA['gigabytes']),
189200
'--snapshots', str(volume_fakes.QUOTA['snapshots']),
190201
'--volumes', str(volume_fakes.QUOTA['volumes']),
202+
'--backups', str(volume_fakes.QUOTA['backups']),
203+
'--backup-gigabytes', str(volume_fakes.QUOTA['backup_gigabytes']),
204+
'--per-volume-gigabytes',
205+
str(volume_fakes.QUOTA['per_volume_gigabytes']),
191206
'--volume-type', 'volume_type_backend',
192207
identity_fakes.project_name,
193208
]
194209
verifylist = [
195210
('gigabytes', volume_fakes.QUOTA['gigabytes']),
196211
('snapshots', volume_fakes.QUOTA['snapshots']),
197212
('volumes', volume_fakes.QUOTA['volumes']),
213+
('backups', volume_fakes.QUOTA['backups']),
214+
('backup_gigabytes', volume_fakes.QUOTA['backup_gigabytes']),
215+
('per_volume_gigabytes',
216+
volume_fakes.QUOTA['per_volume_gigabytes']),
198217
('volume_type', 'volume_type_backend'),
199218
]
200219

@@ -206,6 +225,9 @@ def test_quota_set_volume_with_volume_type(self):
206225
'gigabytes_volume_type_backend': volume_fakes.QUOTA['gigabytes'],
207226
'snapshots_volume_type_backend': volume_fakes.QUOTA['snapshots'],
208227
'volumes_volume_type_backend': volume_fakes.QUOTA['volumes'],
228+
'backups': volume_fakes.QUOTA['backups'],
229+
'backup_gigabytes': volume_fakes.QUOTA['backup_gigabytes'],
230+
'per_volume_gigabytes': volume_fakes.QUOTA['per_volume_gigabytes']
209231
}
210232

211233
self.volume_quotas_mock.update.assert_called_once_with(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
features:
3+
- Support to update ``per_volume_gigabytes``, ``backup_gigabytes`` and
4+
``backups`` quota in ``quota set`` command.
5+
[Bug `1609767 <https://bugs.launchpad.net/python-openstackclient/+bug/1609767>`_]

0 commit comments

Comments
 (0)