Added quota for share-networks

Partially-implements bp quota-for-share-networks

Change-Id: I5977fe3f8bf9cbfa341d0d7332d2d536f4b3006a
This commit is contained in:
vponomaryov 2014-03-06 05:33:27 -05:00
parent 630985649f
commit ef0c7e13be
4 changed files with 83 additions and 39 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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='<gigabytes>',
type=int, default=None,
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',
dest='force',
action="store_true",
@ -242,6 +246,10 @@ def do_quota_class_show(cs, args):
metavar='<gigabytes>',
type=int, default=None,
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')
def do_quota_class_update(cs, args):
"""Update the quotas for a quota class."""

View File

@ -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, {}, {})