diff --git a/cinderclient/tests/v1/fakes.py b/cinderclient/tests/v1/fakes.py index 3df0d95da..d24cf053f 100644 --- a/cinderclient/tests/v1/fakes.py +++ b/cinderclient/tests/v1/fakes.py @@ -401,6 +401,12 @@ class FakeHTTPClient(base_client.HTTPClient): 'snapshots': 2, 'gigabytes': 1}}) + def delete_os_quota_sets_1234(self, **kw): + return (200, {}, {}) + + def delete_os_quota_sets_test(self, **kw): + return (200, {}, {}) + # # Quota Classes # diff --git a/cinderclient/tests/v1/test_quotas.py b/cinderclient/tests/v1/test_quotas.py index 4751954e9..beb5b5dcb 100644 --- a/cinderclient/tests/v1/test_quotas.py +++ b/cinderclient/tests/v1/test_quotas.py @@ -50,3 +50,8 @@ class QuotaSetsTest(utils.TestCase): q2.get() self.assertEqual(q.volumes, q2.volumes) self.assertEqual(q.snapshots, q2.snapshots) + + def test_delete_quota(self): + tenant_id = 'test' + cs.quotas.delete(tenant_id) + cs.assert_called('DELETE', '/os-quota-sets/test') diff --git a/cinderclient/tests/v1/test_shell.py b/cinderclient/tests/v1/test_shell.py index ddb669f35..586caa240 100644 --- a/cinderclient/tests/v1/test_shell.py +++ b/cinderclient/tests/v1/test_shell.py @@ -355,3 +355,7 @@ class ShellTest(utils.TestCase): def test_snapshot_delete(self): self.run_command('snapshot-delete 1234') self.assert_called('DELETE', '/snapshots/1234') + + def test_quota_delete(self): + self.run_command('quota-delete 1234') + self.assert_called('DELETE', '/os-quota-sets/1234') diff --git a/cinderclient/tests/v2/fakes.py b/cinderclient/tests/v2/fakes.py index f44814b0a..eebc58610 100644 --- a/cinderclient/tests/v2/fakes.py +++ b/cinderclient/tests/v2/fakes.py @@ -412,6 +412,12 @@ class FakeHTTPClient(base_client.HTTPClient): 'snapshots': 2, 'gigabytes': 1}}) + def delete_os_quota_sets_1234(self, **kw): + return (200, {}, {}) + + def delete_os_quota_sets_test(self, **kw): + return (200, {}, {}) + # # Quota Classes # diff --git a/cinderclient/tests/v2/test_quotas.py b/cinderclient/tests/v2/test_quotas.py index 5a61dbb49..e4a723aef 100644 --- a/cinderclient/tests/v2/test_quotas.py +++ b/cinderclient/tests/v2/test_quotas.py @@ -50,3 +50,8 @@ class QuotaSetsTest(utils.TestCase): q2.get() self.assertEqual(q.volumes, q2.volumes) self.assertEqual(q.snapshots, q2.snapshots) + + def test_delete_quota(self): + tenant_id = 'test' + cs.quotas.delete(tenant_id) + cs.assert_called('DELETE', '/os-quota-sets/test') diff --git a/cinderclient/tests/v2/test_shell.py b/cinderclient/tests/v2/test_shell.py index 90ef8cf3b..c9a92aa2e 100644 --- a/cinderclient/tests/v2/test_shell.py +++ b/cinderclient/tests/v2/test_shell.py @@ -355,3 +355,7 @@ class ShellTest(utils.TestCase): def test_snapshot_delete(self): self.run_command('snapshot-delete 1234') self.assert_called('DELETE', '/snapshots/1234') + + def test_quota_delete(self): + self.run_command('quota-delete 1234') + self.assert_called('DELETE', '/os-quota-sets/1234') diff --git a/cinderclient/v1/quotas.py b/cinderclient/v1/quotas.py index dd0018621..800a70aac 100644 --- a/cinderclient/v1/quotas.py +++ b/cinderclient/v1/quotas.py @@ -49,3 +49,8 @@ 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): + if hasattr(tenant_id, 'tenant_id'): + tenant_id = tenant_id.tenant_id + return self._delete("/os-quota-sets/%s" % tenant_id) diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index 0f10168e5..6a11c2a9f 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -725,6 +725,15 @@ def do_quota_update(cs, args): _quota_update(cs.quotas, args.tenant, args) +@utils.arg('tenant', metavar='', + help='UUID of tenant to delete the quotas for.') +@utils.service_type('volume') +def do_quota_delete(cs, args): + """Delete the quotas for a tenant.""" + + cs.quotas.delete(args.tenant) + + @utils.arg('class_name', metavar='', help='Name of quota class to list the quotas for.') @utils.service_type('volume') diff --git a/cinderclient/v2/quotas.py b/cinderclient/v2/quotas.py index 3a094ff74..fcb87dd06 100644 --- a/cinderclient/v2/quotas.py +++ b/cinderclient/v2/quotas.py @@ -47,3 +47,8 @@ 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): + if hasattr(tenant_id, 'tenant_id'): + tenant_id = tenant_id.tenant_id + return self._delete("/os-quota-sets/%s" % tenant_id) diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 9abd212f2..e4c3da322 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -786,6 +786,15 @@ def do_quota_update(cs, args): _quota_update(cs.quotas, args.tenant, args) +@utils.arg('tenant', metavar='', + help='UUID of tenant to delete the quotas for.') +@utils.service_type('volume') +def do_quota_delete(cs, args): + """Delete the quotas for a tenant.""" + + cs.quotas.delete(args.tenant) + + @utils.arg('class_name', metavar='', help='Name of quota class to list the quotas for.')