From 03cba903ac4657f5bbde1610502b346f3ca75d12 Mon Sep 17 00:00:00 2001 From: Christos Stavrakakis Date: Wed, 31 Jul 2013 14:25:39 +0300 Subject: [PATCH] ci: Get credentials by kamakirc Get credentials for deployment from .kamakirc instead of config file. Also, add option in config file indicating which cloud for kamaki to use. Finally, add option in SynnefoCI to override the cloud from config. Refs #4193 --- ci/new_config | 5 ++--- ci/setup_slave.py | 6 ------ ci/utils.py | 25 +++++++++++++++++++++---- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ci/new_config b/ci/new_config index 393164e42..f00aa481e 100644 --- a/ci/new_config +++ b/ci/new_config @@ -27,9 +27,8 @@ temporary_config = /tmp/ci_temp_conf [Deployment] -# Credentials -auth_url = https://accounts.okeanos.io/identity/v2.0/ -token = +# Choose the 'cloud' to use from .kamakirc +kamaki_cloud = # If we deploy on okeanos.io we have to set this to True # The server will reside besides a NAT and we have to compute ssh port deploy_on_io = True diff --git a/ci/setup_slave.py b/ci/setup_slave.py index 71a3219f2..29608afac 100755 --- a/ci/setup_slave.py +++ b/ci/setup_slave.py @@ -10,12 +10,6 @@ from utils import SynnefoCI def setup_slave(): """Setup slave server""" synnefo_ci = SynnefoCI(cleanup_config=True) - # Get token from /nfs/token - try: - token = open("/nfs/synnefo_token").read().strip() - synnefo_ci.write_config('token', token, 'Deployment') - except: - pass # Build slave server synnefo_ci.create_server() # Copy synnefo repo to server diff --git a/ci/utils.py b/ci/utils.py index a4250092d..672220801 100644 --- a/ci/utils.py +++ b/ci/utils.py @@ -11,6 +11,7 @@ import logging import fabric.api as fabric from ConfigParser import ConfigParser, DuplicateSectionError +from kamaki.cli import config as kamaki_config from kamaki.clients.astakos import AstakosClient from kamaki.clients.cyclades import CycladesClient from kamaki.clients.image import ImageClient @@ -84,7 +85,7 @@ class _MyFormatter(logging.Formatter): class SynnefoCI(object): """SynnefoCI python class""" - def __init__(self, cleanup_config=False): + def __init__(self, cleanup_config=False, cloud=None): """ Initialize SynnefoCI python class Setup logger, local_dir, config and kamaki @@ -117,6 +118,16 @@ class SynnefoCI(object): else: self.config.read(self.config.get('Global', 'temporary_config')) + # Set kamaki cloud + if cloud is not None: + self.kamaki_cloud = cloud + elif self.config.has_option("Deployment", "kamaki_cloud"): + kamaki_cloud = self.config.get("Deployment", "kamaki_cloud") + if kamaki_cloud == "": + self.kamaki_cloud = None + else: + self.kamaki_cloud = None + # Initialize variables self.fabric_installed = False self.kamaki_installed = False @@ -128,10 +139,16 @@ class SynnefoCI(object): Setup cyclades_client and image_client """ - self.logger.info("Setup kamaki client..") - auth_url = self.config.get('Deployment', 'auth_url') + + config = kamaki_config.Config() + if self.kamaki_cloud is None: + self.kamaki_cloud = config.get_global("default_cloud") + + self.logger.info("Setup kamaki client, using cloud '%s'.." % + self.kamaki_cloud) + auth_url = config.get_cloud(self.kamaki_cloud, "url") self.logger.debug("Authentication URL is %s" % _green(auth_url)) - token = self.config.get('Deployment', 'token') + token = config.get_cloud(self.kamaki_cloud, "token") #self.logger.debug("Token is %s" % _green(token)) astakos_client = AstakosClient(auth_url, token) -- GitLab