Adding route/subnet quota with default of 3

RM982
This commit is contained in:
insequent
2014-08-13 15:59:00 +00:00
parent 2d91a8147c
commit 0745e21421
2 changed files with 12 additions and 2 deletions

View File

@@ -39,17 +39,22 @@ CONF = cfg.CONF
quark_resources = [ quark_resources = [
quota.BaseResource('ports_per_network', quota.BaseResource('ports_per_network',
'quota_ports_per_network'), 'quota_ports_per_network'),
quota.BaseResource('routes_per_subnet',
'quota_routes_per_subnet'),
quota.BaseResource('security_rules_per_group', quota.BaseResource('security_rules_per_group',
'quota_security_rules_per_group'), 'quota_security_rules_per_group')
] ]
quark_quota_opts = [ quark_quota_opts = [
cfg.IntOpt('quota_ports_per_network', cfg.IntOpt('quota_ports_per_network',
default=250, default=250,
help=_('Maximum ports per network')), 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', cfg.IntOpt('quota_security_rules_per_group',
default=20, default=20,
help=_('Maximum security group rules in a group')), help=_('Maximum security group rules in a group'))
] ]

View File

@@ -17,6 +17,7 @@ import netaddr
from neutron.common import exceptions from neutron.common import exceptions
from neutron.openstack.common import importutils from neutron.openstack.common import importutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron import quota
from oslo.config import cfg from oslo.config import cfg
from quark.db import api as db_api from quark.db import api as db_api
@@ -58,6 +59,10 @@ def create_route(context, route):
route_cidr = netaddr.IPNetwork(route["cidr"]) route_cidr = netaddr.IPNetwork(route["cidr"])
subnet_routes = db_api.route_find(context, subnet_id=subnet_id, subnet_routes = db_api.route_find(context, subnet_id=subnet_id,
scope=db_api.ALL) 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: for sub_route in subnet_routes:
sub_route_cidr = netaddr.IPNetwork(sub_route["cidr"]) sub_route_cidr = netaddr.IPNetwork(sub_route["cidr"])
if sub_route_cidr.value == DEFAULT_ROUTE.value: if sub_route_cidr.value == DEFAULT_ROUTE.value: