From 8e5424865386dfce5c01864a63474711caad760b Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Wed, 6 Jan 2016 12:48:28 -0800 Subject: [PATCH] Allow get_unused_ip method to skip v6 and fix iter Skip IPv6 subnets when looking for an unused IP in the floating IP tests since floating IPs cannot be requested with v6 addresses. This also fixes the iterator for the non-allocation pool case. Closes-Bug: #1531706 Change-Id: Id0b2c28970ab61e45755818e3e0798daa4453ce7 --- neutron/tests/api/admin/test_floating_ips_admin_actions.py | 2 +- neutron/tests/api/base.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/neutron/tests/api/admin/test_floating_ips_admin_actions.py b/neutron/tests/api/admin/test_floating_ips_admin_actions.py index e87d46ede54..45bd5c99cda 100644 --- a/neutron/tests/api/admin/test_floating_ips_admin_actions.py +++ b/neutron/tests/api/admin/test_floating_ips_admin_actions.py @@ -140,7 +140,7 @@ class FloatingIPAdminTestJSON(base.BaseAdminNetworkTest): @test.attr(type='smoke') @test.idempotent_id('332a8ae4-402e-4b98-bb6f-532e5a87b8e0') def test_create_floatingip_with_specified_ip_address(self): - fip = self.get_unused_ip(self.ext_net_id) + fip = self.get_unused_ip(self.ext_net_id, ip_version=4) body = self.admin_client.create_floatingip( floating_network_id=self.ext_net_id, floating_ip_address=fip) diff --git a/neutron/tests/api/base.py b/neutron/tests/api/base.py index ecc1044efeb..c9a1d1c1a1a 100644 --- a/neutron/tests/api/base.py +++ b/neutron/tests/api/base.py @@ -544,7 +544,7 @@ class BaseAdminNetworkTest(BaseNetworkTest): return service_profile @classmethod - def get_unused_ip(cls, net_id): + def get_unused_ip(cls, net_id, ip_version=None): """Get an unused ip address in a allocaion pool of net""" body = cls.admin_client.list_ports(network_id=net_id) ports = body['ports'] @@ -556,6 +556,8 @@ class BaseAdminNetworkTest(BaseNetworkTest): subnets = body['subnets'] for subnet in subnets: + if ip_version and subnet['ip_version'] != ip_version: + continue cidr = subnet['cidr'] allocation_pools = subnet['allocation_pools'] iterators = [] @@ -570,7 +572,7 @@ class BaseAdminNetworkTest(BaseNetworkTest): for ip in net: if ip not in (net.network, net.broadcast): yield ip - iterators.append(_iterip) + iterators.append(iter(_iterip())) for iterator in iterators: for ip in iterator: