Fix tenant_quota_usages function calls caching
This patch changes type of 'targets' input parameter in tenant_quota_usages function from list -> tuple. It provides possibility for @memoized decorator to cache function calls. Change-Id: I3c32c3b65ae91e8487fda6148f259fe1931d7c9f Closes-Bug: #1700578
This commit is contained in:
parent
9242e4902e
commit
ca0f293cb6
@ -39,7 +39,7 @@ class FloatingIpAllocate(forms.SelfHandlingForm):
|
||||
try:
|
||||
# Prevent allocating more IP than the quota allows
|
||||
usages = quotas.tenant_quota_usages(request,
|
||||
targets=['floating_ips'])
|
||||
targets=('floating_ips', ))
|
||||
if usages['floating_ips']['available'] <= 0:
|
||||
error_message = _('You are already using all of your available'
|
||||
' floating IPs.')
|
||||
|
@ -48,7 +48,7 @@ class AllocateIP(tables.LinkAction):
|
||||
|
||||
def allowed(self, request, fip=None):
|
||||
usages = quotas.tenant_quota_usages(request,
|
||||
targets=['floating_ips'])
|
||||
targets=('floating_ips', ))
|
||||
if usages['floating_ips']['available'] <= 0:
|
||||
if "disabled" not in self.classes:
|
||||
self.classes = [c for c in self.classes] + ['disabled']
|
||||
|
@ -262,7 +262,7 @@ class FloatingIpViewTests(test.TestCase):
|
||||
IsA(http.HttpRequest), detailed=False) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['floating_ips']).MultipleTimes() \
|
||||
IsA(http.HttpRequest), targets=('floating_ips', )).MultipleTimes() \
|
||||
.AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -300,7 +300,7 @@ class FloatingIpViewTests(test.TestCase):
|
||||
IsA(http.HttpRequest), detailed=False) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['floating_ips']).MultipleTimes() \
|
||||
IsA(http.HttpRequest), targets=('floating_ips', )).MultipleTimes() \
|
||||
.AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
@ -62,7 +62,7 @@ class AllocateView(forms.ModalFormView):
|
||||
context = super(AllocateView, self).get_context_data(**kwargs)
|
||||
try:
|
||||
context['usages'] = quotas.tenant_quota_usages(
|
||||
self.request, targets=['floating_ips'])
|
||||
self.request, targets=('floating_ips', ))
|
||||
except Exception:
|
||||
exceptions.handle(self.request)
|
||||
return context
|
||||
|
@ -1997,7 +1997,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
scheduler_hints=scheduler_hints)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.flavors.list())
|
||||
@ -2127,7 +2127,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
scheduler_hints={})
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -2214,7 +2214,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
.AndReturn([])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
|
||||
api.nova.extension_supported('BlockDeviceMappingV2Boot',
|
||||
@ -2320,7 +2320,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
.AndReturn([])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -2436,7 +2436,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
scheduler_hints={})
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -2508,7 +2508,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
|
||||
self._mock_neutron_network_and_port_list()
|
||||
@ -2678,7 +2678,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
.AndRaise(self.exceptions.keystone)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.flavors.list())
|
||||
@ -2764,7 +2764,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
.AndReturn(self.limits['absolute'])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.flavors.list())
|
||||
@ -2853,7 +2853,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
.AndReturn(self.limits['absolute'])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.flavors.list())
|
||||
@ -2950,7 +2950,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
.AndReturn(self.limits['absolute'])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.flavors.list())
|
||||
@ -3096,7 +3096,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
IsA(http.HttpRequest)).AndReturn(self.limits['absolute'])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
api.nova.flavor_list(
|
||||
IsA(http.HttpRequest)).AndReturn(self.flavors.list())
|
||||
@ -3226,7 +3226,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
.AndReturn(self.limits['absolute'])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.flavors.list())
|
||||
@ -3431,7 +3431,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
||||
.AndReturn(self.flavors.list())
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['instances', 'cores', 'ram', 'volumes']) \
|
||||
targets=('instances', 'cores', 'ram', 'volumes', )) \
|
||||
.AndReturn(quota_usages)
|
||||
|
||||
api.nova.server_create(IsA(http.HttpRequest),
|
||||
|
@ -209,7 +209,7 @@ class SetInstanceDetailsAction(workflows.Action):
|
||||
# Prevent launching more instances than the quota allows
|
||||
usages = quotas.tenant_quota_usages(
|
||||
self.request,
|
||||
targets=['instances', 'cores', 'ram', 'volumes'])
|
||||
targets=('instances', 'cores', 'ram', 'volumes', ))
|
||||
available_count = usages['instances']['available']
|
||||
if available_count < count:
|
||||
msg = (_('The requested instance(s) cannot be launched '
|
||||
|
@ -51,7 +51,7 @@ class DeleteKeyPairs(tables.DeleteAction):
|
||||
|
||||
class QuotaKeypairMixin(object):
|
||||
def allowed(self, request, datum=None):
|
||||
usages = quotas.tenant_quota_usages(request, targets=['key_pairs'])
|
||||
usages = quotas.tenant_quota_usages(request, targets=('key_pairs', ))
|
||||
count = len(self.table.data)
|
||||
if (usages.get('key_pairs') and usages['key_pairs']['quota'] <= count):
|
||||
if "disabled" not in self.classes:
|
||||
|
@ -41,7 +41,7 @@ class KeyPairTests(test.TestCase):
|
||||
quota_data = self.quota_usages.first()
|
||||
|
||||
quotas.tenant_quota_usages(IsA(http.HttpRequest),
|
||||
targets=['key_pairs']).MultipleTimes() \
|
||||
targets=('key_pairs', )).MultipleTimes() \
|
||||
.AndReturn(quota_data)
|
||||
api.nova.keypair_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(keypairs)
|
||||
|
@ -198,13 +198,13 @@ class NetworkTopologyCreateTests(test.TestCase):
|
||||
quota_data['instances']['available'] = instances_quota
|
||||
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['instances']
|
||||
IsA(http.HttpRequest), targets=('instances', )
|
||||
).MultipleTimes().AndReturn(quota_data)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['networks']
|
||||
IsA(http.HttpRequest), targets=('networks', )
|
||||
).MultipleTimes().AndReturn(quota_data)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['routers']
|
||||
IsA(http.HttpRequest), targets=('routers', )
|
||||
).MultipleTimes().AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
@ -18,7 +18,7 @@ from openstack_dashboard.usage import quotas
|
||||
|
||||
|
||||
def _quota_exceeded(request, quota):
|
||||
usages = quotas.tenant_quota_usages(request, targets=[quota])
|
||||
usages = quotas.tenant_quota_usages(request, targets=(quota, ))
|
||||
available = usages.get(quota, {}).get('available', 1)
|
||||
return available <= 0
|
||||
|
||||
|
@ -103,7 +103,7 @@ class CreateSubnet(SubnetPolicyTargetMixin, CheckNetworkEditable,
|
||||
return reverse(self.url, args=(network_id,))
|
||||
|
||||
def allowed(self, request, datum=None):
|
||||
usages = quotas.tenant_quota_usages(request, targets=['subnets'])
|
||||
usages = quotas.tenant_quota_usages(request, targets=('subnets', ))
|
||||
|
||||
# when Settings.OPENSTACK_NEUTRON_NETWORK['enable_quotas'] = False
|
||||
# usages["subnets'] is empty
|
||||
|
@ -92,7 +92,7 @@ class CreateNetwork(tables.LinkAction):
|
||||
policy_rules = (("network", "create_network"),)
|
||||
|
||||
def allowed(self, request, datum=None):
|
||||
usages = quotas.tenant_quota_usages(request, targets=['networks'])
|
||||
usages = quotas.tenant_quota_usages(request, targets=('networks', ))
|
||||
# when Settings.OPENSTACK_NEUTRON_NETWORK['enable_quotas'] = False
|
||||
# usages["networks"] is empty
|
||||
if usages.get('networks', {}).get('available', 1) <= 0:
|
||||
@ -129,7 +129,7 @@ class CreateSubnet(policy.PolicyTargetMixin, CheckNetworkEditable,
|
||||
("network:project_id", "tenant_id"),)
|
||||
|
||||
def allowed(self, request, datum=None):
|
||||
usages = quotas.tenant_quota_usages(request, targets=['subnets'])
|
||||
usages = quotas.tenant_quota_usages(request, targets=('subnets', ))
|
||||
# when Settings.OPENSTACK_NEUTRON_NETWORK['enable_quotas'] = False
|
||||
# usages["subnets'] is empty
|
||||
if usages.get('subnets', {}).get('available', 1) <= 0:
|
||||
|
@ -132,10 +132,10 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
quota_data['subnets']['available'] = 5
|
||||
self._stub_net_list()
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['networks']) \
|
||||
IsA(http.HttpRequest), targets=('networks', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['subnets']) \
|
||||
IsA(http.HttpRequest), targets=('subnets', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -154,7 +154,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
tenant_id=self.tenant.id,
|
||||
shared=False).MultipleTimes().AndRaise(self.exceptions.neutron)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['networks']) \
|
||||
IsA(http.HttpRequest), targets=('networks', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -193,7 +193,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
.AndReturn(mac_learning)
|
||||
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['subnets']) \
|
||||
IsA(http.HttpRequest), targets=('subnets', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -220,7 +220,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
'mac-learning')\
|
||||
.AndReturn(mac_learning)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['subnets']) \
|
||||
IsA(http.HttpRequest), targets=('subnets', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -291,7 +291,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
'mac-learning')\
|
||||
.AndReturn(mac_learning)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['subnets']) \
|
||||
IsA(http.HttpRequest), targets=('subnets', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -333,7 +333,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
|
||||
'mac-learning')\
|
||||
.AndReturn(mac_learning)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['subnets']) \
|
||||
IsA(http.HttpRequest), targets=('subnets', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -995,10 +995,10 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
|
||||
|
||||
self._stub_net_list()
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['networks']) \
|
||||
IsA(http.HttpRequest), targets=('networks', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['subnets']) \
|
||||
IsA(http.HttpRequest), targets=('subnets', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -1024,10 +1024,10 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
|
||||
|
||||
self._stub_net_list()
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['networks']) \
|
||||
IsA(http.HttpRequest), targets=('networks', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['subnets']) \
|
||||
IsA(http.HttpRequest), targets=('subnets', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -1105,7 +1105,7 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
|
||||
IsA(http.HttpRequest), 'mac-learning')\
|
||||
.AndReturn(False)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['subnets']) \
|
||||
IsA(http.HttpRequest), targets=('subnets', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
@ -96,7 +96,7 @@ class CreateRouter(tables.LinkAction):
|
||||
policy_rules = (("network", "create_router"),)
|
||||
|
||||
def allowed(self, request, datum=None):
|
||||
usages = quotas.tenant_quota_usages(request, targets=['routers'])
|
||||
usages = quotas.tenant_quota_usages(request, targets=('routers', ))
|
||||
# when Settings.OPENSTACK_NEUTRON_NETWORK['enable_quotas'] = False
|
||||
# usages['routers'] is empty
|
||||
if usages.get('routers', {}).get('available', 1) <= 0:
|
||||
|
@ -93,7 +93,7 @@ class RouterTests(RouterMixin, test.TestCase):
|
||||
IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id).AndReturn(self.routers.list())
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['routers']) \
|
||||
IsA(http.HttpRequest), targets=('routers', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
self._mock_external_network_list()
|
||||
self.mox.ReplayAll()
|
||||
@ -113,7 +113,7 @@ class RouterTests(RouterMixin, test.TestCase):
|
||||
tenant_id=self.tenant.id).MultipleTimes().AndRaise(
|
||||
self.exceptions.neutron)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['routers']) \
|
||||
IsA(http.HttpRequest), targets=('routers', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
self._mock_external_network_list()
|
||||
self.mox.ReplayAll()
|
||||
@ -133,7 +133,7 @@ class RouterTests(RouterMixin, test.TestCase):
|
||||
IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id).MultipleTimes().AndReturn([router])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['routers']) \
|
||||
IsA(http.HttpRequest), targets=('routers', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
self._mock_external_network_list(alter_ids=True)
|
||||
self.mox.ReplayAll()
|
||||
@ -177,7 +177,7 @@ class RouterTests(RouterMixin, test.TestCase):
|
||||
IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id).AndReturn(self.routers.list())
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['routers']) \
|
||||
IsA(http.HttpRequest), targets=('routers', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
self._mock_external_network_list()
|
||||
api.neutron.router_list(
|
||||
@ -215,7 +215,7 @@ class RouterTests(RouterMixin, test.TestCase):
|
||||
IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id).AndReturn(self.routers.list())
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['routers']) \
|
||||
IsA(http.HttpRequest), targets=('routers', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
self._mock_external_network_list()
|
||||
api.neutron.router_list(
|
||||
@ -801,7 +801,7 @@ class RouterViewTests(RouterMixin, test.TestCase):
|
||||
IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id).AndReturn(self.routers.list())
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['routers']) \
|
||||
IsA(http.HttpRequest), targets=('routers', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
|
||||
self._mock_external_network_list()
|
||||
@ -828,7 +828,7 @@ class RouterViewTests(RouterMixin, test.TestCase):
|
||||
IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id).AndReturn(self.routers.list())
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['routers']) \
|
||||
IsA(http.HttpRequest), targets=('routers', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
|
||||
self._mock_external_network_list()
|
||||
@ -855,7 +855,7 @@ class RouterViewTests(RouterMixin, test.TestCase):
|
||||
IsA(http.HttpRequest),
|
||||
tenant_id=self.tenant.id).AndReturn(self.routers.list())
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest), targets=['routers']) \
|
||||
IsA(http.HttpRequest), targets=('routers', )) \
|
||||
.MultipleTimes().AndReturn(quota_data)
|
||||
|
||||
self._mock_external_network_list()
|
||||
|
@ -64,7 +64,7 @@ class CreateGroup(tables.LinkAction):
|
||||
|
||||
def allowed(self, request, security_group=None):
|
||||
usages = quotas.tenant_quota_usages(request,
|
||||
targets=['security_groups'])
|
||||
targets=('security_groups', ))
|
||||
if usages['security_groups'].get('available', 1) <= 0:
|
||||
if "disabled" not in self.classes:
|
||||
self.classes = [c for c in self.classes] + ["disabled"]
|
||||
|
@ -76,7 +76,7 @@ class SecurityGroupsViewTests(test.TestCase):
|
||||
.AndReturn(sec_groups)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['security_groups']).MultipleTimes() \
|
||||
targets=('security_groups', )).MultipleTimes() \
|
||||
.AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -110,7 +110,7 @@ class SecurityGroupsViewTests(test.TestCase):
|
||||
.AndReturn(sec_groups)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['security_groups']).MultipleTimes() \
|
||||
targets=('security_groups', )).MultipleTimes() \
|
||||
.AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
@ -144,7 +144,7 @@ class SecurityGroupsViewTests(test.TestCase):
|
||||
.AndReturn(sec_groups)
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest),
|
||||
targets=['security_groups']).MultipleTimes() \
|
||||
targets=('security_groups', )).MultipleTimes() \
|
||||
.AndReturn(quota_data)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
@ -414,19 +414,20 @@ class QuotaTests(test.APITestCase):
|
||||
self.assertEqual(expected, disabled_quotas)
|
||||
|
||||
def test_tenant_quota_usages_with_target_instances(self):
|
||||
self._test_tenant_quota_usages_with_target(targets=['instances'])
|
||||
self._test_tenant_quota_usages_with_target(targets=('instances', ))
|
||||
|
||||
def test_tenant_quota_usages_with_target_ram(self):
|
||||
self._test_tenant_quota_usages_with_target(
|
||||
targets=['ram'], use_flavor_list=True)
|
||||
targets=('ram', ), use_flavor_list=True)
|
||||
|
||||
def test_tenant_quota_usages_with_target_volume(self):
|
||||
self._test_tenant_quota_usages_with_target(
|
||||
targets=['volumes'], use_compute_call=False, use_cinder_call=True)
|
||||
targets=('volumes', ), use_compute_call=False,
|
||||
use_cinder_call=True)
|
||||
|
||||
def test_tenant_quota_usages_with_target_compute_volume(self):
|
||||
self._test_tenant_quota_usages_with_target(
|
||||
targets=['instances', 'cores', 'ram', 'volumes'],
|
||||
targets=('instances', 'cores', 'ram', 'volumes', ),
|
||||
use_flavor_list=True, use_cinder_call=True)
|
||||
|
||||
@test.create_stubs({api.nova: ('server_list',
|
||||
@ -484,15 +485,15 @@ class QuotaTests(test.APITestCase):
|
||||
|
||||
def test_tenant_quota_usages_neutron_with_target_network_resources(self):
|
||||
self._test_tenant_quota_usages_neutron_with_target(
|
||||
targets=['networks', 'subnets', 'routers'])
|
||||
targets=('networks', 'subnets', 'routers', ))
|
||||
|
||||
def test_tenant_quota_usages_neutron_with_target_security_groups(self):
|
||||
self._test_tenant_quota_usages_neutron_with_target(
|
||||
targets=['security_groups'])
|
||||
targets=('security_groups', ))
|
||||
|
||||
def test_tenant_quota_usages_neutron_with_target_floating_ips(self):
|
||||
self._test_tenant_quota_usages_neutron_with_target(
|
||||
targets=['floating_ips'])
|
||||
targets=('floating_ips', ))
|
||||
|
||||
@test.create_stubs({api.base: ('is_service_enabled',),
|
||||
api.neutron: ('floating_ip_supported',
|
||||
|
@ -444,7 +444,7 @@ def tenant_quota_usages(request, tenant_id=None, targets=None):
|
||||
|
||||
:param tenant_id: Target tenant ID. If no tenant_id is provided,
|
||||
a the request.user.project_id is assumed to be used.
|
||||
:param targets: A list of quota names to be retrieved.
|
||||
:param targets: A tuple of quota names to be retrieved.
|
||||
If unspecified, all quota and usage information is retrieved.
|
||||
"""
|
||||
if not tenant_id:
|
||||
|
Loading…
x
Reference in New Issue
Block a user