Merge "Merge "missing" quotas with nova quotas"
This commit is contained in:
commit
55c77bdb59
@ -754,9 +754,7 @@ class DefaultQuotaSets(generic.View):
|
||||
if api.base.is_service_enabled(request, 'compute'):
|
||||
disabled_quotas = quotas.get_disabled_quotas(request)
|
||||
|
||||
all_quotas = quotas.NOVA_QUOTA_FIELDS + quotas.MISSING_QUOTA_FIELDS
|
||||
|
||||
filtered_quotas = [quota for quota in all_quotas
|
||||
filtered_quotas = [quota for quota in quotas.NOVA_QUOTA_FIELDS
|
||||
if quota not in disabled_quotas]
|
||||
|
||||
request_data = {
|
||||
|
@ -83,7 +83,9 @@ class ServicesViewTests(test.BaseAdminViewTests):
|
||||
'<Quota: (floating_ips, 1)>',
|
||||
'<Quota: (fixed_ips, 10)>',
|
||||
'<Quota: (security_groups, 10)>',
|
||||
'<Quota: (security_group_rules, 20)>']
|
||||
'<Quota: (security_group_rules, 20)>',
|
||||
'<Quota: (key_pairs, 100)>',
|
||||
'<Quota: (injected_file_path_bytes, 255)>']
|
||||
if neutron_enabled:
|
||||
expected_tabs.remove('<Quota: (floating_ips, 1)>')
|
||||
expected_tabs.remove('<Quota: (fixed_ips, 10)>')
|
||||
@ -99,7 +101,7 @@ class ServicesViewTests(test.BaseAdminViewTests):
|
||||
class UpdateDefaultQuotasTests(test.BaseAdminViewTests):
|
||||
def _get_quota_info(self, quota):
|
||||
quota_data = {}
|
||||
for field in (quotas.QUOTA_FIELDS + quotas.MISSING_QUOTA_FIELDS):
|
||||
for field in quotas.QUOTA_FIELDS:
|
||||
if field != 'fixed_ips':
|
||||
limit = quota.get(field).limit or 10
|
||||
quota_data[field] = int(limit)
|
||||
@ -123,7 +125,7 @@ class UpdateDefaultQuotasTests(test.BaseAdminViewTests):
|
||||
updated_quota = self._get_quota_info(quota)
|
||||
|
||||
# handle
|
||||
nova_fields = quotas.NOVA_QUOTA_FIELDS + quotas.MISSING_QUOTA_FIELDS
|
||||
nova_fields = quotas.NOVA_QUOTA_FIELDS
|
||||
nova_updated_quota = dict([(key, updated_quota[key]) for key in
|
||||
nova_fields if key != 'fixed_ips'])
|
||||
api.nova.default_quota_update(IsA(http.HttpRequest),
|
||||
|
@ -38,7 +38,7 @@ class UpdateDefaultQuotasView(workflows.WorkflowView):
|
||||
# get initial quota defaults
|
||||
try:
|
||||
quota_defaults = quotas.get_default_quota_data(self.request)
|
||||
for field in (quotas.QUOTA_FIELDS + quotas.MISSING_QUOTA_FIELDS):
|
||||
for field in quotas.QUOTA_FIELDS:
|
||||
initial[field] = quota_defaults.get(field).limit
|
||||
|
||||
except Exception:
|
||||
|
@ -24,7 +24,6 @@ from openstack_dashboard.api import cinder
|
||||
from openstack_dashboard.api import nova
|
||||
from openstack_dashboard.usage import quotas
|
||||
|
||||
ALL_NOVA_QUOTA_FIELDS = quotas.NOVA_QUOTA_FIELDS + quotas.MISSING_QUOTA_FIELDS
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -73,7 +72,7 @@ class UpdateDefaultQuotasAction(workflows.Action):
|
||||
|
||||
class UpdateDefaultQuotasStep(workflows.Step):
|
||||
action_class = UpdateDefaultQuotasAction
|
||||
contributes = (quotas.QUOTA_FIELDS + quotas.MISSING_QUOTA_FIELDS)
|
||||
contributes = quotas.QUOTA_FIELDS
|
||||
|
||||
|
||||
class UpdateDefaultQuotas(workflows.Workflow):
|
||||
@ -88,7 +87,7 @@ class UpdateDefaultQuotas(workflows.Workflow):
|
||||
def handle(self, request, data):
|
||||
# Update the default quotas.
|
||||
# `fixed_ips` update for quota class is not supported by novaclient
|
||||
nova_data = dict([(key, data[key]) for key in ALL_NOVA_QUOTA_FIELDS
|
||||
nova_data = dict([(key, data[key]) for key in quotas.NOVA_QUOTA_FIELDS
|
||||
if key != 'fixed_ips'])
|
||||
is_error_nova = False
|
||||
is_error_cinder = False
|
||||
|
@ -50,6 +50,7 @@ COMMON_HORIZONTAL_TEMPLATE = "identity/projects/_common_horizontal_form.html"
|
||||
|
||||
class ProjectQuotaAction(workflows.Action):
|
||||
ifcb_label = _("Injected File Content (Bytes)")
|
||||
ifpb_label = _("Length of Injected File Path")
|
||||
metadata_items = forms.IntegerField(min_value=-1,
|
||||
label=_("Metadata Items"))
|
||||
cores = forms.IntegerField(min_value=-1, label=_("VCPUs"))
|
||||
@ -58,6 +59,9 @@ class ProjectQuotaAction(workflows.Action):
|
||||
label=_("Injected Files"))
|
||||
injected_file_content_bytes = forms.IntegerField(min_value=-1,
|
||||
label=ifcb_label)
|
||||
key_pairs = forms.IntegerField(min_value=-1, label=_("Key Pairs"))
|
||||
injected_file_path_bytes = forms.IntegerField(min_value=-1,
|
||||
label=ifpb_label)
|
||||
volumes = forms.IntegerField(min_value=-1, label=_("Volumes"))
|
||||
snapshots = forms.IntegerField(min_value=-1, label=_("Volume Snapshots"))
|
||||
gigabytes = forms.IntegerField(
|
||||
|
@ -400,7 +400,9 @@ def data(TEST):
|
||||
injected_files='1',
|
||||
cores='10',
|
||||
security_groups='10',
|
||||
security_group_rules='20')
|
||||
security_group_rules='20',
|
||||
key_pairs=100,
|
||||
injected_file_path_bytes=255)
|
||||
quota = quotas.QuotaSet(quotas.QuotaSetManager(None), quota_data)
|
||||
TEST.quotas.nova = base.QuotaSet(quota)
|
||||
TEST.quotas.add(base.QuotaSet(quota))
|
||||
|
@ -50,7 +50,9 @@ class QuotaTests(test.APITestCase):
|
||||
'ram': {'available': 8976, 'used': 1024, 'quota': 10000},
|
||||
'floating_ips': {'available': 0, 'used': 2, 'quota': 1},
|
||||
'instances': {'available': 8, 'used': 2, 'quota': 10},
|
||||
'cores': {'available': 8, 'used': 2, 'quota': 10}
|
||||
'cores': {'available': 8, 'used': 2, 'quota': 10},
|
||||
'key_pairs': {'quota': 100},
|
||||
'injected_file_path_bytes': {'quota': 255}
|
||||
})
|
||||
else:
|
||||
inf = float('inf')
|
||||
@ -162,7 +164,7 @@ class QuotaTests(test.APITestCase):
|
||||
result_quotas = quotas.get_disabled_quotas(self.request)
|
||||
expected_quotas = list(quotas.CINDER_QUOTA_FIELDS) + \
|
||||
list(quotas.NEUTRON_QUOTA_FIELDS) + \
|
||||
list(quotas.NOVA_QUOTA_FIELDS) + list(quotas.MISSING_QUOTA_FIELDS)
|
||||
list(quotas.NOVA_QUOTA_FIELDS)
|
||||
self.assertItemsEqual(result_quotas, expected_quotas)
|
||||
|
||||
@test.create_stubs({api.nova: ('server_list',
|
||||
|
@ -39,10 +39,11 @@ NOVA_QUOTA_FIELDS = ("metadata_items",
|
||||
"floating_ips",
|
||||
"fixed_ips",
|
||||
"security_groups",
|
||||
"security_group_rules",)
|
||||
"security_group_rules",
|
||||
"key_pairs",
|
||||
"injected_file_path_bytes",
|
||||
)
|
||||
|
||||
MISSING_QUOTA_FIELDS = ("key_pairs",
|
||||
"injected_file_path_bytes",)
|
||||
|
||||
CINDER_QUOTA_FIELDS = ("volumes",
|
||||
"snapshots",
|
||||
@ -276,9 +277,6 @@ def get_disabled_quotas(request):
|
||||
if not (base.is_service_enabled(request, 'compute') and
|
||||
nova.can_set_quotas()):
|
||||
disabled_quotas.update(NOVA_QUOTA_FIELDS)
|
||||
# The 'missing' quota fields are all nova (this is hardcoded in
|
||||
# dashboards.admin.defaults.workflows)
|
||||
disabled_quotas.update(MISSING_QUOTA_FIELDS)
|
||||
|
||||
# There appear to be no glance quota fields currently
|
||||
return disabled_quotas
|
||||
|
Loading…
Reference in New Issue
Block a user