Commit c0c976a2 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Fix IP pool exceptions

parent 151136a9
......@@ -41,7 +41,7 @@ from datetime import datetime
from synnefo.db.models import (Backend, VirtualMachine, Network,
from synnefo.logic import utils, ippool
from synnefo.api.faults import ServiceUnavailable
from synnefo.api.faults import OverLimit
from synnefo.util.rapi import GanetiRapiClient
log = getLogger('synnefo.logic')
......@@ -281,7 +281,8 @@ def create_instance(vm, flavor, image, password, personality):
address = pool.get_free_address()
except ippool.IPPool.IPPoolExhausted:
raise ServiceUnavailable('Network is full')
raise OverLimit("Can not allocate IP for new machine."
" Public network is full.")
nic = {'ip': address, 'network': settings.GANETI_PUBLIC_NETWORK}
......@@ -36,7 +36,7 @@ class IPPool(object):
if not self._contains(address):
raise Exception("%s does not contain %s" % (, address))
raise Exception("%s does not contain %s" % (str(, address))
addr = ipaddr.IPAddress(address)
return int(addr) - int(
......@@ -69,7 +69,7 @@ class IPPool(object):
def get_free_address(self):
if self.is_full():
raise Exception("%s if full",
raise IPPool.IPPoolExhausted("%s if full" % str(
index = self.reservations.index(False)
address = str([index])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment