Revision ad297723 snf-cyclades-app/synnefo/logic/backend.py

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:

Also available in: Unified diff