summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dague <sean@dague.net>2013-05-24 09:04:09 -0400
committerSean Dague <sean@dague.net>2013-05-24 09:06:01 -0400
commitc305a458926f66d717d827dbad4596a7b22a02eb (patch)
tree0918eb7e0a0bf33596b18c7edb65ee13fd425fc3
parentc07f05ed33b382d14def6d4cef8fd194ddfc9f49 (diff)
Revert "Support force update quota"
This reverts commit e8b665edbfcd86488f75ed0b79dafdedbf8f5950. The previous commit created an incompatibility in using new nova client with older nova server. Nova client needs to be always releasable, and work with all nova server API versions out there. Fixes bug #1173353 Change-Id: I2c07d109af4a35bc3b98dedaf991d5d3cc6fdd3b
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Mark McLoughlin <markmc@redhat.com> Approved+1: Russell Bryant <rbryant@redhat.com> Code-Review+2: Russell Bryant <rbryant@redhat.com> Code-Review+1: David Ripton <dripton@redhat.com> Submitted-by: Jenkins Submitted-at: Fri, 24 May 2013 17:41:24 +0000 Reviewed-on: https://review.openstack.org/30436 Project: openstack/python-novaclient Branch: refs/heads/master
-rw-r--r--novaclient/v1_1/quotas.py5
-rw-r--r--novaclient/v1_1/shell.py13
-rw-r--r--tests/v1_1/test_quotas.py9
-rw-r--r--tests/v1_1/test_shell.py21
4 files changed, 6 insertions, 42 deletions
diff --git a/novaclient/v1_1/quotas.py b/novaclient/v1_1/quotas.py
index c510b11..6aa7fe5 100644
--- a/novaclient/v1_1/quotas.py
+++ b/novaclient/v1_1/quotas.py
@@ -36,7 +36,7 @@ class QuotaSetManager(base.Manager):
36 tenant_id = tenant_id.tenant_id 36 tenant_id = tenant_id.tenant_id
37 return self._get("/os-quota-sets/%s" % (tenant_id), "quota_set") 37 return self._get("/os-quota-sets/%s" % (tenant_id), "quota_set")
38 38
39 def update(self, tenant_id, force=None, metadata_items=None, 39 def update(self, tenant_id, metadata_items=None,
40 injected_file_content_bytes=None, injected_file_path_bytes=None, 40 injected_file_content_bytes=None, injected_file_path_bytes=None,
41 volumes=None, gigabytes=None, 41 volumes=None, gigabytes=None,
42 ram=None, floating_ips=None, fixed_ips=None, instances=None, 42 ram=None, floating_ips=None, fixed_ips=None, instances=None,
@@ -58,8 +58,7 @@ class QuotaSetManager(base.Manager):
58 'injected_files': injected_files, 58 'injected_files': injected_files,
59 'cores': cores, 59 'cores': cores,
60 'security_groups': security_groups, 60 'security_groups': security_groups,
61 'security_group_rules': security_group_rules, 61 'security_group_rules': security_group_rules}}
62 'force': force}}
63 62
64 for key in body['quota_set'].keys(): 63 for key in body['quota_set'].keys():
65 if body['quota_set'][key] is None: 64 if body['quota_set'][key] is None:
diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py
index 460ef92..f56ad91 100644
--- a/novaclient/v1_1/shell.py
+++ b/novaclient/v1_1/shell.py
@@ -31,7 +31,6 @@ from novaclient.openstack.common import timeutils
31from novaclient.openstack.common import uuidutils 31from novaclient.openstack.common import uuidutils
32from novaclient import utils 32from novaclient import utils
33from novaclient.v1_1 import availability_zones 33from novaclient.v1_1 import availability_zones
34from novaclient.v1_1 import quotas
35from novaclient.v1_1 import servers 34from novaclient.v1_1 import servers
36 35
37 36
@@ -2791,11 +2790,7 @@ def _quota_update(manager, identifier, args):
2791 updates[resource] = val 2790 updates[resource] = val
2792 2791
2793 if updates: 2792 if updates:
2794 force_update = getattr(args, 'force', False) 2793 manager.update(identifier, **updates)
2795 if isinstance(manager, quotas.QuotaSetManager):
2796 manager.update(identifier, force_update, **updates)
2797 else:
2798 manager.update(identifier, **updates)
2799 2794
2800 2795
2801@utils.arg('--tenant', 2796@utils.arg('--tenant',
@@ -2904,12 +2899,6 @@ def do_quota_defaults(cs, args):
2904 type=int, 2899 type=int,
2905 default=None, 2900 default=None,
2906 help='New value for the "security-group-rules" quota.') 2901 help='New value for the "security-group-rules" quota.')
2907@utils.arg('--force',
2908 dest='force',
2909 action="store_true",
2910 default=False,
2911 help='Whether force update the quota even if the already used'
2912 ' and reserved exceeds the new quota')
2913def do_quota_update(cs, args): 2902def do_quota_update(cs, args):
2914 """Update the quotas for a tenant.""" 2903 """Update the quotas for a tenant."""
2915 2904
diff --git a/tests/v1_1/test_quotas.py b/tests/v1_1/test_quotas.py
index c7aa64c..85a7a57 100644
--- a/tests/v1_1/test_quotas.py
+++ b/tests/v1_1/test_quotas.py
@@ -37,15 +37,6 @@ class QuotaSetsTest(utils.TestCase):
37 cs.assert_called('PUT', 37 cs.assert_called('PUT',
38 '/os-quota-sets/97f4c221bff44578b0300df4ef119353') 38 '/os-quota-sets/97f4c221bff44578b0300df4ef119353')
39 39
40 def test_force_update_quota(self):
41 q = cs.quotas.get('97f4c221bff44578b0300df4ef119353')
42 q.update(cores=2, force=True)
43 cs.assert_called(
44 'PUT', '/os-quota-sets/97f4c221bff44578b0300df4ef119353',
45 {'quota_set': {'force': True,
46 'cores': 2,
47 'tenant_id': '97f4c221bff44578b0300df4ef119353'}})
48
49 def test_refresh_quota(self): 40 def test_refresh_quota(self):
50 q = cs.quotas.get('test') 41 q = cs.quotas.get('test')
51 q2 = cs.quotas.get('test') 42 q2 = cs.quotas.get('test')
diff --git a/tests/v1_1/test_shell.py b/tests/v1_1/test_shell.py
index 3071ba0..51ccf50 100644
--- a/tests/v1_1/test_shell.py
+++ b/tests/v1_1/test_shell.py
@@ -1022,22 +1022,8 @@ class ShellTest(utils.TestCase):
1022 self.run_command( 1022 self.run_command(
1023 'quota-update 97f4c221bff44578b0300df4ef119353' 1023 'quota-update 97f4c221bff44578b0300df4ef119353'
1024 ' --instances=5') 1024 ' --instances=5')
1025 self.assert_called( 1025 self.assert_called('PUT',
1026 'PUT', 1026 '/os-quota-sets/97f4c221bff44578b0300df4ef119353')
1027 '/os-quota-sets/97f4c221bff44578b0300df4ef119353',
1028 {'quota_set': {'force': False,
1029 'instances': 5,
1030 'tenant_id': '97f4c221bff44578b0300df4ef119353'}})
1031
1032 def test_quota_force_update(self):
1033 self.run_command(
1034 'quota-update 97f4c221bff44578b0300df4ef119353'
1035 ' --instances=5 --force')
1036 self.assert_called(
1037 'PUT', '/os-quota-sets/97f4c221bff44578b0300df4ef119353',
1038 {'quota_set': {'force': True,
1039 'instances': 5,
1040 'tenant_id': '97f4c221bff44578b0300df4ef119353'}})
1041 1027
1042 def test_quota_update_fixed_ip(self): 1028 def test_quota_update_fixed_ip(self):
1043 self.run_command( 1029 self.run_command(
@@ -1045,8 +1031,7 @@ class ShellTest(utils.TestCase):
1045 ' --fixed-ips=5') 1031 ' --fixed-ips=5')
1046 self.assert_called( 1032 self.assert_called(
1047 'PUT', '/os-quota-sets/97f4c221bff44578b0300df4ef119353', 1033 'PUT', '/os-quota-sets/97f4c221bff44578b0300df4ef119353',
1048 {'quota_set': {'force': False, 1034 {'quota_set': {'fixed_ips': 5,
1049 'fixed_ips': 5,
1050 'tenant_id': '97f4c221bff44578b0300df4ef119353'}}) 1035 'tenant_id': '97f4c221bff44578b0300df4ef119353'}})
1051 1036
1052 def test_quota_class_show(self): 1037 def test_quota_class_show(self):