Revision ad297723

b/snf-cyclades-app/synnefo/app_settings/default/api.py
42 42
PUBLIC_ROUTED_ROUTING_TABLE = 'snf_public'
43 43
PUBLIC_ROUTED_TAGS = ['ip-less-routed']
44 44

  
45
# Boolean value indicating whether synnefo would hold a Pool and allocate IP
46
# addresses. If this setting is set to False, IP pool management will be
47
# delegated to Ganeti. If machines have been created with this option as False,
48
# you must run network reconciliation after turning it to True.
49
PUBLIC_ROUTED_USE_POOL = True
50

  
45 51
# Settings for PRIVATE_MAC_FILTERED network:
46 52
# ------------------------------------------
47 53
# All networks of this type are bridged to the same bridge. Isolation between
b/snf-cyclades-app/synnefo/logic/backend.py
283 283
        metadata value should be a dictionary.
284 284
    """
285 285

  
286
    # Get the Network object in exclusive mode in order to
287
    # safely (isolated) reserve an IP address
288
    network = Network.objects.select_for_update().get(id=1)
289
    pool = ippool.IPPool(network)
290
    try:
291
        address = pool.get_free_address()
292
    except ippool.IPPool.IPPoolExhausted:
293
        raise OverLimit("Can not allocate IP for new machine."
294
                        " Public network is full.")
295
    pool.save()
296

  
297
    nic = {'ip': address, 'network': settings.GANETI_PUBLIC_NETWORK}
286
    if settings.PUBLIC_ROUTED_USE_POOL:
287
        # Get the Network object in exclusive mode in order to
288
        # safely (isolated) reserve an IP address
289
        network = Network.objects.select_for_update().get(id=1)
290
        pool = ippool.IPPool(network)
291
        try:
292
            address = pool.get_free_address()
293
        except ippool.IPPool.IPPoolExhausted:
294
            raise OverLimit("Can not allocate IP for new machine."
295
                            " Public network is full.")
296
        pool.save()
297
        nic = {'ip': address, 'network': settings.GANETI_PUBLIC_NETWORK}
298
    else:
299
        nic = {'ip': 'pool', 'network': settings.GANETI_PUBLIC_NETWORK}
298 300

  
299 301
    if settings.IGNORE_FLAVOR_DISK_SIZES:
300 302
        if image['backend_id'].find("windows") >= 0:
b/snf-cyclades-app/synnefo/logic/management/commands/reconcile-networks.py
39 39

  
40 40
from optparse import make_option
41 41

  
42
from synnefo.settings import PUBLIC_ROUTED_USE_POOL
42 43
from django.core.management.base import BaseCommand
43 44
from django.db import transaction
44 45

  
......
48 49

  
49 50
class Command(BaseCommand):
50 51
    help = 'Reconcile contents of Synnefo DB with state of Ganeti backend'
52
    can_import_settings = True
51 53
    output_transaction = True  # The management command runs inside
52 54
                               # an SQL transaction
53 55
    option_list = BaseCommand.option_list + (
......
84 86
    for network in networks:
85 87
        net_id = network.id
86 88
        destroying = network.action == 'DESTROY'
89
        uses_pool = not (network.type == 'PUBLIC_ROUTED' and (not
90
                        PUBLIC_ROUTED_USE_POOL))
87 91
        ip_address_maps = []
88 92

  
89 93
        # Perform reconcilliation for each backend
......
153 157
                                        0, 'OP_NETWORK_CONNECT', 'success',
154 158
                                        'Reconciliation simulated event.')
155 159

  
156
            # Reconcile IP Pools
157
            ip_map = ganeti_networks[b][net_id]['map']
158
            ip_address_maps.append(bitarray_from_o1(ip_map))
160
            if uses_pool:
161
                # Reconcile IP Pools
162
                ip_map = ganeti_networks[b][net_id]['map']
163
                ip_address_maps.append(bitarray_from_o1(ip_map))
159 164

  
160
        if ip_address_maps:
165
        if ip_address_maps and uses_pool:
161 166
            network_bitarray = reduce(lambda x, y: x | y, ip_address_maps)
162 167
            if not network.pool.reservations == network_bitarray:
163 168
                out.write('D: Unsynced pool of network %d\n' % net_id)

Also available in: Unified diff