Revision ac1e7de3 ci/utils.py

b/ci/utils.py
26 26
DEFAULT_SYSTEM_IMAGES_UUID = [
27 27
    "25ecced9-bf53-4145-91ee-cf47377e9fb2",  # production (okeanos.grnet.gr)
28 28
    "04cbe33f-29b7-4ef1-94fb-015929e5fc06",  # testing (okeanos.io)
29
    ]
29
]
30 30

  
31 31

  
32 32
def _run(cmd, verbose):
......
190 190
        token = config.get_cloud(self.kamaki_cloud, "token")
191 191
        #self.logger.debug("Token is %s" % _green(token))
192 192

  
193
        astakos_client = AstakosClient(auth_url, token)
193
        self.astakos_client = AstakosClient(auth_url, token)
194 194

  
195 195
        cyclades_url = \
196
            astakos_client.get_service_endpoints('compute')['publicURL']
196
            self.astakos_client.get_service_endpoints('compute')['publicURL']
197 197
        self.logger.debug("Cyclades API url is %s" % _green(cyclades_url))
198 198
        self.cyclades_client = CycladesClient(cyclades_url, token)
199 199
        self.cyclades_client.CONNECTION_RETRY_LIMIT = 2
200 200

  
201 201
        image_url = \
202
            astakos_client.get_service_endpoints('image')['publicURL']
202
            self.astakos_client.get_service_endpoints('image')['publicURL']
203 203
        self.logger.debug("Images API url is %s" % _green(image_url))
204 204
        self.image_client = ImageClient(cyclades_url, token)
205 205
        self.image_client.CONNECTION_RETRY_LIMIT = 2
206 206

  
207 207
        compute_url = \
208
            astakos_client.get_service_endpoints('compute')['publicURL']
208
            self.astakos_client.get_service_endpoints('compute')['publicURL']
209 209
        self.logger.debug("Compute API url is %s" % _green(compute_url))
210 210
        self.compute_client = ComputeClient(compute_url, token)
211 211
        self.compute_client.CONNECTION_RETRY_LIMIT = 2
......
332 332

  
333 333
        list_flavors = self.compute_client.list_flavors()
334 334
        for flv in flavors:
335
            flv_type, flv_value = parse_typed_option(option="flavor", value=flv)
335
            flv_type, flv_value = parse_typed_option(option="flavor",
336
                                                     value=flv)
336 337
            if flv_type == "name":
337 338
                # Filter flavors by name
338 339
                self.logger.debug(
339 340
                    "Trying to find a flavor with name \"%s\"" % flv_value)
340 341
                list_flvs = \
341 342
                    [f for f in list_flavors
342
                     if re.search(flv_value, f['name'], flags=re.I) is not None]
343
                     if re.search(flv_value, f['name'], flags=re.I)
344
                     is not None]
343 345
            elif flv_type == "id":
344 346
                # Filter flavors by id
345 347
                self.logger.debug(
......
372 374
            # If we have an image from command line, add it to our list
373 375
            images.insert(0, image)
374 376

  
377
        auth = self.astakos_client.authenticate()
378
        user_uuid = auth["access"]["token"]["tenant"]["id"]
375 379
        list_images = self.image_client.list_public(detail=True)['images']
376 380
        for img in images:
377 381
            img_type, img_value = parse_typed_option(option="image", value=img)
......
379 383
                # Filter images by name
380 384
                self.logger.debug(
381 385
                    "Trying to find an image with name \"%s\"" % img_value)
386
                accepted_uuids = DEFAULT_SYSTEM_IMAGES_UUID + [user_uuid]
382 387
                list_imgs = \
383
                    [i for i in list_images
384
                     if i['user_id'] in DEFAULT_SYSTEM_IMAGES_UUID and
385
                        re.search(img_value, i['name'], flags=re.I) is not None]
388
                    [i for i in list_images if i['user_id'] in accepted_uuids
389
                     and
390
                     re.search(img_value, i['name'], flags=re.I) is not None]
386 391
            elif img_type == "id":
387 392
                # Filter images by id
388 393
                self.logger.debug(
......
421 426
        self.write_temp_config('server_port', server_port)
422 427
        self.logger.debug("Server's ssh port is %s" % _green(server_port))
423 428
        self.logger.debug("Access server using \"ssh -X -p %s %s@%s\"" %
424
                          (server_port, server['metadata']['users'], server_ip))
429
                          (server_port, server['metadata']['users'],
430
                           server_ip))
425 431

  
426 432
    @_check_fabric
427 433
    def _copy_ssh_keys(self, ssh_keys):
......
432 438

  
433 439
        if ssh_keys != "":
434 440
            ssh_keys = os.path.expanduser(ssh_keys)
435
            self.logger.debug("Will use %s authentication keys file" % ssh_keys)
441
            self.logger.debug("Will use %s authentication keys file" %
442
                              ssh_keys)
436 443
            keyfile = '/tmp/%s.pub' % fabric.env.user
437 444
            _run('mkdir -p ~/.ssh && chmod 700 ~/.ssh', False)
438 445
            if ssh_keys.startswith("http://") or \

Also available in: Unified diff