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

cyclades: Fix bugs in IP pools

Fix default value for 'external' argument of release_address method of
Network model. Also fix how is checked whether an IP pool contains an
address.
parent b6ca43a3
......@@ -547,10 +547,10 @@ class Network(models.Model):
raise pools.InvalidValue("Network %s does not have an IP pool that"
" contains address %s" % (self, address))
def release_address(self, address, external=True):
def release_address(self, address, external=False):
for ip_pool in self.get_ip_pools():
if ip_pool.contains(address):
ip_pool.release(address, external=external)
ip_pool.put(address, external=external)
ip_pool.save()
return
raise pools.InvalidValue("Network %s does not have an IP pool that"
......
......@@ -287,9 +287,12 @@ class IPPool(PoolManager):
def index_to_value(self, index):
return str(self.net[index + int(self.offset)])
def contains(self, address):
addr = ipaddr.IPAddress(address)
return addr in self.net and super(IPPool, self).contains(address)
def contains(self, address, index=False):
if index is False:
addr = ipaddr.IPAddress(address)
if addr not in self.net:
return False
return super(IPPool, self).contains(address, index=False)
def return_start(self):
return str(ipaddr.IPAddress(self.base) + self.offset)
......
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