Added quota for share-networks
Partially-implements bp quota-for-share-networks Change-Id: I5977fe3f8bf9cbfa341d0d7332d2d536f4b3006a
This commit is contained in:
parent
630985649f
commit
ef0c7e13be
@ -31,21 +31,28 @@ class QuotaClassSetManager(base.ManagerWithFind):
|
|||||||
resource_class = QuotaClassSet
|
resource_class = QuotaClassSet
|
||||||
|
|
||||||
def get(self, class_name):
|
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")
|
"quota_class_set")
|
||||||
|
|
||||||
def update(self,
|
def update(self,
|
||||||
class_name,
|
class_name,
|
||||||
shares=None,
|
shares=None,
|
||||||
gigabytes=None):
|
gigabytes=None,
|
||||||
|
snapshots=None,
|
||||||
|
share_networks=None):
|
||||||
|
|
||||||
body = {'quota_class_set': {
|
body = {
|
||||||
|
'quota_class_set': {
|
||||||
'class_name': class_name,
|
'class_name': class_name,
|
||||||
'shares': shares,
|
'shares': shares,
|
||||||
'gigabytes': gigabytes}}
|
'snapshots': snapshots,
|
||||||
|
'gigabytes': gigabytes,
|
||||||
|
'share_networks': share_networks,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for key in body['quota_class_set'].keys():
|
for key in body['quota_class_set'].keys():
|
||||||
if body['quota_class_set'][key] is None:
|
if body['quota_class_set'][key] is None:
|
||||||
body['quota_class_set'].pop(key)
|
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)
|
||||||
|
@ -40,14 +40,18 @@ class QuotaSetManager(base.ManagerWithFind):
|
|||||||
return self._get(url, "quota_set")
|
return self._get(url, "quota_set")
|
||||||
|
|
||||||
def update(self, tenant_id, shares=None, snapshots=None, gigabytes=None,
|
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,
|
'tenant_id': tenant_id,
|
||||||
'shares': shares,
|
'shares': shares,
|
||||||
'snapshots': snapshots,
|
'snapshots': snapshots,
|
||||||
'gigabytes': gigabytes,
|
'gigabytes': gigabytes,
|
||||||
'force': force}}
|
'share_networks': share_networks,
|
||||||
|
'force': force,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
for key in body['quota_set'].keys():
|
for key in body['quota_set'].keys():
|
||||||
if body['quota_set'][key] is None:
|
if body['quota_set'][key] is None:
|
||||||
|
@ -109,7 +109,7 @@ def do_credentials(cs, args):
|
|||||||
utils.print_dict(catalog['access']['user'], "User Credentials")
|
utils.print_dict(catalog['access']['user'], "User Credentials")
|
||||||
utils.print_dict(catalog['access']['token'], "Token")
|
utils.print_dict(catalog['access']['token'], "Token")
|
||||||
|
|
||||||
_quota_resources = ['shares', 'snapshots', 'gigabytes']
|
_quota_resources = ['shares', 'snapshots', 'gigabytes', 'share_networks']
|
||||||
|
|
||||||
|
|
||||||
def _quota_show(quotas):
|
def _quota_show(quotas):
|
||||||
@ -187,6 +187,10 @@ def do_quota_defaults(cs, args):
|
|||||||
metavar='<gigabytes>',
|
metavar='<gigabytes>',
|
||||||
type=int, default=None,
|
type=int, default=None,
|
||||||
help='New value for the "gigabytes" quota.')
|
help='New value for the "gigabytes" quota.')
|
||||||
|
@utils.arg('--share-networks',
|
||||||
|
metavar='<share-networks>',
|
||||||
|
type=int, default=None,
|
||||||
|
help='New value for the "share_networks" quota.')
|
||||||
@utils.arg('--force',
|
@utils.arg('--force',
|
||||||
dest='force',
|
dest='force',
|
||||||
action="store_true",
|
action="store_true",
|
||||||
@ -242,6 +246,10 @@ def do_quota_class_show(cs, args):
|
|||||||
metavar='<gigabytes>',
|
metavar='<gigabytes>',
|
||||||
type=int, default=None,
|
type=int, default=None,
|
||||||
help='New value for the "gigabytes" quota.')
|
help='New value for the "gigabytes" quota.')
|
||||||
|
@utils.arg('--share-networks',
|
||||||
|
metavar='<share-networks>',
|
||||||
|
type=int, default=None,
|
||||||
|
help='New value for the "share_networks" quota.')
|
||||||
@utils.service_type('share')
|
@utils.service_type('share')
|
||||||
def do_quota_class_update(cs, args):
|
def do_quota_class_update(cs, args):
|
||||||
"""Update the quotas for a quota class."""
|
"""Update the quotas for a quota class."""
|
||||||
|
@ -78,54 +78,79 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
#
|
#
|
||||||
|
|
||||||
def get_os_quota_sets_test(self, **kw):
|
def get_os_quota_sets_test(self, **kw):
|
||||||
return (200, {}, {'quota_set': {
|
quota_set = {
|
||||||
'tenant_id': 'test',
|
'quota_set': {
|
||||||
'metadata_items': [],
|
'tenant_id': 'test',
|
||||||
'shares': 1,
|
'metadata_items': [],
|
||||||
'snapshots': 1,
|
'shares': 1,
|
||||||
'gigabytes': 1}})
|
'snapshots': 1,
|
||||||
|
'gigabytes': 1,
|
||||||
|
'share_networks': 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (200, {}, quota_set)
|
||||||
|
|
||||||
def get_os_quota_sets_test_defaults(self):
|
def get_os_quota_sets_test_defaults(self):
|
||||||
return (200, {}, {'quota_set': {
|
quota_set = {
|
||||||
'tenant_id': 'test',
|
'quota_set': {
|
||||||
'metadata_items': [],
|
'tenant_id': 'test',
|
||||||
'shares': 1,
|
'metadata_items': [],
|
||||||
'snapshots': 1,
|
'shares': 1,
|
||||||
'gigabytes': 1}})
|
'snapshots': 1,
|
||||||
|
'gigabytes': 1,
|
||||||
|
'share_networks': 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (200, {}, quota_set)
|
||||||
|
|
||||||
def put_os_quota_sets_test(self, body, **kw):
|
def put_os_quota_sets_test(self, body, **kw):
|
||||||
assert body.keys() == ['quota_set']
|
assert body.keys() == ['quota_set']
|
||||||
fakes.assert_has_keys(body['quota_set'],
|
fakes.assert_has_keys(body['quota_set'],
|
||||||
required=['tenant_id'])
|
required=['tenant_id'])
|
||||||
return (200, {}, {'quota_set': {
|
quota_set = {
|
||||||
'tenant_id': 'test',
|
'quota_set': {
|
||||||
'metadata_items': [],
|
'tenant_id': 'test',
|
||||||
'shares': 2,
|
'metadata_items': [],
|
||||||
'snapshots': 2,
|
'shares': 2,
|
||||||
'gigabytes': 1}})
|
'snapshots': 2,
|
||||||
|
'gigabytes': 1,
|
||||||
|
'share_networks': 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (200, {}, quota_set)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Quota Classes
|
# Quota Classes
|
||||||
#
|
#
|
||||||
|
|
||||||
def get_os_quota_class_sets_test(self, **kw):
|
def get_os_quota_class_sets_test(self, **kw):
|
||||||
return (200, {}, {'quota_class_set': {
|
quota_class_set = {
|
||||||
'class_name': 'test',
|
'quota_class_set': {
|
||||||
'metadata_items': [],
|
'class_name': 'test',
|
||||||
'shares': 1,
|
'metadata_items': [],
|
||||||
'snapshots': 1,
|
'shares': 1,
|
||||||
'gigabytes': 1}})
|
'snapshots': 1,
|
||||||
|
'gigabytes': 1,
|
||||||
|
'share_networks': 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (200, {}, quota_class_set)
|
||||||
|
|
||||||
def put_os_quota_class_sets_test(self, body, **kw):
|
def put_os_quota_class_sets_test(self, body, **kw):
|
||||||
assert body.keys() == ['quota_class_set']
|
assert body.keys() == ['quota_class_set']
|
||||||
fakes.assert_has_keys(body['quota_class_set'],
|
fakes.assert_has_keys(body['quota_class_set'],
|
||||||
required=['class_name'])
|
required=['class_name'])
|
||||||
return (200, {}, {'quota_class_set': {
|
quota_class_set = {
|
||||||
'class_name': 'test',
|
'quota_class_set': {
|
||||||
'metadata_items': [],
|
'class_name': 'test',
|
||||||
'shares': 2,
|
'metadata_items': [],
|
||||||
'snapshots': 2,
|
'shares': 2,
|
||||||
'gigabytes': 1}})
|
'snapshots': 2,
|
||||||
|
'gigabytes': 1,
|
||||||
|
'share_networks': 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (200, {}, quota_class_set)
|
||||||
|
|
||||||
def delete_os_quota_sets_test(self, **kw):
|
def delete_os_quota_sets_test(self, **kw):
|
||||||
return (202, {}, {})
|
return (202, {}, {})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user