]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Allow get_unused_ip method to skip v6 and fix iter
authorKevin Benton <blak111@gmail.com>
Wed, 6 Jan 2016 20:48:28 +0000 (12:48 -0800)
committerKevin Benton <blak111@gmail.com>
Wed, 6 Jan 2016 21:27:54 +0000 (13:27 -0800)
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
neutron/tests/api/base.py

index e87d46ede548c4717ca12c65211b8aa62f734944..45bd5c99cda0ad6d692b7b0dc1ac658bb74770a5 100644 (file)
@@ -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)
index ecc1044efeb4e7decf33cbc1f635f0b8cacd7dac..c9a1d1c1a1ac2d07e19cf596fb8fe53eae851b37 100644 (file)
@@ -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: