diff --git a/cinderclient/v1/quotas.py b/cinderclient/v1/quotas.py index c998f0aa4..2ac22dfc3 100644 --- a/cinderclient/v1/quotas.py +++ b/cinderclient/v1/quotas.py @@ -36,11 +36,12 @@ class QuotaSetManager(base.ManagerWithFind): tenant_id = tenant_id.tenant_id return self._get("/os-quota-sets/%s" % (tenant_id), "quota_set") - def update(self, tenant_id, volumes=None, gigabytes=None): + def update(self, tenant_id, volumes=None, snapshots=None, gigabytes=None): body = {'quota_set': { 'tenant_id': tenant_id, 'volumes': volumes, + 'snapshots': snapshots, 'gigabytes': gigabytes}} for key in body['quota_set'].keys(): diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index 6eae43bf3..8119654bf 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -500,7 +500,7 @@ def do_credentials(cs, args): utils.print_dict(catalog['access']['user'], "User Credentials") utils.print_dict(catalog['access']['token'], "Token") -_quota_resources = ['volumes', 'gigabytes'] +_quota_resources = ['volumes', 'snapshots', 'gigabytes'] def _quota_show(quotas): @@ -545,6 +545,10 @@ def do_quota_defaults(cs, args): metavar='', type=int, default=None, help='New value for the "volumes" quota.') +@utils.arg('--snapshots', + metavar='', + type=int, default=None, + help='New value for the "snapshots" quota.') @utils.arg('--gigabytes', metavar='', type=int, default=None, @@ -571,6 +575,10 @@ def do_quota_class_show(cs, args): metavar='', type=int, default=None, help='New value for the "volumes" quota.') +@utils.arg('--snapshots', + metavar='', + type=int, default=None, + help='New value for the "snapshots" quota.') @utils.arg('--gigabytes', metavar='', type=int, default=None, diff --git a/cinderclient/v2/quotas.py b/cinderclient/v2/quotas.py index 7a264d81a..803d72cce 100644 --- a/cinderclient/v2/quotas.py +++ b/cinderclient/v2/quotas.py @@ -35,11 +35,12 @@ class QuotaSetManager(base.ManagerWithFind): tenant_id = tenant_id.tenant_id return self._get("/os-quota-sets/%s" % (tenant_id), "quota_set") - def update(self, tenant_id, volumes=None, gigabytes=None): + def update(self, tenant_id, volumes=None, snapshots=None, gigabytes=None): body = {'quota_set': { 'tenant_id': tenant_id, 'volumes': volumes, + 'snapshots': snapshots, 'gigabytes': gigabytes}} for key in body['quota_set'].keys(): diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 4759a5994..2cf7c768f 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -544,7 +544,7 @@ def do_credentials(cs, args): utils.print_dict(catalog['access']['user'], "User Credentials") utils.print_dict(catalog['access']['token'], "Token") -_quota_resources = ['volumes', 'gigabytes'] +_quota_resources = ['volumes', 'snapshots', 'gigabytes'] def _quota_show(quotas): @@ -592,6 +592,10 @@ def do_quota_defaults(cs, args): metavar='', type=int, default=None, help='New value for the "volumes" quota.') +@utils.arg('--snapshots', + metavar='', + type=int, default=None, + help='New value for the "snapshots" quota.') @utils.arg('--gigabytes', metavar='', type=int, default=None, @@ -620,6 +624,10 @@ def do_quota_class_show(cs, args): metavar='', type=int, default=None, help='New value for the "volumes" quota.') +@utils.arg('--snapshots', + metavar='', + type=int, default=None, + help='New value for the "snapshots" quota.') @utils.arg('--gigabytes', metavar='', type=int, default=None, diff --git a/tests/v1/fakes.py b/tests/v1/fakes.py index 87f5d81c0..ed0a64020 100644 --- a/tests/v1/fakes.py +++ b/tests/v1/fakes.py @@ -196,6 +196,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'tenant_id': 'test', 'metadata_items': [], 'volumes': 1, + 'snapshots': 1, 'gigabytes': 1}}) def get_os_quota_sets_test_defaults(self): @@ -203,6 +204,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'tenant_id': 'test', 'metadata_items': [], 'volumes': 1, + 'snapshots': 1, 'gigabytes': 1}}) def put_os_quota_sets_test(self, body, **kw): @@ -213,6 +215,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'tenant_id': 'test', 'metadata_items': [], 'volumes': 2, + 'snapshots': 2, 'gigabytes': 1}}) # @@ -224,6 +227,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'class_name': 'test', 'metadata_items': [], 'volumes': 1, + 'snapshots': 1, 'gigabytes': 1}}) def put_os_quota_class_sets_test(self, body, **kw): @@ -234,6 +238,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'class_name': 'test', 'metadata_items': [], 'volumes': 2, + 'snapshots': 2, 'gigabytes': 1}}) # diff --git a/tests/v1/test_quotas.py b/tests/v1/test_quotas.py index 49f039b76..7afc626c0 100644 --- a/tests/v1/test_quotas.py +++ b/tests/v1/test_quotas.py @@ -35,13 +35,18 @@ class QuotaSetsTest(utils.TestCase): def test_update_quota(self): q = cs.quotas.get('test') q.update(volumes=2) + q.update(snapshots=2) cs.assert_called('PUT', '/os-quota-sets/test') def test_refresh_quota(self): q = cs.quotas.get('test') q2 = cs.quotas.get('test') self.assertEqual(q.volumes, q2.volumes) + self.assertEqual(q.snapshots, q2.snapshots) q2.volumes = 0 self.assertNotEqual(q.volumes, q2.volumes) + q2.snapshots = 0 + self.assertNotEqual(q.snapshots, q2.snapshots) q2.get() self.assertEqual(q.volumes, q2.volumes) + self.assertEqual(q.snapshots, q2.snapshots) diff --git a/tests/v2/fakes.py b/tests/v2/fakes.py index e04caf444..af11af722 100644 --- a/tests/v2/fakes.py +++ b/tests/v2/fakes.py @@ -203,6 +203,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'tenant_id': 'test', 'metadata_items': [], 'volumes': 1, + 'snapshots': 1, 'gigabytes': 1}}) def get_os_quota_sets_test_defaults(self): @@ -210,6 +211,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'tenant_id': 'test', 'metadata_items': [], 'volumes': 1, + 'snapshots': 1, 'gigabytes': 1}}) def put_os_quota_sets_test(self, body, **kw): @@ -220,6 +222,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'tenant_id': 'test', 'metadata_items': [], 'volumes': 2, + 'snapshots': 2, 'gigabytes': 1}}) # @@ -231,6 +234,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'class_name': 'test', 'metadata_items': [], 'volumes': 1, + 'snapshots': 1, 'gigabytes': 1}}) def put_os_quota_class_sets_test(self, body, **kw): @@ -241,6 +245,7 @@ class FakeHTTPClient(base_client.HTTPClient): 'class_name': 'test', 'metadata_items': [], 'volumes': 2, + 'snapshots': 2, 'gigabytes': 1}}) # diff --git a/tests/v2/test_quotas.py b/tests/v2/test_quotas.py index 71837a21c..d222e8314 100644 --- a/tests/v2/test_quotas.py +++ b/tests/v2/test_quotas.py @@ -35,13 +35,18 @@ class QuotaSetsTest(utils.TestCase): def test_update_quota(self): q = cs.quotas.get('test') q.update(volumes=2) + q.update(snapshots=2) cs.assert_called('PUT', '/os-quota-sets/test') def test_refresh_quota(self): q = cs.quotas.get('test') q2 = cs.quotas.get('test') self.assertEqual(q.volumes, q2.volumes) + self.assertEqual(q.snapshots, q2.snapshots) q2.volumes = 0 self.assertNotEqual(q.volumes, q2.volumes) + q2.snapshots = 0 + self.assertNotEqual(q.snapshots, q2.snapshots) q2.get() self.assertEqual(q.volumes, q2.volumes) + self.assertEqual(q.snapshots, q2.snapshots)