Revision 34c03a51 snf-cyclades-app/synnefo/api/util.py

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

  

Also available in: Unified diff