diff --git a/manilaclient/v1/quota_classes.py b/manilaclient/v1/quota_classes.py index e3824d760..d0c2d0de1 100644 --- a/manilaclient/v1/quota_classes.py +++ b/manilaclient/v1/quota_classes.py @@ -31,21 +31,28 @@ class QuotaClassSetManager(base.ManagerWithFind): resource_class = QuotaClassSet def get(self, class_name): - return self._get("/os-quota-class-sets/%s" % (class_name), + return self._get("/os-quota-class-sets/%s" % class_name, "quota_class_set") def update(self, class_name, shares=None, - gigabytes=None): + gigabytes=None, + snapshots=None, + share_networks=None): - body = {'quota_class_set': { + body = { + 'quota_class_set': { 'class_name': class_name, 'shares': shares, - 'gigabytes': gigabytes}} + 'snapshots': snapshots, + 'gigabytes': gigabytes, + 'share_networks': share_networks, + } + } for key in body['quota_class_set'].keys(): if body['quota_class_set'][key] is None: body['quota_class_set'].pop(key) - self._update('/os-quota-class-sets/%s' % (class_name), body) + self._update('/os-quota-class-sets/%s' % class_name, body) diff --git a/manilaclient/v1/quotas.py b/manilaclient/v1/quotas.py index cfb52ea73..905feaba1 100644 --- a/manilaclient/v1/quotas.py +++ b/manilaclient/v1/quotas.py @@ -40,14 +40,18 @@ class QuotaSetManager(base.ManagerWithFind): return self._get(url, "quota_set") def update(self, tenant_id, shares=None, snapshots=None, gigabytes=None, - force=None, user_id=None): + share_networks=None, force=None, user_id=None): - body = {'quota_set': { + body = { + 'quota_set': { 'tenant_id': tenant_id, 'shares': shares, 'snapshots': snapshots, 'gigabytes': gigabytes, - 'force': force}} + 'share_networks': share_networks, + 'force': force, + }, + } for key in body['quota_set'].keys(): if body['quota_set'][key] is None: diff --git a/manilaclient/v1/shell.py b/manilaclient/v1/shell.py index e38729d55..167122679 100644 --- a/manilaclient/v1/shell.py +++ b/manilaclient/v1/shell.py @@ -109,7 +109,7 @@ def do_credentials(cs, args): utils.print_dict(catalog['access']['user'], "User Credentials") utils.print_dict(catalog['access']['token'], "Token") -_quota_resources = ['shares', 'snapshots', 'gigabytes'] +_quota_resources = ['shares', 'snapshots', 'gigabytes', 'share_networks'] def _quota_show(quotas): @@ -187,6 +187,10 @@ def do_quota_defaults(cs, args): metavar='', type=int, default=None, help='New value for the "gigabytes" quota.') +@utils.arg('--share-networks', + metavar='', + type=int, default=None, + help='New value for the "share_networks" quota.') @utils.arg('--force', dest='force', action="store_true", @@ -242,6 +246,10 @@ def do_quota_class_show(cs, args): metavar='', type=int, default=None, help='New value for the "gigabytes" quota.') +@utils.arg('--share-networks', + metavar='', + type=int, default=None, + help='New value for the "share_networks" quota.') @utils.service_type('share') def do_quota_class_update(cs, args): """Update the quotas for a quota class.""" diff --git a/tests/v1/fake_clients.py b/tests/v1/fake_clients.py index f2bb430c5..30f1a279f 100644 --- a/tests/v1/fake_clients.py +++ b/tests/v1/fake_clients.py @@ -78,54 +78,79 @@ class FakeHTTPClient(base_client.HTTPClient): # def get_os_quota_sets_test(self, **kw): - return (200, {}, {'quota_set': { - 'tenant_id': 'test', - 'metadata_items': [], - 'shares': 1, - 'snapshots': 1, - 'gigabytes': 1}}) + quota_set = { + 'quota_set': { + 'tenant_id': 'test', + 'metadata_items': [], + 'shares': 1, + 'snapshots': 1, + 'gigabytes': 1, + 'share_networks': 1, + } + } + return (200, {}, quota_set) def get_os_quota_sets_test_defaults(self): - return (200, {}, {'quota_set': { - 'tenant_id': 'test', - 'metadata_items': [], - 'shares': 1, - 'snapshots': 1, - 'gigabytes': 1}}) + quota_set = { + 'quota_set': { + 'tenant_id': 'test', + 'metadata_items': [], + 'shares': 1, + 'snapshots': 1, + 'gigabytes': 1, + 'share_networks': 1, + } + } + return (200, {}, quota_set) def put_os_quota_sets_test(self, body, **kw): assert body.keys() == ['quota_set'] fakes.assert_has_keys(body['quota_set'], required=['tenant_id']) - return (200, {}, {'quota_set': { - 'tenant_id': 'test', - 'metadata_items': [], - 'shares': 2, - 'snapshots': 2, - 'gigabytes': 1}}) + quota_set = { + 'quota_set': { + 'tenant_id': 'test', + 'metadata_items': [], + 'shares': 2, + 'snapshots': 2, + 'gigabytes': 1, + 'share_networks': 1, + } + } + return (200, {}, quota_set) # # Quota Classes # def get_os_quota_class_sets_test(self, **kw): - return (200, {}, {'quota_class_set': { - 'class_name': 'test', - 'metadata_items': [], - 'shares': 1, - 'snapshots': 1, - 'gigabytes': 1}}) + quota_class_set = { + 'quota_class_set': { + 'class_name': 'test', + 'metadata_items': [], + 'shares': 1, + 'snapshots': 1, + 'gigabytes': 1, + 'share_networks': 1, + } + } + return (200, {}, quota_class_set) def put_os_quota_class_sets_test(self, body, **kw): assert body.keys() == ['quota_class_set'] fakes.assert_has_keys(body['quota_class_set'], required=['class_name']) - return (200, {}, {'quota_class_set': { - 'class_name': 'test', - 'metadata_items': [], - 'shares': 2, - 'snapshots': 2, - 'gigabytes': 1}}) + quota_class_set = { + 'quota_class_set': { + 'class_name': 'test', + 'metadata_items': [], + 'shares': 2, + 'snapshots': 2, + 'gigabytes': 1, + 'share_networks': 1, + } + } + return (200, {}, quota_class_set) def delete_os_quota_sets_test(self, **kw): return (202, {}, {})