Commit 285ce552 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Limit allowed network size

Limit the size of networks that users can create, since big IP
pools can have negative impact on performance. Allowed network
size is controled by 'MAX_CIDR_BLOCK' setting.
parent 6a489825
......@@ -44,9 +44,10 @@ from synnefo.api import util
from synnefo.api.actions import network_actions
from synnefo.api.common import method_not_allowed
from synnefo.api.faults import (BadRequest, Unauthorized,
NetworkInUse, OverLimit)
from synnefo.db.models import Network
from synnefo.logic import backend
from synnefo.settings import MAX_CIDR_BLOCK
log = getLogger('synnefo.api')
......@@ -168,6 +169,10 @@ def create_network(request):
if type == 'PUBLIC_ROUTED':
raise Unauthorized('Can not create a public network.')
cidr_block = int(subnet.split('/')[1])
if cidr_block <= MAX_CIDR_BLOCK:
raise OverLimit("Network size is to big. Please specify a network"
" smaller than /" + str(MAX_CIDR_BLOCK) + '.')
link, mac_prefix = util.network_specs_from_type(type)
if not link:
......@@ -21,6 +21,8 @@ POLL_LIMIT = 3600
# Network Configuration
# Maximum allowed network size for private networks.
# Name of the network in Ganeti corresponding to the default public network.
# All created VMs will obtain an IP from this network.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment