diff --git a/novaclient/tests/v1_1/fakes.py b/novaclient/tests/v1_1/fakes.py index 924d39051..601a06096 100644 --- a/novaclient/tests/v1_1/fakes.py +++ b/novaclient/tests/v1_1/fakes.py @@ -1014,6 +1014,12 @@ class FakeHTTPClient(base_client.HTTPClient): 'security_groups': 1, 'security_group_rules': 1}}) + def delete_os_quota_sets_test(self, **kw): + return (202, {}, {}) + + def delete_os_quota_sets_97f4c221bff44578b0300df4ef119353(self, **kw): + return (202, {}, {}) + # # Quota Classes # diff --git a/novaclient/tests/v1_1/test_quotas.py b/novaclient/tests/v1_1/test_quotas.py index 69c2952f1..a4d68f863 100644 --- a/novaclient/tests/v1_1/test_quotas.py +++ b/novaclient/tests/v1_1/test_quotas.py @@ -45,3 +45,8 @@ class QuotaSetsTest(utils.TestCase): self.assertNotEqual(q.volumes, q2.volumes) q2.get() self.assertEqual(q.volumes, q2.volumes) + + def test_quotas_delete(self): + tenant_id = 'test' + cs.quotas.delete(tenant_id) + cs.assert_called('DELETE', '/os-quota-sets/%s' % tenant_id) diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index 5b17b2b9e..96c1156a2 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -1034,6 +1034,12 @@ class ShellTest(utils.TestCase): {'quota_set': {'fixed_ips': 5, 'tenant_id': '97f4c221bff44578b0300df4ef119353'}}) + def test_quota_delete(self): + self.run_command('quota-delete --tenant ' + '97f4c221bff44578b0300df4ef119353') + self.assert_called('DELETE', + '/os-quota-sets/97f4c221bff44578b0300df4ef119353') + def test_quota_class_show(self): self.run_command('quota-class-show test') self.assert_called('GET', '/os-quota-class-sets/test') diff --git a/novaclient/v1_1/quotas.py b/novaclient/v1_1/quotas.py index 6aa7fe5ac..19f7d7190 100644 --- a/novaclient/v1_1/quotas.py +++ b/novaclient/v1_1/quotas.py @@ -69,3 +69,6 @@ class QuotaSetManager(base.Manager): def defaults(self, tenant_id): return self._get('/os-quota-sets/%s/defaults' % tenant_id, 'quota_set') + + def delete(self, tenant_id): + self._delete("/os-quota-sets/%s" % tenant_id) diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index 4c1627ce8..21e658959 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -2914,6 +2914,15 @@ def do_quota_update(cs, args): _quota_update(cs.quotas, args.tenant, args) +@utils.arg('--tenant', + metavar='', + help='ID of tenant to delete quota for.') +def do_quota_delete(cs, args): + """Delete quota for a tenant so their quota will revert back to default.""" + + cs.quotas.delete(args.tenant) + + @utils.arg('class_name', metavar='', help='Name of quota class to list the quotas for.')