@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)
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']
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 = []
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: