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
This commit is contained in:
parent
3bcc1c3d4c
commit
8e54248653
|
@ -140,7 +140,7 @@ class FloatingIPAdminTestJSON(base.BaseAdminNetworkTest):
|
||||||
@test.attr(type='smoke')
|
@test.attr(type='smoke')
|
||||||
@test.idempotent_id('332a8ae4-402e-4b98-bb6f-532e5a87b8e0')
|
@test.idempotent_id('332a8ae4-402e-4b98-bb6f-532e5a87b8e0')
|
||||||
def test_create_floatingip_with_specified_ip_address(self):
|
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(
|
body = self.admin_client.create_floatingip(
|
||||||
floating_network_id=self.ext_net_id,
|
floating_network_id=self.ext_net_id,
|
||||||
floating_ip_address=fip)
|
floating_ip_address=fip)
|
||||||
|
|
|
@ -544,7 +544,7 @@ class BaseAdminNetworkTest(BaseNetworkTest):
|
||||||
return service_profile
|
return service_profile
|
||||||
|
|
||||||
@classmethod
|
@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"""
|
"""Get an unused ip address in a allocaion pool of net"""
|
||||||
body = cls.admin_client.list_ports(network_id=net_id)
|
body = cls.admin_client.list_ports(network_id=net_id)
|
||||||
ports = body['ports']
|
ports = body['ports']
|
||||||
|
@ -556,6 +556,8 @@ class BaseAdminNetworkTest(BaseNetworkTest):
|
||||||
subnets = body['subnets']
|
subnets = body['subnets']
|
||||||
|
|
||||||
for subnet in subnets:
|
for subnet in subnets:
|
||||||
|
if ip_version and subnet['ip_version'] != ip_version:
|
||||||
|
continue
|
||||||
cidr = subnet['cidr']
|
cidr = subnet['cidr']
|
||||||
allocation_pools = subnet['allocation_pools']
|
allocation_pools = subnet['allocation_pools']
|
||||||
iterators = []
|
iterators = []
|
||||||
|
@ -570,7 +572,7 @@ class BaseAdminNetworkTest(BaseNetworkTest):
|
||||||
for ip in net:
|
for ip in net:
|
||||||
if ip not in (net.network, net.broadcast):
|
if ip not in (net.network, net.broadcast):
|
||||||
yield ip
|
yield ip
|
||||||
iterators.append(_iterip)
|
iterators.append(iter(_iterip()))
|
||||||
|
|
||||||
for iterator in iterators:
|
for iterator in iterators:
|
||||||
for ip in iterator:
|
for ip in iterator:
|
||||||
|
|
Loading…
Reference in New Issue