Browse Source

Delete a quota through admin api.

Exposes the quota-delete api implemented as part of
blueprint admin-api-for-delete-quota
Change-Id: Iab358f0fcf2dfb41bcd9a3a5b73d590d3f55cd6c
tags/2.14.0
Aarti Kriplani 6 years ago
parent
commit
d43b923d8a

+ 6
- 0
novaclient/tests/v1_1/fakes.py View File

@@ -1014,6 +1014,12 @@ class FakeHTTPClient(base_client.HTTPClient):
1014 1014
                       'security_groups': 1,
1015 1015
                       'security_group_rules': 1}})
1016 1016
 
1017
+    def delete_os_quota_sets_test(self, **kw):
1018
+        return (202, {}, {})
1019
+
1020
+    def delete_os_quota_sets_97f4c221bff44578b0300df4ef119353(self, **kw):
1021
+        return (202, {}, {})
1022
+
1017 1023
     #
1018 1024
     # Quota Classes
1019 1025
     #

+ 5
- 0
novaclient/tests/v1_1/test_quotas.py View File

@@ -45,3 +45,8 @@ class QuotaSetsTest(utils.TestCase):
45 45
         self.assertNotEqual(q.volumes, q2.volumes)
46 46
         q2.get()
47 47
         self.assertEqual(q.volumes, q2.volumes)
48
+
49
+    def test_quotas_delete(self):
50
+        tenant_id = 'test'
51
+        cs.quotas.delete(tenant_id)
52
+        cs.assert_called('DELETE', '/os-quota-sets/%s' % tenant_id)

+ 6
- 0
novaclient/tests/v1_1/test_shell.py View File

@@ -1034,6 +1034,12 @@ class ShellTest(utils.TestCase):
1034 1034
             {'quota_set': {'fixed_ips': 5,
1035 1035
                            'tenant_id': '97f4c221bff44578b0300df4ef119353'}})
1036 1036
 
1037
+    def test_quota_delete(self):
1038
+        self.run_command('quota-delete --tenant '
1039
+                         '97f4c221bff44578b0300df4ef119353')
1040
+        self.assert_called('DELETE',
1041
+                           '/os-quota-sets/97f4c221bff44578b0300df4ef119353')
1042
+
1037 1043
     def test_quota_class_show(self):
1038 1044
         self.run_command('quota-class-show test')
1039 1045
         self.assert_called('GET', '/os-quota-class-sets/test')

+ 3
- 0
novaclient/v1_1/quotas.py View File

@@ -69,3 +69,6 @@ class QuotaSetManager(base.Manager):
69 69
     def defaults(self, tenant_id):
70 70
         return self._get('/os-quota-sets/%s/defaults' % tenant_id,
71 71
                          'quota_set')
72
+
73
+    def delete(self, tenant_id):
74
+        self._delete("/os-quota-sets/%s" % tenant_id)

+ 9
- 0
novaclient/v1_1/shell.py View File

@@ -2914,6 +2914,15 @@ def do_quota_update(cs, args):
2914 2914
     _quota_update(cs.quotas, args.tenant, args)
2915 2915
 
2916 2916
 
2917
+@utils.arg('--tenant',
2918
+           metavar='<tenant-id>',
2919
+           help='ID of tenant to delete quota for.')
2920
+def do_quota_delete(cs, args):
2921
+    """Delete quota for a tenant so their quota will revert back to default."""
2922
+
2923
+    cs.quotas.delete(args.tenant)
2924
+
2925
+
2917 2926
 @utils.arg('class_name',
2918 2927
     metavar='<class>',
2919 2928
     help='Name of quota class to list the quotas for.')

Loading…
Cancel
Save