Commit 1503f436 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis
Browse files

PUBLIC_ROUTED minor changes



Do not allow api to create public networks and type other
than PRIVATE_MAC_FILTERED/PRIVATE_PHYSICAL_VLAN.

Rename PUBLIC_ROUTED_USE_POOL setting to PUBLIC_USE_POOL.

Let synnefo do IP pool management only if network is private or
PUBLIC_USE_POOL is True.
Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
parent 7a20b494
......@@ -166,13 +166,17 @@ def create_network(request):
gateway = d.get('gateway', None)
gateway6 = d.get('gateway6', None)
net_type = d.get('type', 'PRIVATE_MAC_FILTERED')
public = d.get('public', False)
dhcp = d.get('dhcp', True)
except (KeyError, ValueError):
raise BadRequest('Malformed request.')
if net_type == 'PUBLIC_ROUTED':
if public:
raise Unauthorized('Can not create a public network.')
if net_type not in ('PRIVATE_MAC_FILTERED', 'PRIVATE_PHYSICAL_VLAN'):
raise Unauthorized('Can not create a network of type %s.' % net_type)
user_networks = len(Network.objects.filter(userid=request.user_uniq,
deleted=False))
......
......@@ -269,7 +269,7 @@ def create_server(request):
transaction.commit()
try:
if settings.PUBLIC_ROUTED_USE_POOL:
if settings.PUBLIC_USE_POOL:
(network, address) = util.allocate_public_address(backend)
if address is None:
log.error("Public networks of backend %s are full", backend)
......
......@@ -47,7 +47,7 @@ PUBLIC_ROUTED_TAGS = ['ip-less-routed']
# addresses. If this setting is set to False, IP pool management will be
# delegated to Ganeti. If machines have been created with this option as False,
# you must run network reconciliation after turning it to True.
PUBLIC_ROUTED_USE_POOL = True
PUBLIC_USE_POOL = True
# Settings for PRIVATE_MAC_FILTERED network:
# ------------------------------------------
......
......@@ -39,7 +39,7 @@ import bitarray
from optparse import make_option
from synnefo.settings import PUBLIC_ROUTED_USE_POOL
from synnefo.settings import PUBLIC_USE_POOL
from django.core.management.base import BaseCommand
from django.db import transaction
......@@ -87,8 +87,7 @@ def reconcile_networks(out, fix, conflicting_ips):
for network in networks:
net_id = network.id
destroying = network.action == 'DESTROY'
uses_pool = not (network.type == 'PUBLIC_ROUTED' and (not
PUBLIC_ROUTED_USE_POOL))
uses_pool = not network.public or PUBLIC_USE_POOL
ip_available_maps = []
ip_reserved_maps = []
......
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