Adding route/subnet quota with default of 3
RM982
This commit is contained in:
@@ -39,17 +39,22 @@ CONF = cfg.CONF
|
||||
quark_resources = [
|
||||
quota.BaseResource('ports_per_network',
|
||||
'quota_ports_per_network'),
|
||||
quota.BaseResource('routes_per_subnet',
|
||||
'quota_routes_per_subnet'),
|
||||
quota.BaseResource('security_rules_per_group',
|
||||
'quota_security_rules_per_group'),
|
||||
'quota_security_rules_per_group')
|
||||
]
|
||||
|
||||
quark_quota_opts = [
|
||||
cfg.IntOpt('quota_ports_per_network',
|
||||
default=250,
|
||||
help=_('Maximum ports per network')),
|
||||
cfg.IntOpt('quota_routes_per_subnet',
|
||||
default=3,
|
||||
help=_('Maximum routes per subnet')),
|
||||
cfg.IntOpt('quota_security_rules_per_group',
|
||||
default=20,
|
||||
help=_('Maximum security group rules in a group')),
|
||||
help=_('Maximum security group rules in a group'))
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import netaddr
|
||||
from neutron.common import exceptions
|
||||
from neutron.openstack.common import importutils
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron import quota
|
||||
from oslo.config import cfg
|
||||
|
||||
from quark.db import api as db_api
|
||||
@@ -58,6 +59,10 @@ def create_route(context, route):
|
||||
route_cidr = netaddr.IPNetwork(route["cidr"])
|
||||
subnet_routes = db_api.route_find(context, subnet_id=subnet_id,
|
||||
scope=db_api.ALL)
|
||||
|
||||
quota.QUOTAS.limit_check(context, context.tenant_id,
|
||||
routes_per_subnet=len(subnet_routes) + 1)
|
||||
|
||||
for sub_route in subnet_routes:
|
||||
sub_route_cidr = netaddr.IPNetwork(sub_route["cidr"])
|
||||
if sub_route_cidr.value == DEFAULT_ROUTE.value:
|
||||
|
||||
Reference in New Issue
Block a user