Commit 3dab7faa authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Fix handling of old IP pools

Before implementing the Neutron API, each network had one IP pool that
contained the whole subnet CIDR. This changed since now we have multiple
IP Pools(with base and offset attributes) per network and this IP pools
do not contain the network, broadcast and gateway addreeses. This commit
fixes an old migration to add 'base' and 'offset' attribute to all IP
pool objects, and adds an extra step to old and not-initialized pools in
order to externally reserve those addresses.
parent 0c3b3480
......@@ -19,6 +19,8 @@ class Migration(DataMigration):
ip_pool = network.pool
ip_pool.subnet = subnet
ip_pool.base = subnet.cidr
ip_pool.offset = 0
if network.subnet6:
......@@ -279,15 +279,31 @@ class IPPool(PoolManager):
def __init__(self, pool_table):
subnet = pool_table.subnet = ipaddr.IPNetwork(subnet.cidr)
if pool_table.base is None:
self.base = pool_table.subnet.cidr
self.base = pool_table.base
if pool_table.offset is None:
self.offset = 0
if pool_table.available_map:
initialized_pool = True
self.offset = pool_table.offset
initialized_pool = False
super(IPPool, self).__init__(pool_table)
if not initialized_pool:
def check_pool_integtiry(self):
"""Check the integrity of the IP pool
This check is required only for old IP pools(one IP pool per network
that contained the whole subnet cidr) that had not been initialized
before the migration. This checks that the network, gateway and
broadcast IP addresses are externally reserved, and if not reserves
subnet = self.pool_table.subnet
check_ips = [str(, str(]
if subnet.gateway is not None:
for ip in check_ips:
if self.contains(ip):
self.reserve(ip, external=True)
def value_to_index(self, value):
addr = ipaddr.IPAddress(value)
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