Revision 8a4a931d
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
41 | 41 |
from synnefo.db.models import (Backend, VirtualMachine, Network, |
42 | 42 |
BackendNetwork, BACKEND_STATUSES) |
43 | 43 |
from synnefo.logic import utils, ippool |
44 |
from synnefo.api.faults import ServiceUnavailable
|
|
44 |
from synnefo.api.faults import OverLimit
|
|
45 | 45 |
from synnefo.util.rapi import GanetiRapiClient |
46 | 46 |
|
47 | 47 |
log = getLogger('synnefo.logic') |
... | ... | |
281 | 281 |
try: |
282 | 282 |
address = pool.get_free_address() |
283 | 283 |
except ippool.IPPool.IPPoolExhausted: |
284 |
raise ServiceUnavailable('Network is full') |
|
284 |
raise OverLimit("Can not allocate IP for new machine." |
|
285 |
" Public network is full.") |
|
285 | 286 |
pool.save() |
286 | 287 |
|
287 | 288 |
nic = {'ip': address, 'network': settings.GANETI_PUBLIC_NETWORK} |
b/snf-cyclades-app/synnefo/logic/ippool.py | ||
---|---|---|
36 | 36 |
|
37 | 37 |
""" |
38 | 38 |
if not self._contains(address): |
39 |
raise Exception("%s does not contain %s" % (self.network, address))
|
|
39 |
raise Exception("%s does not contain %s" % (str(self.network), address))
|
|
40 | 40 |
addr = ipaddr.IPAddress(address) |
41 | 41 |
|
42 | 42 |
return int(addr) - int(self.network.network) |
... | ... | |
69 | 69 |
|
70 | 70 |
def get_free_address(self): |
71 | 71 |
if self.is_full(): |
72 |
raise Exception("%s if full", self.network)
|
|
72 |
raise IPPool.IPPoolExhausted("%s if full" % str(self.network))
|
|
73 | 73 |
|
74 | 74 |
index = self.reservations.index(False) |
75 | 75 |
address = str(self.network[index]) |
Also available in: Unified diff