Changes for volume type quotas.
blueprint quotas-limits-by-voltype Change-Id: I1bb676689c79fe1b14a14a81b21105a02ec117ef
This commit is contained in:
parent
aef613f994
commit
784f53f0a0
@ -36,20 +36,10 @@ class QuotaClassSetManager(base.Manager):
|
||||
return self._get("/os-quota-class-sets/%s" % (class_name),
|
||||
"quota_class_set")
|
||||
|
||||
def update(self,
|
||||
class_name,
|
||||
volumes=None,
|
||||
snapshots=None,
|
||||
gigabytes=None):
|
||||
def update(self, class_name, **updates):
|
||||
body = {'quota_class_set': {'class_name': class_name}}
|
||||
|
||||
body = {'quota_class_set': {
|
||||
'class_name': class_name,
|
||||
'volumes': volumes,
|
||||
'snapshots': snapshots,
|
||||
'gigabytes': gigabytes}}
|
||||
|
||||
for key in list(body['quota_class_set'].keys()):
|
||||
if body['quota_class_set'][key] is None:
|
||||
body['quota_class_set'].pop(key)
|
||||
for update in updates.keys():
|
||||
body['quota_class_set'][update] = updates[update]
|
||||
|
||||
self._update('/os-quota-class-sets/%s' % (class_name), body)
|
||||
|
@ -37,17 +37,11 @@ class QuotaSetManager(base.Manager):
|
||||
tenant_id = tenant_id.tenant_id
|
||||
return self._get("/os-quota-sets/%s" % (tenant_id), "quota_set")
|
||||
|
||||
def update(self, tenant_id, volumes=None, snapshots=None, gigabytes=None):
|
||||
def update(self, tenant_id, **updates):
|
||||
body = {'quota_set': {'tenant_id': tenant_id}}
|
||||
|
||||
body = {'quota_set': {
|
||||
'tenant_id': tenant_id,
|
||||
'volumes': volumes,
|
||||
'snapshots': snapshots,
|
||||
'gigabytes': gigabytes}}
|
||||
|
||||
for key in list(body['quota_set'].keys()):
|
||||
if body['quota_set'][key] is None:
|
||||
body['quota_set'].pop(key)
|
||||
for update in updates.keys():
|
||||
body['quota_set'][update] = updates[update]
|
||||
|
||||
self._update('/os-quota-sets/%s' % (tenant_id), body)
|
||||
|
||||
|
@ -539,12 +539,19 @@ def do_credentials(cs, args):
|
||||
utils.print_dict(catalog['access']['user'], "User Credentials")
|
||||
utils.print_dict(catalog['access']['token'], "Token")
|
||||
|
||||
|
||||
_quota_resources = ['volumes', 'snapshots', 'gigabytes']
|
||||
|
||||
|
||||
def _quota_show(quotas):
|
||||
quota_dict = {}
|
||||
for resource in _quota_resources:
|
||||
for resource in quotas._info.keys():
|
||||
good_name = False
|
||||
for name in _quota_resources:
|
||||
if resource.startswith(name):
|
||||
good_name = True
|
||||
if not good_name:
|
||||
continue
|
||||
quota_dict[resource] = getattr(quotas, resource, None)
|
||||
utils.print_dict(quota_dict)
|
||||
|
||||
@ -554,6 +561,8 @@ def _quota_update(manager, identifier, args):
|
||||
for resource in _quota_resources:
|
||||
val = getattr(args, resource, None)
|
||||
if val is not None:
|
||||
if args.volume_type:
|
||||
resource = resource + '_%s' % args.volume_type
|
||||
updates[resource] = val
|
||||
|
||||
if updates:
|
||||
@ -592,6 +601,10 @@ def do_quota_defaults(cs, args):
|
||||
metavar='<gigabytes>',
|
||||
type=int, default=None,
|
||||
help='New value for the "gigabytes" quota.')
|
||||
@utils.arg('--volume-type',
|
||||
metavar='<volume_type_name>',
|
||||
default=None,
|
||||
help='Volume type (Optional, Default=None)')
|
||||
@utils.service_type('volume')
|
||||
def do_quota_update(cs, args):
|
||||
"""Update the quotas for a tenant."""
|
||||
@ -622,6 +635,10 @@ def do_quota_class_show(cs, args):
|
||||
metavar='<gigabytes>',
|
||||
type=int, default=None,
|
||||
help='New value for the "gigabytes" quota.')
|
||||
@utils.arg('--volume-type',
|
||||
metavar='<volume_type_name>',
|
||||
default=None,
|
||||
help='Volume type (Optional, Default=None)')
|
||||
@utils.service_type('volume')
|
||||
def do_quota_class_update(cs, args):
|
||||
"""Update the quotas for a quota class."""
|
||||
|
@ -34,20 +34,10 @@ class QuotaClassSetManager(base.Manager):
|
||||
return self._get("/os-quota-class-sets/%s" % (class_name),
|
||||
"quota_class_set")
|
||||
|
||||
def update(self,
|
||||
class_name,
|
||||
volumes=None,
|
||||
snapshots=None,
|
||||
gigabytes=None):
|
||||
def update(self, class_name, **updates):
|
||||
body = {'quota_class_set': {'class_name': class_name}}
|
||||
|
||||
body = {'quota_class_set': {
|
||||
'class_name': class_name,
|
||||
'volumes': volumes,
|
||||
'snapshots': snapshots,
|
||||
'gigabytes': gigabytes}}
|
||||
|
||||
for key in list(body['quota_class_set'].keys()):
|
||||
if body['quota_class_set'][key] is None:
|
||||
body['quota_class_set'].pop(key)
|
||||
for update in updates.keys():
|
||||
body['quota_class_set'][update] = updates[update]
|
||||
|
||||
self._update('/os-quota-class-sets/%s' % (class_name), body)
|
||||
|
@ -35,17 +35,11 @@ class QuotaSetManager(base.Manager):
|
||||
tenant_id = tenant_id.tenant_id
|
||||
return self._get("/os-quota-sets/%s" % (tenant_id), "quota_set")
|
||||
|
||||
def update(self, tenant_id, volumes=None, snapshots=None, gigabytes=None):
|
||||
def update(self, tenant_id, **updates):
|
||||
body = {'quota_set': {'tenant_id': tenant_id}}
|
||||
|
||||
body = {'quota_set': {
|
||||
'tenant_id': tenant_id,
|
||||
'volumes': volumes,
|
||||
'snapshots': snapshots,
|
||||
'gigabytes': gigabytes}}
|
||||
|
||||
for key in list(body['quota_set'].keys()):
|
||||
if body['quota_set'][key] is None:
|
||||
body['quota_set'].pop(key)
|
||||
for update in updates.keys():
|
||||
body['quota_set'][update] = updates[update]
|
||||
|
||||
self._update('/os-quota-sets/%s' % (tenant_id), body)
|
||||
|
||||
|
@ -604,12 +604,19 @@ def do_credentials(cs, args):
|
||||
utils.print_dict(catalog['access']['user'], "User Credentials")
|
||||
utils.print_dict(catalog['access']['token'], "Token")
|
||||
|
||||
|
||||
_quota_resources = ['volumes', 'snapshots', 'gigabytes']
|
||||
|
||||
|
||||
def _quota_show(quotas):
|
||||
quota_dict = {}
|
||||
for resource in _quota_resources:
|
||||
for resource in quotas._info.keys():
|
||||
good_name = False
|
||||
for name in _quota_resources:
|
||||
if resource.startswith(name):
|
||||
good_name = True
|
||||
if not good_name:
|
||||
continue
|
||||
quota_dict[resource] = getattr(quotas, resource, None)
|
||||
utils.print_dict(quota_dict)
|
||||
|
||||
@ -619,6 +626,8 @@ def _quota_update(manager, identifier, args):
|
||||
for resource in _quota_resources:
|
||||
val = getattr(args, resource, None)
|
||||
if val is not None:
|
||||
if args.volume_type:
|
||||
resource = resource + '_%s' % args.volume_type
|
||||
updates[resource] = val
|
||||
|
||||
if updates:
|
||||
@ -660,6 +669,10 @@ def do_quota_defaults(cs, args):
|
||||
metavar='<gigabytes>',
|
||||
type=int, default=None,
|
||||
help='New value for the "gigabytes" quota.')
|
||||
@utils.arg('--volume-type',
|
||||
metavar='<volume_type_name>',
|
||||
default=None,
|
||||
help='Volume type (Optional, Default=None)')
|
||||
@utils.service_type('volume')
|
||||
def do_quota_update(cs, args):
|
||||
"""Update the quotas for a tenant."""
|
||||
@ -692,6 +705,10 @@ def do_quota_class_show(cs, args):
|
||||
metavar='<gigabytes>',
|
||||
type=int, default=None,
|
||||
help='New value for the "gigabytes" quota.')
|
||||
@utils.arg('--volume-type',
|
||||
metavar='<volume_type_name>',
|
||||
default=None,
|
||||
help='Volume type (Optional, Default=None)')
|
||||
@utils.service_type('volume')
|
||||
def do_quota_class_update(cs, args):
|
||||
"""Update the quotas for a quota class."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user