Fixed dhcp & gateway ip conflict in PLUMgrid plugin
* Adjust dhcp IP if conflicts with gateway IP * Added unit test case Closes-Bug:1333442 Change-Id: Iaa4e63faf28b783e6b5dbc50035ca50ccde9951a
This commit is contained in:
parent
f1f841d772
commit
fb919c32c9
@ -586,12 +586,17 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
pools = []
|
pools = []
|
||||||
# Auto allocate the pool around gateway_ip
|
# Auto allocate the pool around gateway_ip
|
||||||
net = netaddr.IPNetwork(subnet['cidr'])
|
net = netaddr.IPNetwork(subnet['cidr'])
|
||||||
|
boundary = int(netaddr.IPAddress(subnet['gateway_ip'] or net.last))
|
||||||
|
potential_dhcp_ip = int(net.first + 1)
|
||||||
|
if boundary == potential_dhcp_ip:
|
||||||
|
first_ip = net.first + 3
|
||||||
|
boundary = net.first + 2
|
||||||
|
else:
|
||||||
first_ip = net.first + 2
|
first_ip = net.first + 2
|
||||||
last_ip = net.last - 1
|
last_ip = net.last - 1
|
||||||
gw_ip = int(netaddr.IPAddress(subnet['gateway_ip'] or net.last))
|
|
||||||
# Use the gw_ip to find a point for splitting allocation pools
|
# Use the gw_ip to find a point for splitting allocation pools
|
||||||
# for this subnet
|
# for this subnet
|
||||||
split_ip = min(max(gw_ip, net.first), net.last)
|
split_ip = min(max(boundary, net.first), net.last)
|
||||||
if split_ip > first_ip:
|
if split_ip > first_ip:
|
||||||
pools.append({'start': str(netaddr.IPAddress(first_ip)),
|
pools.append({'start': str(netaddr.IPAddress(first_ip)),
|
||||||
'end': str(netaddr.IPAddress(split_ip - 1))})
|
'end': str(netaddr.IPAddress(split_ip - 1))})
|
||||||
|
@ -127,6 +127,19 @@ class TestPlumgridAllocationPool(PLUMgridPluginV2TestCase):
|
|||||||
pool = plugin._allocate_pools_for_subnet(context, subnet)
|
pool = plugin._allocate_pools_for_subnet(context, subnet)
|
||||||
self.assertEqual(allocation_pool, pool)
|
self.assertEqual(allocation_pool, pool)
|
||||||
|
|
||||||
|
def test_conflict_dhcp_gw_ip(self):
|
||||||
|
cidr = '10.0.0.0/24'
|
||||||
|
gateway_ip = '10.0.0.1'
|
||||||
|
subnet = {'gateway_ip': gateway_ip,
|
||||||
|
'cidr': cidr,
|
||||||
|
'ip_version': 4}
|
||||||
|
allocation_pool = [{"start": '10.0.0.3',
|
||||||
|
"end": '10.0.0.254'}]
|
||||||
|
context = None
|
||||||
|
plugin = manager.NeutronManager.get_plugin()
|
||||||
|
pool = plugin._allocate_pools_for_subnet(context, subnet)
|
||||||
|
self.assertEqual(allocation_pool, pool)
|
||||||
|
|
||||||
|
|
||||||
class TestPlumgridProvidernet(PLUMgridPluginV2TestCase):
|
class TestPlumgridProvidernet(PLUMgridPluginV2TestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user