Merge "Allow admin to edit project quotas for security groups and rules"
This commit is contained in:
commit
986182b327
@ -60,6 +60,8 @@ class ServicessViewTests(test.BaseAdminViewTests):
|
||||
'<Quota: (instances, 10)>',
|
||||
'<Quota: (volumes, 1)>',
|
||||
'<Quota: (cores, 10)>',
|
||||
'<Quota: (security_groups, 10)>',
|
||||
'<Quota: (security_group_rules, 20)>',
|
||||
'<Quota: (injected_file_content_bytes, 1)>',
|
||||
'<Quota: (metadata_items, 1)>',
|
||||
'<Quota: (injected_files, 1)>',
|
||||
@ -68,4 +70,7 @@ class ServicessViewTests(test.BaseAdminViewTests):
|
||||
'<Quota: (floating_ips, 1)>',
|
||||
'<Quota: (instances, 10)>',
|
||||
'<Quota: (volumes, 1)>',
|
||||
'<Quota: (cores, 10)>'])
|
||||
'<Quota: (cores, 10)>',
|
||||
'<Quota: (security_groups, 10)>',
|
||||
'<Quota: (security_group_rules, 20)>'],
|
||||
ordered=False)
|
||||
|
@ -46,7 +46,9 @@ QUOTA_FIELDS = ("metadata_items",
|
||||
"volumes",
|
||||
"gigabytes",
|
||||
"ram",
|
||||
"floating_ips")
|
||||
"floating_ips",
|
||||
"security_groups",
|
||||
"security_group_rules")
|
||||
|
||||
PROJECT_INFO_FIELDS = ("name",
|
||||
"description",
|
||||
|
@ -40,17 +40,21 @@ ADD_USER_URL = "horizon:admin:projects:create_user"
|
||||
class UpdateProjectQuotaAction(workflows.Action):
|
||||
ifcb_label = _("Injected File Content Bytes")
|
||||
metadata_items = forms.IntegerField(min_value=-1,
|
||||
label=_("Metadata Items"))
|
||||
label=_("Metadata Items"))
|
||||
cores = forms.IntegerField(min_value=-1, label=_("VCPUs"))
|
||||
instances = forms.IntegerField(min_value=-1, label=_("Instances"))
|
||||
injected_files = forms.IntegerField(min_value=-1,
|
||||
label=_("Injected Files"))
|
||||
label=_("Injected Files"))
|
||||
injected_file_content_bytes = forms.IntegerField(min_value=-1,
|
||||
label=ifcb_label)
|
||||
volumes = forms.IntegerField(min_value=-1, label=_("Volumes"))
|
||||
gigabytes = forms.IntegerField(min_value=-1, label=_("Gigabytes"))
|
||||
ram = forms.IntegerField(min_value=-1, label=_("RAM (MB)"))
|
||||
floating_ips = forms.IntegerField(min_value=-1, label=_("Floating IPs"))
|
||||
security_groups = forms.IntegerField(min_value=-1,
|
||||
label=_("Security Groups"))
|
||||
security_group_rules = forms.IntegerField(min_value=-1,
|
||||
label=_("Security Group Rules"))
|
||||
|
||||
class Meta:
|
||||
name = _("Quota")
|
||||
@ -70,7 +74,9 @@ class UpdateProjectQuota(workflows.Step):
|
||||
"volumes",
|
||||
"gigabytes",
|
||||
"ram",
|
||||
"floating_ips")
|
||||
"floating_ips",
|
||||
"security_groups",
|
||||
"security_group_rules")
|
||||
|
||||
|
||||
class CreateProjectInfoAction(workflows.Action):
|
||||
@ -247,17 +253,20 @@ class CreateProject(workflows.Workflow):
|
||||
# update the project quota
|
||||
ifcb = data['injected_file_content_bytes']
|
||||
try:
|
||||
api.nova.tenant_quota_update(request,
|
||||
project_id,
|
||||
metadata_items=data['metadata_items'],
|
||||
injected_file_content_bytes=ifcb,
|
||||
volumes=data['volumes'],
|
||||
gigabytes=data['gigabytes'],
|
||||
ram=data['ram'],
|
||||
floating_ips=data['floating_ips'],
|
||||
instances=data['instances'],
|
||||
injected_files=data['injected_files'],
|
||||
cores=data['cores'])
|
||||
api.nova.tenant_quota_update(
|
||||
request,
|
||||
project_id,
|
||||
metadata_items=data['metadata_items'],
|
||||
injected_file_content_bytes=ifcb,
|
||||
volumes=data['volumes'],
|
||||
gigabytes=data['gigabytes'],
|
||||
ram=data['ram'],
|
||||
floating_ips=data['floating_ips'],
|
||||
instances=data['instances'],
|
||||
injected_files=data['injected_files'],
|
||||
cores=data['cores'],
|
||||
security_groups=data['security_groups'],
|
||||
security_group_rules=data['security_group_rules'])
|
||||
except:
|
||||
exceptions.handle(request, _('Unable to set project quotas.'))
|
||||
return True
|
||||
@ -381,17 +390,21 @@ class UpdateProject(workflows.Workflow):
|
||||
# TODO(gabriel): Once nova-volume is fully deprecated the
|
||||
# "volumes" and "gigabytes" quotas should no longer be sent to
|
||||
# the nova API to be updated anymore.
|
||||
nova.tenant_quota_update(request,
|
||||
project_id,
|
||||
metadata_items=data['metadata_items'],
|
||||
injected_file_content_bytes=ifcb,
|
||||
volumes=data['volumes'],
|
||||
gigabytes=data['gigabytes'],
|
||||
ram=data['ram'],
|
||||
floating_ips=data['floating_ips'],
|
||||
instances=data['instances'],
|
||||
injected_files=data['injected_files'],
|
||||
cores=data['cores'])
|
||||
nova.tenant_quota_update(
|
||||
request,
|
||||
project_id,
|
||||
metadata_items=data['metadata_items'],
|
||||
injected_file_content_bytes=ifcb,
|
||||
volumes=data['volumes'],
|
||||
gigabytes=data['gigabytes'],
|
||||
ram=data['ram'],
|
||||
floating_ips=data['floating_ips'],
|
||||
instances=data['instances'],
|
||||
injected_files=data['injected_files'],
|
||||
cores=data['cores'],
|
||||
security_groups=data['security_groups'],
|
||||
security_group_rules=data['security_group_rules'])
|
||||
|
||||
if is_service_enabled(request, 'volume'):
|
||||
cinder.tenant_quota_update(request,
|
||||
project_id,
|
||||
|
@ -297,7 +297,9 @@ def data(TEST):
|
||||
floating_ips='1',
|
||||
instances='10',
|
||||
injected_files='1',
|
||||
cores='10')
|
||||
cores='10',
|
||||
security_groups='10',
|
||||
security_group_rules='20')
|
||||
quota = quotas.QuotaSet(quotas.QuotaSetManager(None), quota_data)
|
||||
TEST.quotas.nova = QuotaSetWrapper(quota)
|
||||
TEST.quotas.add(QuotaSetWrapper(quota))
|
||||
|
@ -60,6 +60,8 @@ class QuotaTests(test.APITestCase):
|
||||
'injected_file_content_bytes': {'quota': 1},
|
||||
'metadata_items': {'quota': 1},
|
||||
'injected_files': {'quota': 1},
|
||||
'security_groups': {'quota': 10},
|
||||
'security_group_rules': {'quota': 20},
|
||||
'gigabytes': {'available': 920, 'used': 80, 'quota': 1000},
|
||||
'ram': {'available': 8976, 'used': 1024, 'quota': 10000},
|
||||
'floating_ips': {'available': 0, 'used': 2, 'quota': 1},
|
||||
@ -95,6 +97,8 @@ class QuotaTests(test.APITestCase):
|
||||
'injected_file_content_bytes': {'quota': 1},
|
||||
'metadata_items': {'quota': 1},
|
||||
'injected_files': {'quota': 1},
|
||||
'security_groups': {'quota': 10},
|
||||
'security_group_rules': {'quota': 20},
|
||||
'ram': {'available': 8976, 'used': 1024, 'quota': 10000},
|
||||
'floating_ips': {'available': 0, 'used': 2, 'quota': 1},
|
||||
'instances': {'available': 8, 'used': 2, 'quota': 10},
|
||||
@ -127,6 +131,8 @@ class QuotaTests(test.APITestCase):
|
||||
'injected_file_content_bytes': {'quota': 1},
|
||||
'metadata_items': {'quota': 1},
|
||||
'injected_files': {'quota': 1},
|
||||
'security_groups': {'quota': 10},
|
||||
'security_group_rules': {'quota': 20},
|
||||
'ram': {'available': 10000, 'used': 0, 'quota': 10000},
|
||||
'floating_ips': {'available': 1, 'used': 0, 'quota': 1},
|
||||
'instances': {'available': 10, 'used': 0, 'quota': 10},
|
||||
@ -168,6 +174,8 @@ class QuotaTests(test.APITestCase):
|
||||
'injected_file_content_bytes': {'quota': 1},
|
||||
'metadata_items': {'quota': 1},
|
||||
'injected_files': {'quota': 1},
|
||||
'security_groups': {'quota': 10},
|
||||
'security_group_rules': {'quota': 20},
|
||||
'gigabytes': {'available': 920, 'used': 80, 'quota': 1000},
|
||||
'ram': {'available': float("inf"), 'used': 1024,
|
||||
'quota': float("inf")},
|
||||
|
@ -6,7 +6,7 @@ netaddr
|
||||
python-cinderclient
|
||||
python-glanceclient<2
|
||||
python-keystoneclient
|
||||
python-novaclient>=2.10.0,<3
|
||||
python-novaclient>=2.11.1,<3
|
||||
python-quantumclient>=2.0
|
||||
python-swiftclient>1.1,<2
|
||||
pytz
|
||||
|
Loading…
Reference in New Issue
Block a user