Commit dda1563d authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis Committed by Christos Stavrakakis

snf-ci: Search all public networks

When creating a new floating IP try all public networks
until we find one that is not full.
parent bac3a50d
......@@ -19,6 +19,7 @@ from kamaki.clients.astakos import AstakosClient, parse_endpoints
from kamaki.clients.cyclades import CycladesClient, CycladesNetworkClient
from kamaki.clients.image import ImageClient
from kamaki.clients.compute import ComputeClient
from kamaki.clients import ClientError
import filelocker
DEFAULT_CONFIG_FILE = "ci_wheezy.conf"
......@@ -270,13 +271,20 @@ class SynnefoCI(object):
def _create_floating_ip(self):
"""Create a new floating ip"""
networks = self.network_client.list_networks(detail=True)
pub_net = [n for n in networks
if n['SNF:floating_ip_pool'] and n['public']]
pub_net = pub_net[0]
fip = self.network_client.create_floatingip(pub_net['id'])
self.logger.debug("Floating IP %s with id %s created",
fip['floating_ip_address'], fip['id'])
return fip
pub_nets = [n for n in networks
if n['SNF:floating_ip_pool'] and n['public']]
for pub_net in pub_nets:
# Try until we find a public network that is not full
try:
fip = self.network_client.create_floatingip(pub_net['id'])
except ClientError as err:
self.logger.warning("%s: %s", err.message, err.details)
continue
self.logger.debug("Floating IP %s with id %s created",
fip['floating_ip_address'], fip['id'])
return fip
self.logger.error("No mor IP addresses available")
sys.exit(1)
def _create_port(self, floating_ip):
"""Create a new port for our floating IP"""
......
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