Revision 34c03a51

b/snf-cyclades-app/synnefo/api/util.py
273 273
    for network in backend_public_networks(backend):
274 274
        try:
275 275
            address = get_network_free_address(network)
276
            return (network, address)
277
        except EmptyPool:
276
        except faults.OverLimit:
278 277
            pass
278
        else:
279
            return (network, address)
279 280
    return (None, None)
280 281

  
281 282

  
......
323 324

  
324 325

  
325 326
def get_network_free_address(network):
326
    """Reserve an IP address from the IP Pool of the network.
327

  
328
    Raises EmptyPool
329

  
330
    """
327
    """Reserve an IP address from the IP Pool of the network."""
331 328

  
332 329
    pool = network.get_pool()
333
    address = pool.get()
330
    try:
331
        address = pool.get()
332
    except EmptyPool:
333
        raise faults.OverLimit("Network %s is full." % network.backend_id)
334
        address = None
334 335
    pool.save()
335 336
    return address
336 337

  
b/snf-cyclades-app/synnefo/logic/servers.py
303 303
    address = None
304 304
    if network.dhcp:
305 305
        # Get a free IP from the address pool.
306
        try:
307
            address = util.get_network_free_address(network)
308
        except EmptyPool:
309
            raise faults.OverLimit('Network is full')
306
        address = util.get_network_free_address(network)
310 307

  
311 308
    log.info("Connecting VM %s to Network %s(%s)", vm, network, address)
312 309

  

Also available in: Unified diff