Commit 8b71128b authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

burnin: Search all public networks

Previously burnin tried to create a floatingIP from the first public
network found. But this public network may be full.
This patch fixes '_create_floating_ip' so it will try all public
networks until it succeeds.
parent 178882b1
......@@ -452,34 +452,45 @@ class CycladesTests(BurninTests):
# Verify quotas
self._check_quotas(network=-len(networks))
def _get_public_network(self, networks=None):
"""Get the public network"""
def _get_public_networks(self, networks=None):
"""Get the public networks"""
if networks is None:
networks = self._get_list_of_networks(detail=True)
self.info("Getting the public network")
self.info("Getting the public networks")
public_networks = []
for net in networks:
if net['SNF:floating_ip_pool'] and net['public']:
return net
self.fail("Could not find a public network to use")
public_networks.append(net)
self.assertNotEqual(public_networks, [],
"Could not find a public network to use")
return public_networks
def _create_floating_ip(self):
"""Create a new floating ip"""
pub_net = self._get_public_network()
self.info("Creating a new floating ip for network with id %s",
pub_net['id'])
fip = self.clients.network.create_floatingip(pub_net['id'])
# Verify that floating ip has been created
fips = self.clients.network.list_floatingips()
fips = [f['id'] for f in fips]
self.assertIn(fip['id'], fips)
# Verify quotas
self._check_quotas(ip=+1)
# Check that IP is IPv4
self.assertEquals(IPy.IP(fip['floating_ip_address']).version(), 4)
pub_nets = self._get_public_networks()
for pub_net in pub_nets:
self.info("Creating a new floating ip for network with id %s",
pub_net['id'])
try:
fip = self.clients.network.create_floatingip(pub_net['id'])
except ClientError as err:
self.warning("%s: %s", err.message, err.details)
continue
# Verify that floating ip has been created
fips = self.clients.network.list_floatingips()
fips = [f['id'] for f in fips]
self.assertIn(fip['id'], fips)
# Verify quotas
self._check_quotas(ip=+1)
# Check that IP is IPv4
self.assertEquals(IPy.IP(fip['floating_ip_address']).version(), 4)
self.info("Floating IP %s with id %s created",
fip['floating_ip_address'], fip['id'])
return fip
self.info("Floating IP %s with id %s created",
fip['floating_ip_address'], fip['id'])
return fip
self.fail("No more IP addresses available")
def _create_port(self, network_id, device_id=None, floating_ip=None):
"""Create a new port attached to the a specific network"""
......@@ -540,8 +551,10 @@ class CycladesTests(BurninTests):
def _disconnect_from_network(self, server, network=None):
"""Disconnnect server from network"""
if network is None:
# Disconnect from public network
network = self._get_public_network()
# Disconnect from all public networks
for net in self._get_public_networks():
self._disconnect_from_network(server, network=net)
return
lports = self.clients.network.list_ports()
ports = []
......@@ -569,6 +582,8 @@ class CycladesTests(BurninTests):
"""Delete floating ips"""
# Renew the list of floating IP objects
# (It may have been changed, i.e. a port may have been deleted).
if not fips:
return
fip_ids = [f['id'] for f in fips]
new_fips = [f for f in self.clients.network.list_floatingips()
if f['id'] in fip_ids]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment