
This reverts commit ed586a0355fb99a5b1fbeadfc0625f0ceffe8b72. The quota_class subcommand in python-novaclient was used to set default quota values so it shouldn't have been removed. As now it is being restored, the defaults quota panel is being restored too. Related mailing list thread on the topic: http://lists.openstack.org/pipermail/openstack-dev/2014-May/035383.html Resolved merge conflicts by hand in: openstack_dashboard/api/cinder.py openstack_dashboard/dashboards/admin/info/tabs.py openstack_dashboard/dashboards/admin/info/tests.py Updated translatable segments to match refactors in openstack_dashboard/dashboards/admin/defaults/workflows.py openstack_dashboard/dashboards/admin/defaults/tables.py Fixed most egregious post-merge styling errors in openstack_dashboard/dashboards/admin/defaults/templates/defaults/index.html (probably should have been separate, but I just couldn't let it out that way!) Removed unrelated file that was allowed to be part of the original commit doc/source/topics/settings.rst Co-Authored-By: Doug Fish <drfish@us.ibm.com> Change-Id: Ic4c4ecec843c7ea9afd0db36ce0eb15952da15b3 Partial-Bug: #1299517
101 lines
4.4 KiB
Python
101 lines
4.4 KiB
Python
# Copyright 2013 Kylin, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from horizon import exceptions
|
|
from horizon import forms
|
|
from horizon import workflows
|
|
|
|
from openstack_dashboard.api import base
|
|
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
|
|
|
|
|
|
class UpdateDefaultQuotasAction(workflows.Action):
|
|
ifcb_label = _("Injected File Content Bytes")
|
|
ifpb_label = _("Length of Injected File Path")
|
|
injected_file_content_bytes = forms.IntegerField(min_value=-1,
|
|
label=ifcb_label)
|
|
metadata_items = forms.IntegerField(min_value=-1,
|
|
label=_("Metadata Items"))
|
|
ram = forms.IntegerField(min_value=-1, label=_("RAM (MB)"))
|
|
floating_ips = forms.IntegerField(min_value=-1, label=_("Floating IPs"))
|
|
key_pairs = forms.IntegerField(min_value=-1, label=_("Key Pairs"))
|
|
injected_file_path_bytes = forms.IntegerField(min_value=-1,
|
|
label=ifpb_label)
|
|
instances = forms.IntegerField(min_value=-1, label=_("Instances"))
|
|
security_group_rules = forms.IntegerField(min_value=-1,
|
|
label=_("Security Group Rules"))
|
|
injected_files = forms.IntegerField(min_value=-1,
|
|
label=_("Injected Files"))
|
|
cores = forms.IntegerField(min_value=-1, label=_("VCPUs"))
|
|
security_groups = forms.IntegerField(min_value=-1,
|
|
label=_("Security Groups"))
|
|
gigabytes = forms.IntegerField(min_value=-1,
|
|
label=_("Total Size of Volumes and Snapshots (GB)"))
|
|
snapshots = forms.IntegerField(min_value=-1, label=_("Volume Snapshots"))
|
|
volumes = forms.IntegerField(min_value=-1, label=_("Volumes"))
|
|
|
|
def __init__(self, request, *args, **kwargs):
|
|
super(UpdateDefaultQuotasAction, self).__init__(request,
|
|
*args,
|
|
**kwargs)
|
|
disabled_quotas = quotas.get_disabled_quotas(request)
|
|
for field in disabled_quotas:
|
|
if field in self.fields:
|
|
self.fields[field].required = False
|
|
self.fields[field].widget = forms.HiddenInput()
|
|
|
|
class Meta:
|
|
name = _("Default Quotas")
|
|
slug = 'update_default_quotas'
|
|
help_text = _("From here you can update the default quotas "
|
|
"(max limits).")
|
|
|
|
|
|
class UpdateDefaultQuotasStep(workflows.Step):
|
|
action_class = UpdateDefaultQuotasAction
|
|
contributes = (quotas.QUOTA_FIELDS + quotas.MISSING_QUOTA_FIELDS)
|
|
|
|
|
|
class UpdateDefaultQuotas(workflows.Workflow):
|
|
slug = "update_default_quotas"
|
|
name = _("Update Default Quotas")
|
|
finalize_button_name = _("Update Defaults")
|
|
success_message = _('Default quotas updated.')
|
|
failure_message = _('Unable to update default quotas.')
|
|
success_url = "horizon:admin:defaults:index"
|
|
default_steps = (UpdateDefaultQuotasStep,)
|
|
|
|
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
|
|
if key != 'fixed_ips'])
|
|
try:
|
|
nova.default_quota_update(request, **nova_data)
|
|
|
|
if base.is_service_enabled(request, 'volume'):
|
|
cinder_data = dict([(key, data[key]) for key in
|
|
quotas.CINDER_QUOTA_FIELDS])
|
|
cinder.default_quota_update(request, **cinder_data)
|
|
except Exception:
|
|
exceptions.handle(request, _('Unable to update default quotas.'))
|
|
return True
|