Merge "Reduce duplicate definitions about quota sets"
This commit is contained in:
commit
43447eb368
@ -23,6 +23,8 @@ from openstack_dashboard.api import keystone
|
||||
from openstack_dashboard.usage import quotas
|
||||
from .tables import QuotasTable, ServicesTable
|
||||
from openstack_dashboard.api.base import is_service_enabled
|
||||
from openstack_dashboard.dashboards.admin.projects.workflows import \
|
||||
CINDER_QUOTA_FIELDS
|
||||
|
||||
|
||||
class DefaultQuotasTab(tabs.TableTab):
|
||||
@ -35,7 +37,7 @@ class DefaultQuotasTab(tabs.TableTab):
|
||||
request = self.tab_group.request
|
||||
disabled_quotas = []
|
||||
if not is_service_enabled(self.request, 'volume'):
|
||||
disabled_quotas.extend(['volumes', 'gigabytes'])
|
||||
disabled_quotas.extend(CINDER_QUOTA_FIELDS)
|
||||
try:
|
||||
quota_set = quotas.get_default_quota_data(request, disabled_quotas)
|
||||
data = quota_set.items
|
||||
|
@ -33,13 +33,10 @@ from openstack_dashboard.usage import quotas
|
||||
from openstack_dashboard.dashboards.admin.users.views import CreateView
|
||||
from .forms import CreateUser
|
||||
from .tables import TenantsTable, TenantUsersTable, AddUsersTable
|
||||
from .workflows import CreateProject, UpdateProject, NOVA_QUOTA_FIELDS, \
|
||||
CINDER_QUOTA_FIELDS
|
||||
from .workflows import CreateProject, UpdateProject, QUOTA_FIELDS
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
QUOTA_FIELDS = NOVA_QUOTA_FIELDS + CINDER_QUOTA_FIELDS
|
||||
|
||||
PROJECT_INFO_FIELDS = ("name",
|
||||
"description",
|
||||
"enabled")
|
||||
|
@ -48,6 +48,8 @@ NOVA_QUOTA_FIELDS = ("metadata_items",
|
||||
CINDER_QUOTA_FIELDS = ("volumes",
|
||||
"gigabytes",)
|
||||
|
||||
QUOTA_FIELDS = NOVA_QUOTA_FIELDS + CINDER_QUOTA_FIELDS
|
||||
|
||||
|
||||
class UpdateProjectQuotaAction(workflows.Action):
|
||||
ifcb_label = _("Injected File Content Bytes")
|
||||
@ -78,17 +80,7 @@ class UpdateProjectQuotaAction(workflows.Action):
|
||||
class UpdateProjectQuota(workflows.Step):
|
||||
action_class = UpdateProjectQuotaAction
|
||||
depends_on = ("project_id",)
|
||||
contributes = ("metadata_items",
|
||||
"cores",
|
||||
"instances",
|
||||
"injected_files",
|
||||
"injected_file_content_bytes",
|
||||
"volumes",
|
||||
"gigabytes",
|
||||
"ram",
|
||||
"floating_ips",
|
||||
"security_groups",
|
||||
"security_group_rules")
|
||||
contributes = QUOTA_FIELDS
|
||||
|
||||
|
||||
class CreateProjectInfoAction(workflows.Action):
|
||||
|
@ -6,6 +6,8 @@ from horizon.utils.memoized import memoized
|
||||
|
||||
from openstack_dashboard.api import nova, cinder, network
|
||||
from openstack_dashboard.api.base import is_service_enabled, QuotaSet
|
||||
from openstack_dashboard.dashboards.admin.projects.workflows import \
|
||||
CINDER_QUOTA_FIELDS
|
||||
|
||||
|
||||
class QuotaUsage(dict):
|
||||
@ -85,7 +87,7 @@ def tenant_quota_usages(request):
|
||||
# Get our quotas and construct our usage object.
|
||||
disabled_quotas = []
|
||||
if not is_service_enabled(request, 'volume'):
|
||||
disabled_quotas.extend(['volumes', 'gigabytes'])
|
||||
disabled_quotas.extend(CINDER_QUOTA_FIELDS)
|
||||
|
||||
usages = QuotaUsage()
|
||||
for quota in get_tenant_quota_data(request, disabled_quotas):
|
||||
|
Loading…
Reference in New Issue
Block a user