quota: Disable nova-network quotas completely
nova-network quotas are considered in usage/quotas.py previously. This commit completely always disables nova-network quotas. The nova API wrapper ensures nova-network quota fileds are not included in responses from tenant_quota_get and default_quota_get. Drop nova-network quota fields from the Admin Defaults panel and the Identity Project quota form. blueprint make-quotas-great-again Change-Id: Ie69d3003f62d3a124d79a1fea003092f73372187
This commit is contained in:
parent
e23048774b
commit
34fb3e5b0e
@ -235,6 +235,24 @@ class FlavorExtraSpec(object):
|
||||
self.value = val
|
||||
|
||||
|
||||
class QuotaSet(base.QuotaSet):
|
||||
|
||||
# We don't support nova-network, so we exclude nova-network relatd
|
||||
# quota fields from the response.
|
||||
ignore_quotas = {
|
||||
"floating_ips",
|
||||
"fixed_ips",
|
||||
"security_groups",
|
||||
"security_group_rules",
|
||||
}
|
||||
|
||||
def __init__(self, apiresource=None):
|
||||
super(QuotaSet, self).__init__(apiresource)
|
||||
for name in self.ignore_quotas:
|
||||
if name in self.items:
|
||||
del self.items[name]
|
||||
|
||||
|
||||
def get_auth_params_from_request(request):
|
||||
"""Extracts properties needed by novaclient call from the request object.
|
||||
|
||||
@ -682,7 +700,7 @@ def server_metadata_delete(request, instance_id, keys):
|
||||
|
||||
@profiler.trace
|
||||
def tenant_quota_get(request, tenant_id):
|
||||
return base.QuotaSet(novaclient(request).quotas.get(tenant_id))
|
||||
return QuotaSet(novaclient(request).quotas.get(tenant_id))
|
||||
|
||||
|
||||
@profiler.trace
|
||||
@ -693,7 +711,7 @@ def tenant_quota_update(request, tenant_id, **kwargs):
|
||||
|
||||
@profiler.trace
|
||||
def default_quota_get(request, tenant_id):
|
||||
return base.QuotaSet(novaclient(request).quotas.defaults(tenant_id))
|
||||
return QuotaSet(novaclient(request).quotas.defaults(tenant_id))
|
||||
|
||||
|
||||
@profiler.trace
|
||||
|
@ -55,11 +55,6 @@ def get_quota_name(quota):
|
||||
'key_pairs': _('Key Pairs'),
|
||||
'server_group_members': _('Server Group Members'),
|
||||
'server_groups': _('Server Groups'),
|
||||
# Nova (deprecated)
|
||||
'fixed_ips': _('Fixed IPs'),
|
||||
'floating_ips': _('Floating IPs'),
|
||||
'security_groups': _('Security Groups'),
|
||||
'security_group_rules': _('Security Group Rules'),
|
||||
# Cinder
|
||||
'volumes': _('Volumes'),
|
||||
'snapshots': _('Volume Snapshots'),
|
||||
|
@ -80,18 +80,8 @@ class ServicesViewTests(test.BaseAdminViewTests):
|
||||
'<Quota: (snapshots, 1)>',
|
||||
'<Quota: (volumes, 1)>',
|
||||
'<Quota: (cores, 10)>',
|
||||
'<Quota: (floating_ips, 1)>',
|
||||
'<Quota: (fixed_ips, 10)>',
|
||||
'<Quota: (security_groups, 10)>',
|
||||
'<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)>')
|
||||
if neutron_sg_enabled:
|
||||
expected_tabs.remove('<Quota: (security_groups, 10)>')
|
||||
expected_tabs.remove('<Quota: (security_group_rules, 20)>')
|
||||
|
||||
self.assertQuerysetEqual(quotas_tab._tables['quotas'].data,
|
||||
expected_tabs,
|
||||
@ -101,7 +91,9 @@ class ServicesViewTests(test.BaseAdminViewTests):
|
||||
class UpdateDefaultQuotasTests(test.BaseAdminViewTests):
|
||||
def _get_quota_info(self, quota):
|
||||
quota_data = {}
|
||||
for field in quotas.QUOTA_FIELDS:
|
||||
updatable_quota_fields = (quotas.NOVA_QUOTA_FIELDS |
|
||||
quotas.CINDER_QUOTA_FIELDS)
|
||||
for field in updatable_quota_fields:
|
||||
if field != 'fixed_ips':
|
||||
limit = quota.get(field).limit or 10
|
||||
quota_data[field] = int(limit)
|
||||
@ -115,8 +107,7 @@ class UpdateDefaultQuotasTests(test.BaseAdminViewTests):
|
||||
quota = self.quotas.first()
|
||||
|
||||
# init
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)).AndReturn(set())
|
||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||
|
||||
# update some fields
|
||||
|
@ -35,18 +35,13 @@ class UpdateDefaultQuotasAction(workflows.Action):
|
||||
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 (GiB)"))
|
||||
@ -86,10 +81,9 @@ 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 = {
|
||||
key: value for key, value in data.items()
|
||||
if key in quotas.NOVA_QUOTA_FIELDS and key != 'fixed_ips'
|
||||
if key in quotas.NOVA_QUOTA_FIELDS
|
||||
}
|
||||
is_error_nova = False
|
||||
is_error_cinder = False
|
||||
|
@ -333,7 +333,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
def test_add_project_post(self):
|
||||
project = self.tenants.first()
|
||||
quota = self.quotas.first()
|
||||
disabled_quotas = self.disabled_quotas.first()
|
||||
disabled_quotas = set()
|
||||
default_role = self.roles.first()
|
||||
default_domain = self._get_default_domain()
|
||||
domain_id = default_domain.id
|
||||
@ -345,7 +345,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
|
||||
# init
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||
|
||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||
@ -455,7 +455,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
.MultipleTimes().AndReturn(True)
|
||||
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
|
||||
quotas.get_default_quota_data(IsA(http.HttpRequest)) \
|
||||
.AndRaise(self.exceptions.nova)
|
||||
@ -506,7 +506,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.get_default_domain(IsA(http.HttpRequest)) \
|
||||
.MultipleTimes().AndReturn(default_domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||
|
||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||
@ -554,7 +554,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
def test_add_project_quota_update_error(self):
|
||||
project = self.tenants.first()
|
||||
quota = self.quotas.first()
|
||||
disabled_quotas = self.disabled_quotas.first()
|
||||
disabled_quotas = set()
|
||||
default_role = self.roles.first()
|
||||
default_domain = self._get_default_domain()
|
||||
domain_id = default_domain.id
|
||||
@ -566,7 +566,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.get_default_domain(IsA(http.HttpRequest)) \
|
||||
.MultipleTimes().AndReturn(default_domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||
|
||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||
@ -643,7 +643,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
def test_add_project_user_update_error(self):
|
||||
project = self.tenants.first()
|
||||
quota = self.quotas.first()
|
||||
disabled_quotas = self.disabled_quotas.first()
|
||||
disabled_quotas = set()
|
||||
default_role = self.roles.first()
|
||||
default_domain = self._get_default_domain()
|
||||
domain_id = default_domain.id
|
||||
@ -655,7 +655,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.get_default_domain(
|
||||
IsA(http.HttpRequest)).MultipleTimes().AndReturn(default_domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||
|
||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||
@ -739,7 +739,7 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.get_default_domain(IsA(http.HttpRequest)) \
|
||||
.AndReturn(default_domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_default_quota_data(IsA(http.HttpRequest)).AndReturn(quota)
|
||||
|
||||
api.keystone.get_default_role(IsA(http.HttpRequest)) \
|
||||
@ -916,7 +916,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||
.AndReturn(self.domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id) \
|
||||
.AndReturn(quota)
|
||||
@ -995,7 +995,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
|
||||
project = self.tenants.first()
|
||||
quota = self.quotas.first()
|
||||
disabled_quotas = self.disabled_quotas.first()
|
||||
disabled_quotas = set()
|
||||
default_role = self.roles.first()
|
||||
domain_id = project.domain_id
|
||||
users = self._get_all_users(domain_id)
|
||||
@ -1012,7 +1012,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||
.AndReturn(self.domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id) \
|
||||
.AndReturn(quota)
|
||||
@ -1179,7 +1179,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||
.AndReturn(self.domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id) \
|
||||
.AndReturn(quota)
|
||||
@ -1285,7 +1285,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
|
||||
project = self.tenants.first()
|
||||
quota = self.quotas.first()
|
||||
disabled_quotas = self.disabled_quotas.first()
|
||||
disabled_quotas = set()
|
||||
default_role = self.roles.first()
|
||||
domain_id = project.domain_id
|
||||
users = self._get_all_users(domain_id)
|
||||
@ -1302,7 +1302,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||
.AndReturn(self.domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id) \
|
||||
.AndReturn(quota)
|
||||
@ -1432,7 +1432,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||
.MultipleTimes().AndReturn(self.domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id) \
|
||||
.AndReturn(quota)
|
||||
@ -1491,7 +1491,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.user_list(IsA(http.HttpRequest),
|
||||
domain=domain_id).AndReturn(users)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
|
||||
self._check_role_list(keystone_api_version, role_assignments, groups,
|
||||
proj_users, roles, workflow_data)
|
||||
@ -1533,7 +1533,7 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
|
||||
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
|
||||
.AndReturn(self.domain)
|
||||
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.disabled_quotas.first())
|
||||
.AndReturn(set())
|
||||
quotas.get_tenant_quota_data(IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id).AndReturn(quota)
|
||||
self.mox.ReplayAll()
|
||||
|
@ -67,12 +67,6 @@ class ProjectQuotaAction(workflows.Action):
|
||||
gigabytes = forms.IntegerField(
|
||||
min_value=-1, label=_("Total Size of Volumes and Snapshots (GiB)"))
|
||||
ram = forms.IntegerField(min_value=-1, label=_("RAM (MB)"))
|
||||
floating_ips = forms.IntegerField(min_value=-1, label=_("Floating IPs"))
|
||||
fixed_ips = forms.IntegerField(min_value=-1, label=_("Fixed IPs"))
|
||||
security_groups = forms.IntegerField(min_value=-1,
|
||||
label=_("Security Groups"))
|
||||
security_group_rules = forms.IntegerField(min_value=-1,
|
||||
label=_("Security Group Rules"))
|
||||
|
||||
# Neutron
|
||||
security_group = forms.IntegerField(min_value=-1,
|
||||
|
@ -163,7 +163,6 @@ def data(TEST):
|
||||
TEST.volumes = utils.TestDataContainer()
|
||||
TEST.quotas = utils.TestDataContainer()
|
||||
TEST.quota_usages = utils.TestDataContainer()
|
||||
TEST.disabled_quotas = utils.TestDataContainer()
|
||||
TEST.usages = utils.TestDataContainer()
|
||||
TEST.certs = utils.TestDataContainer()
|
||||
TEST.availability_zones = utils.TestDataContainer()
|
||||
@ -297,27 +296,20 @@ def data(TEST):
|
||||
TEST.keypairs.add(keypair)
|
||||
|
||||
# Quota Sets
|
||||
quota_data = dict(metadata_items='1',
|
||||
injected_file_content_bytes='1',
|
||||
ram=10000,
|
||||
floating_ips='1',
|
||||
fixed_ips='10',
|
||||
instances='10',
|
||||
injected_files='1',
|
||||
cores='10',
|
||||
security_groups='10',
|
||||
security_group_rules='20',
|
||||
key_pairs=100,
|
||||
injected_file_path_bytes=255)
|
||||
quota_data = {
|
||||
'metadata_items': '1',
|
||||
'injected_file_content_bytes': '1',
|
||||
'ram': 10000,
|
||||
'instances': '10',
|
||||
'injected_files': '1',
|
||||
'cores': '10',
|
||||
'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))
|
||||
|
||||
# nova quotas disabled when neutron is enabled
|
||||
disabled_quotas_nova = {'floating_ips', 'fixed_ips',
|
||||
'security_groups', 'security_group_rules'}
|
||||
TEST.disabled_quotas.add(disabled_quotas_nova)
|
||||
|
||||
# Quota Usages
|
||||
quota_usage_data = {'gigabytes': {'used': 0,
|
||||
'quota': 1000},
|
||||
@ -327,10 +319,6 @@ def data(TEST):
|
||||
'quota': 10000},
|
||||
'cores': {'used': 0,
|
||||
'quota': 20},
|
||||
'floating_ips': {'used': 0,
|
||||
'quota': 10},
|
||||
'security_groups': {'used': 0,
|
||||
'quota': 10},
|
||||
'volumes': {'used': 0,
|
||||
'quota': 10}}
|
||||
quota_usage = usage_quotas.QuotaUsage()
|
||||
|
@ -44,11 +44,7 @@ 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},
|
||||
'fixed_ips': {'quota': 10},
|
||||
'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},
|
||||
'key_pairs': {'quota': 100},
|
||||
@ -81,8 +77,6 @@ class QuotaTests(test.APITestCase):
|
||||
@test.create_stubs({api.nova: ('server_list',
|
||||
'flavor_list',
|
||||
'tenant_quota_get',),
|
||||
api.neutron: ('tenant_floating_ip_list',
|
||||
'floating_ip_supported'),
|
||||
api.base: ('is_service_enabled',),
|
||||
cinder: ('volume_list', 'volume_snapshot_list',
|
||||
'tenant_quota_get',
|
||||
@ -97,12 +91,8 @@ class QuotaTests(test.APITestCase):
|
||||
servers = [s for s in self.servers.list() if s.tenant_id == tenant_id]
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.flavors.list())
|
||||
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
|
||||
.AndReturn(True)
|
||||
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.floating_ips.list())
|
||||
opts = {'tenant_id': tenant_id,
|
||||
'all_tenants': 1}
|
||||
'all_tenants': True}
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=opts) \
|
||||
.AndReturn([servers, False])
|
||||
api.nova.tenant_quota_get(IsA(http.HttpRequest), tenant_id) \
|
||||
@ -133,8 +123,6 @@ class QuotaTests(test.APITestCase):
|
||||
@test.create_stubs({api.nova: ('server_list',
|
||||
'flavor_list',
|
||||
'tenant_quota_get',),
|
||||
api.neutron: ('tenant_floating_ip_list',
|
||||
'floating_ip_supported'),
|
||||
api.base: ('is_service_enabled',),
|
||||
cinder: ('volume_list', 'volume_snapshot_list',
|
||||
'tenant_quota_get',
|
||||
@ -155,10 +143,6 @@ class QuotaTests(test.APITestCase):
|
||||
if s.tenant_id == self.request.user.tenant_id]
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.flavors.list())
|
||||
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
|
||||
.AndReturn(True)
|
||||
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.floating_ips.list())
|
||||
api.nova.server_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn([servers, False])
|
||||
api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \
|
||||
@ -217,8 +201,6 @@ class QuotaTests(test.APITestCase):
|
||||
@test.create_stubs({api.nova: ('server_list',
|
||||
'flavor_list',
|
||||
'tenant_quota_get',),
|
||||
api.neutron: ('tenant_floating_ip_list',
|
||||
'floating_ip_supported'),
|
||||
api.base: ('is_service_enabled',),
|
||||
api.cinder: ('is_volume_service_enabled',)})
|
||||
def test_tenant_quota_usages_without_volume(self):
|
||||
@ -236,10 +218,6 @@ class QuotaTests(test.APITestCase):
|
||||
.AndReturn(self.flavors.list())
|
||||
api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \
|
||||
.AndReturn(self.quotas.first())
|
||||
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
|
||||
.AndReturn(True)
|
||||
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.floating_ips.list())
|
||||
api.nova.server_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn([servers, False])
|
||||
|
||||
@ -259,8 +237,6 @@ class QuotaTests(test.APITestCase):
|
||||
@test.create_stubs({api.nova: ('server_list',
|
||||
'flavor_list',
|
||||
'tenant_quota_get',),
|
||||
api.neutron: ('tenant_floating_ip_list',
|
||||
'floating_ip_supported'),
|
||||
api.base: ('is_service_enabled',),
|
||||
api.cinder: ('is_volume_service_enabled',)})
|
||||
def test_tenant_quota_usages_no_instances_running(self):
|
||||
@ -275,10 +251,6 @@ class QuotaTests(test.APITestCase):
|
||||
.AndReturn(self.flavors.list())
|
||||
api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \
|
||||
.AndReturn(self.quotas.first())
|
||||
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
|
||||
.AndReturn(True)
|
||||
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn([])
|
||||
api.nova.server_list(IsA(http.HttpRequest)).AndReturn([[], False])
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -288,7 +260,6 @@ class QuotaTests(test.APITestCase):
|
||||
|
||||
expected_output.update({
|
||||
'ram': {'available': 10000, 'used': 0, 'quota': 10000},
|
||||
'floating_ips': {'available': 1, 'used': 0, 'quota': 1},
|
||||
'instances': {'available': 10, 'used': 0, 'quota': 10},
|
||||
'cores': {'available': 10, 'used': 0, 'quota': 10}})
|
||||
|
||||
@ -298,8 +269,6 @@ class QuotaTests(test.APITestCase):
|
||||
@test.create_stubs({api.nova: ('server_list',
|
||||
'flavor_list',
|
||||
'tenant_quota_get',),
|
||||
api.neutron: ('tenant_floating_ip_list',
|
||||
'floating_ip_supported'),
|
||||
api.base: ('is_service_enabled',),
|
||||
cinder: ('volume_list', 'volume_snapshot_list',
|
||||
'tenant_quota_get',
|
||||
@ -321,10 +290,6 @@ class QuotaTests(test.APITestCase):
|
||||
.AndReturn(self.flavors.list())
|
||||
api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \
|
||||
.AndReturn(inf_quota)
|
||||
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
|
||||
.AndReturn(True)
|
||||
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.floating_ips.list())
|
||||
api.nova.server_list(IsA(http.HttpRequest)).AndReturn([servers, False])
|
||||
opts = {'all_tenants': 1, 'project_id': self.request.user.tenant_id}
|
||||
cinder.volume_list(IsA(http.HttpRequest), opts) \
|
||||
@ -348,8 +313,6 @@ class QuotaTests(test.APITestCase):
|
||||
@test.create_stubs({api.nova: ('server_list',
|
||||
'flavor_list',
|
||||
'tenant_quota_get',),
|
||||
api.neutron: ('tenant_floating_ip_list',
|
||||
'floating_ip_supported'),
|
||||
api.base: ('is_service_enabled',),
|
||||
cinder: ('volume_list', 'volume_snapshot_list',
|
||||
'tenant_quota_get',
|
||||
@ -369,8 +332,6 @@ class QuotaTests(test.APITestCase):
|
||||
.AndReturn(self.flavors.list())
|
||||
api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \
|
||||
.AndReturn(self.quotas.first())
|
||||
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
|
||||
.AndReturn(False)
|
||||
api.nova.server_list(IsA(http.HttpRequest)).AndReturn([servers, False])
|
||||
opts = {'all_tenants': 1, 'project_id': self.request.user.tenant_id}
|
||||
cinder.volume_list(IsA(http.HttpRequest), opts) \
|
||||
@ -384,8 +345,6 @@ class QuotaTests(test.APITestCase):
|
||||
|
||||
quota_usages = quotas.tenant_quota_usages(self.request)
|
||||
expected_output = self.get_usages()
|
||||
expected_output['floating_ips']['used'] = 0
|
||||
expected_output['floating_ips']['available'] = 1
|
||||
|
||||
# Compare internal structure of usages to expected.
|
||||
self.assertItemsEqual(expected_output, quota_usages.usages)
|
||||
@ -419,7 +378,7 @@ class QuotaTests(test.APITestCase):
|
||||
_("Unable to retrieve volume limit information."))
|
||||
self.mox.ReplayAll()
|
||||
|
||||
quotas._get_quota_data(self.request, 'tenant_quota_get')
|
||||
quotas._get_quota_data(self.request, tenant_mode=True)
|
||||
|
||||
@test.create_stubs({api.base: ('is_service_enabled',),
|
||||
api.cinder: ('tenant_absolute_limits',
|
||||
@ -460,8 +419,7 @@ class QuotaTests(test.APITestCase):
|
||||
self.mox.ReplayAll()
|
||||
|
||||
disabled_quotas = quotas.get_disabled_quotas(self.request)
|
||||
expected = set(['floating_ips', 'fixed_ips', 'security_groups',
|
||||
'security_group_rules', 'router', 'floatingip'])
|
||||
expected = set(['router', 'floatingip'])
|
||||
self.assertEqual(expected, disabled_quotas)
|
||||
|
||||
def test_tenant_quota_usages_with_target_instances(self):
|
||||
@ -499,15 +457,15 @@ class QuotaTests(test.APITestCase):
|
||||
.MultipleTimes().AndReturn(True)
|
||||
|
||||
if use_compute_call:
|
||||
api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \
|
||||
.AndReturn(self.quotas.first())
|
||||
servers = [s for s in self.servers.list()
|
||||
if s.tenant_id == self.request.user.tenant_id]
|
||||
api.nova.server_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn([servers, False])
|
||||
if use_flavor_list:
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.flavors.list())
|
||||
api.nova.server_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn([servers, False])
|
||||
api.nova.tenant_quota_get(IsA(http.HttpRequest), '1') \
|
||||
.AndReturn(self.quotas.first())
|
||||
|
||||
if use_cinder_call:
|
||||
opts = {'all_tenants': 1,
|
||||
|
@ -40,14 +40,9 @@ NOVA_COMPUTE_QUOTA_FIELDS = {
|
||||
"key_pairs",
|
||||
}
|
||||
|
||||
NOVA_NETWORK_QUOTA_FIELDS = {
|
||||
"floating_ips",
|
||||
"fixed_ips",
|
||||
"security_groups",
|
||||
"security_group_rules",
|
||||
}
|
||||
|
||||
NOVA_QUOTA_FIELDS = NOVA_COMPUTE_QUOTA_FIELDS | NOVA_NETWORK_QUOTA_FIELDS
|
||||
# We no longer supports nova-network, so network related quotas from nova
|
||||
# are not considered.
|
||||
NOVA_QUOTA_FIELDS = NOVA_COMPUTE_QUOTA_FIELDS
|
||||
|
||||
CINDER_QUOTA_FIELDS = {"volumes",
|
||||
"snapshots",
|
||||
@ -65,21 +60,20 @@ NEUTRON_QUOTA_FIELDS = {"network",
|
||||
QUOTA_FIELDS = NOVA_QUOTA_FIELDS | CINDER_QUOTA_FIELDS | NEUTRON_QUOTA_FIELDS
|
||||
|
||||
QUOTA_NAMES = {
|
||||
# nova
|
||||
"metadata_items": _('Metadata Items'),
|
||||
"cores": _('VCPUs'),
|
||||
"instances": _('Instances'),
|
||||
"injected_files": _('Injected Files'),
|
||||
"injected_file_content_bytes": _('Injected File Content Bytes'),
|
||||
"ram": _('RAM (MB)'),
|
||||
"floating_ips": _('Floating IPs'),
|
||||
"fixed_ips": _('Fixed IPs'),
|
||||
"security_groups": _('Security Groups'),
|
||||
"security_group_rules": _('Security Group Rules'),
|
||||
"key_pairs": _('Key Pairs'),
|
||||
"injected_file_path_bytes": _('Injected File Path Bytes'),
|
||||
# cinder
|
||||
"volumes": _('Volumes'),
|
||||
"snapshots": _('Volume Snapshots'),
|
||||
"gigabytes": _('Total Size of Volumes and Snapshots (GB)'),
|
||||
# neutron
|
||||
"network": _("Networks"),
|
||||
"subnet": _("Subnets"),
|
||||
"port": _("Ports"),
|
||||
@ -207,19 +201,17 @@ def get_tenant_quota_data(request, disabled_quotas=None, tenant_id=None):
|
||||
tenant_id = tenant_id or request.user.tenant_id
|
||||
neutron_quotas = neutron.tenant_quota_get(request, tenant_id)
|
||||
|
||||
if 'floating_ips' in disabled_quotas:
|
||||
if 'floatingip' not in disabled_quotas:
|
||||
# Rename floatingip to floating_ips since that's how it's
|
||||
# expected in some places (e.g. Security & Access' Floating IPs)
|
||||
fips_quota = neutron_quotas.get('floatingip').limit
|
||||
qs.add(base.QuotaSet({'floating_ips': fips_quota}))
|
||||
if 'floatingip' not in disabled_quotas:
|
||||
# Rename floatingip to floating_ips since that's how it's
|
||||
# expected in some places (e.g. Security & Access' Floating IPs)
|
||||
fips_quota = neutron_quotas.get('floatingip').limit
|
||||
qs.add(base.QuotaSet({'floating_ips': fips_quota}))
|
||||
|
||||
if 'security_groups' in disabled_quotas:
|
||||
if 'security_group' not in disabled_quotas:
|
||||
# Rename security_group to security_groups since that's how it's
|
||||
# expected in some places (e.g. Security & Access' Security Groups)
|
||||
sec_quota = neutron_quotas.get('security_group').limit
|
||||
qs.add(base.QuotaSet({'security_groups': sec_quota}))
|
||||
if 'security_group' not in disabled_quotas:
|
||||
# Rename security_group to security_groups since that's how it's
|
||||
# expected in some places (e.g. Security & Access' Security Groups)
|
||||
sec_quota = neutron_quotas.get('security_group').limit
|
||||
qs.add(base.QuotaSet({'security_groups': sec_quota}))
|
||||
|
||||
if 'network' not in disabled_quotas:
|
||||
net_quota = neutron_quotas.get('network').limit
|
||||
@ -242,7 +234,9 @@ def get_tenant_quota_data(request, disabled_quotas=None, tenant_id=None):
|
||||
|
||||
@profiler.trace
|
||||
def get_disabled_quotas(request):
|
||||
disabled_quotas = set([])
|
||||
# We no longer supports nova network, so we always disable
|
||||
# network related nova quota fields.
|
||||
disabled_quotas = set()
|
||||
|
||||
# Cinder
|
||||
if not cinder.is_volume_service_enabled(request):
|
||||
@ -252,14 +246,7 @@ def get_disabled_quotas(request):
|
||||
if not base.is_service_enabled(request, 'network'):
|
||||
disabled_quotas.update(NEUTRON_QUOTA_FIELDS)
|
||||
else:
|
||||
# Remove the nova network quotas
|
||||
disabled_quotas.update(['floating_ips', 'fixed_ips'])
|
||||
|
||||
if neutron.is_extension_supported(request, 'security-group'):
|
||||
# If Neutron security group is supported, disable Nova quotas
|
||||
disabled_quotas.update(['security_groups', 'security_group_rules'])
|
||||
else:
|
||||
# If Nova security group is used, disable Neutron quotas
|
||||
if not neutron.is_extension_supported(request, 'security-group'):
|
||||
disabled_quotas.update(['security_group', 'security_group_rule'])
|
||||
|
||||
if not neutron.is_router_enabled(request):
|
||||
@ -341,8 +328,7 @@ def _get_tenant_compute_usages(request, usages, disabled_quotas, tenant_id):
|
||||
|
||||
@profiler.trace
|
||||
def _get_tenant_network_usages(request, usages, disabled_quotas, tenant_id):
|
||||
enabled_quotas = ((NOVA_NETWORK_QUOTA_FIELDS | NEUTRON_QUOTA_FIELDS)
|
||||
- disabled_quotas)
|
||||
enabled_quotas = NEUTRON_QUOTA_FIELDS - disabled_quotas
|
||||
if not enabled_quotas:
|
||||
return
|
||||
|
||||
@ -405,9 +391,9 @@ def _get_tenant_volume_usages(request, usages, disabled_quotas, tenant_id):
|
||||
|
||||
|
||||
NETWORK_QUOTA_API_KEY_MAP = {
|
||||
'floating_ips': ['floatingip', 'floating_ips'],
|
||||
'security_groups': ['security_group', 'security_groups'],
|
||||
'security_group_rules': ['security_group_rule', 'security_group_rules'],
|
||||
'floating_ips': ['floatingip'],
|
||||
'security_groups': ['security_group'],
|
||||
'security_group_rules': ['security_group_rule'],
|
||||
# Singular form key is used as quota field in the Neutron API.
|
||||
# We convert it explicitly here.
|
||||
# NOTE(amotoki): It is better to be converted in the horizon API wrapper
|
||||
|
Loading…
Reference in New Issue
Block a user