Revision 49fb00cc 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"
......
270 271
    def _create_floating_ip(self):
271 272
        """Create a new floating ip"""
272 273
        networks = self.network_client.list_networks(detail=True)
273
        pub_net = [n for n in networks
274
                   if n['SNF:floating_ip_pool'] and n['public']]
275
        pub_net = pub_net[0]
276
        fip = self.network_client.create_floatingip(pub_net['id'])
277
        self.logger.debug("Floating IP %s with id %s created",
278
                          fip['floating_ip_address'], fip['id'])
279
        return fip
274
        pub_nets = [n for n in networks
275
                    if n['SNF:floating_ip_pool'] and n['public']]
276
        for pub_net in pub_nets:
277
            # Try until we find a public network that is not full
278
            try:
279
                fip = self.network_client.create_floatingip(pub_net['id'])
280
            except ClientError as err:
281
                self.logger.warning("%s: %s", err.message, err.details)
282
                continue
283
            self.logger.debug("Floating IP %s with id %s created",
284
                              fip['floating_ip_address'], fip['id'])
285
            return fip
286
        self.logger.error("No mor IP addresses available")
287
        sys.exit(1)
280 288

  
281 289
    def _create_port(self, floating_ip):
282 290
        """Create a new port for our floating IP"""

Also available in: Unified diff