From 3441007062eea006fe0fa1a90692c3e85eee9df8 Mon Sep 17 00:00:00 2001 From: Matt Riedemann <mriedem@us.ibm.com> Date: Tue, 17 Jun 2014 11:01:18 -0700 Subject: [PATCH] Allow updating fixed_ips quotas in quota-class-update (v2 shell only) The quota-class-update command wasn't allowing updating quotas for fixed_ips which is a supported key for the os-quota-class-sets API. This change adds the support to update qoutas for fixed_ips and updates the existing test to be more robust in (a) the quota keys it's testing and (b) the request body it's asserting. This is a v2-only change since the os-quota-class-sets API was removed from the nova v3 API in Icehouse. Closes-Bug: #1330571 Change-Id: Ifcca6d00551619b993b96f05134980a4ca2f2acf --- novaclient/tests/v1_1/test_shell.py | 21 ++++++++++++++++----- novaclient/v1_1/shell.py | 5 +++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index 38c721552..4121e4a77 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -1600,11 +1600,22 @@ class ShellTest(utils.TestCase): self.assert_called('GET', '/os-quota-class-sets/test') def test_quota_class_update(self): - self.run_command('quota-class-update 97f4c221bff44578b0300df4ef119353' - ' --instances=5') - self.assert_called('PUT', - '/os-quota-class-sets/97f4c221bff44578b0300' - 'df4ef119353') + # The list of args we can update. + args = ( + '--instances', '--cores', '--ram', '--floating-ips', '--fixed-ips', + '--metadata-items', '--injected-files', + '--injected-file-content-bytes', '--injected-file-path-bytes', + '--key-pairs', '--security-groups', '--security-group-rules' + ) + for arg in args: + self.run_command('quota-class-update ' + '97f4c221bff44578b0300df4ef119353 ' + '%s=5' % arg) + request_param = arg[2:].replace('-', '_') + body = {'quota_class_set': {request_param: 5}} + self.assert_called( + 'PUT', '/os-quota-class-sets/97f4c221bff44578b0300df4ef119353', + body) def test_network_list(self): self.run_command('network-list') diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index d8260cc89..928da577c 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -3373,6 +3373,11 @@ def do_quota_class_show(cs, args): @utils.arg('--floating_ips', type=int, help=argparse.SUPPRESS) +@utils.arg('--fixed-ips', + metavar='<fixed-ips>', + type=int, + default=None, + help=_('New value for the "fixed-ips" quota.')) @utils.arg('--metadata-items', metavar='<metadata-items>', type=int,