Revision 58e7347a ci/utils.py

b/ci/utils.py
19 19
from kamaki.clients.cyclades import CycladesClient, CycladesNetworkClient
20 20
from kamaki.clients.image import ImageClient
21 21
from kamaki.clients.compute import ComputeClient
22
from kamaki.clients import ClientError
22 23
import filelocker
23 24

  
24 25
DEFAULT_CONFIG_FILE = "ci_wheezy.conf"
......
264 265
    def _create_floating_ip(self):
265 266
        """Create a new floating ip"""
266 267
        networks = self.network_client.list_networks(detail=True)
267
        pub_net = [n for n in networks
268
                   if n['SNF:floating_ip_pool'] and n['public']]
269
        pub_net = pub_net[0]
270
        fip = self.network_client.create_floatingip(pub_net['id'])
271
        self.logger.debug("Floating IP %s with id %s created",
272
                          fip['floating_ip_address'], fip['id'])
273
        return fip
268
        pub_nets = [n for n in networks
269
                    if n['SNF:floating_ip_pool'] and n['public']]
270
        for pub_net in pub_nets:
271
            # Try until we find a public network that is not full
272
            try:
273
                fip = self.network_client.create_floatingip(pub_net['id'])
274
            except ClientError as err:
275
                self.logger.warning("%s: %s", err.message, err.details)
276
                continue
277
            self.logger.debug("Floating IP %s with id %s created",
278
                              fip['floating_ip_address'], fip['id'])
279
            return fip
280
        self.logger.error("No mor IP addresses available")
281
        sys.exit(1)
274 282

  
275 283
    def _create_port(self, floating_ip):
276 284
        """Create a new port for our floating IP"""

Also available in: Unified diff