Revision 94c89c0e

b/ci/ci_wheezy.conf
64 64
# Kamaki version to be used (leave empty for default)
65 65
# In some cases there is the need for a specific version
66 66
# of kamaki to be used.
67
kamaki_version = 0.11next-1858-1d7368b
67
kamaki_version = 0.12rc2
68 68

  
69 69

  
70 70
[Unit Tests]
b/ci/utils.py
16 16

  
17 17
from kamaki.cli import config as kamaki_config
18 18
from kamaki.clients.astakos import AstakosClient
19
from kamaki.clients.cyclades import CycladesClient
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 22
import filelocker
......
92 92
    def format(self, record):
93 93
        format_orig = self._fmt
94 94
        if record.levelno == logging.DEBUG:
95
            self._fmt = "  %(msg)s"
95
            self._fmt = "  %(message)s"
96 96
        elif record.levelno == logging.INFO:
97
            self._fmt = "%(msg)s"
97
            self._fmt = "%(message)s"
98 98
        elif record.levelno == logging.WARNING:
99
            self._fmt = _yellow("[W] %(msg)s")
99
            self._fmt = _yellow("[W] %(message)s")
100 100
        elif record.levelno == logging.ERROR:
101
            self._fmt = _red("[E] %(msg)s")
101
            self._fmt = _red("[E] %(message)s")
102 102
        result = logging.Formatter.format(self, record)
103 103
        self._fmt = format_orig
104 104
        return result
......
173 173
        self.fabric_installed = False
174 174
        self.kamaki_installed = False
175 175
        self.cyclades_client = None
176
        self.network_client = None
176 177
        self.compute_client = None
177 178
        self.image_client = None
178 179
        self.astakos_client = None
......
189 190
                self.kamaki_cloud = config.get("global", "default_cloud")
190 191
            except AttributeError:
191 192
                # Compatibility with kamaki version <=0.10
192
                self.kamaki_cloud = config.get_global("default_cloud")
193
                self.kamaki_cloud = config.get("global", "default_cloud")
193 194

  
194 195
        self.logger.info("Setup kamaki client, using cloud '%s'.." %
195 196
                         self.kamaki_cloud)
......
206 207
        self.cyclades_client = CycladesClient(cyclades_url, token)
207 208
        self.cyclades_client.CONNECTION_RETRY_LIMIT = 2
208 209

  
210
        network_url = \
211
            self.astakos_client.get_service_endpoints('network')['publicURL']
212
        self.logger.debug("Network API url is %s" % _green(network_url))
213
        self.network_client = CycladesNetworkClient(network_url, token)
214
        self.network_client.CONNECTION_RETRY_LIMIT = 2
215

  
209 216
        image_url = \
210 217
            self.astakos_client.get_service_endpoints('image')['publicURL']
211 218
        self.logger.debug("Images API url is %s" % _green(image_url))
......
251 258
        if wait:
252 259
            self._wait_transition(server_id, "ACTIVE", "DELETED")
253 260

  
261
    def _create_floating_ip(self):
262
        """Create a new floating ip"""
263
        networks = self.network_client.list_networks(detail=True)
264
        pub_net = [n for n in networks
265
                   if n['SNF:floating_ip_pool'] and n['public']]
266
        pub_net = pub_net[0]
267
        fip = self.network_client.create_floatingip(pub_net['id'])
268
        self.logger.debug("Floating IP %s with id %s created",
269
                          fip['floating_ip_address'], fip['id'])
270
        return fip
271

  
272
    def _create_port(self, floating_ip):
273
        """Create a new port for our floating IP"""
274
        net_id = floating_ip['floating_network_id']
275
        self.logger.debug("Creating a new port to network with id %s", net_id)
276
        fixed_ips = [{'ip_address': floating_ip['floating_ip_address']}]
277
        port = self.network_client.create_port(
278
            net_id, device_id=None, fixed_ips=fixed_ips)
279
        return port
280

  
254 281
    @_check_kamaki
255 282
    def create_server(self, image=None, flavor=None, ssh_keys=None,
256 283
                      server_name=None):
......
266 293
        flavor_id = self._find_flavor(flavor)
267 294

  
268 295
        # Create Server
296
        fip = self._create_floating_ip()
297
        port = self._create_port(fip)
298
        networks = [{'port': port['id']}]
269 299
        if server_name is None:
270 300
            server_name = self.config.get("Deployment", "server_name")
271 301
            server_name = "%s(BID: %s)" % (server_name, self.build_id)
272
        server = self.cyclades_client.create_server(server_name, flavor_id,
273
                                                    image_id)
302
        server = self.cyclades_client.create_server(
303
            server_name, flavor_id, image_id, networks=networks)
274 304
        server_id = server['id']
275 305
        self.write_temp_config('server_id', server_id)
276 306
        self.logger.debug("Server got id %s" % _green(server_id))

Also available in: Unified diff