From 3c9b0a5fac2e3a1321eadc272c8ed46aa61efd3e Mon Sep 17 00:00:00 2001 From: elajkat Date: Wed, 30 Oct 2019 13:38:30 +0100 Subject: [PATCH] [fullstack] find ip based on allocation_pool _find_available_ips tried to find available ips based on the given subnet's cidr field, which can be misleading if random selection goes out-of allocation-pool. This patch changes this behaviour to use cidr's allocation_pool field. Closes-Bug: #1850292 Change-Id: Ied2ffb5ed58007789b0f5157731687dc2e0b9bb1 --- neutron/tests/fullstack/base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/neutron/tests/fullstack/base.py b/neutron/tests/fullstack/base.py index f8479b7dd24..457d8ab0f57 100644 --- a/neutron/tests/fullstack/base.py +++ b/neutron/tests/fullstack/base.py @@ -133,7 +133,13 @@ class BaseFullStackTestCase(testlib_api.MySQLTestCaseMixin, [netaddr.IPAddress(ip['ip_address']) for port in ports for ip in port['fixed_ips']]) used_ips.add(netaddr.IPAddress(subnet['gateway_ip'])) - valid_ips = netaddr.IPSet(netaddr.IPNetwork(subnet['cidr'])) + # Note(lajoskatona): Suppose that we have 1 allocation pool for the + # subnet, that should be quite good assumption for testing. + valid_ip_pool = subnet['allocation_pools'][0] + valid_ips = netaddr.IPSet(netaddr.IPRange( + valid_ip_pool['start'], + valid_ip_pool['end']) + ) valid_ips = valid_ips.difference(used_ips) if valid_ips.size < num: self.fail("Cannot find enough free IP addresses.")