Commit 03cba903 authored by Christos Stavrakakis's avatar Christos Stavrakakis

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
parent 4d80d699
...@@ -27,9 +27,8 @@ temporary_config = /tmp/ci_temp_conf ...@@ -27,9 +27,8 @@ temporary_config = /tmp/ci_temp_conf
[Deployment] [Deployment]
# Credentials # Choose the 'cloud' to use from .kamakirc
auth_url = https://accounts.okeanos.io/identity/v2.0/ kamaki_cloud =
token =
# If we deploy on okeanos.io we have to set this to True # 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 # The server will reside besides a NAT and we have to compute ssh port
deploy_on_io = True deploy_on_io = True
......
...@@ -10,12 +10,6 @@ from utils import SynnefoCI ...@@ -10,12 +10,6 @@ from utils import SynnefoCI
def setup_slave(): def setup_slave():
"""Setup slave server""" """Setup slave server"""
synnefo_ci = SynnefoCI(cleanup_config=True) 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 # Build slave server
synnefo_ci.create_server() synnefo_ci.create_server()
# Copy synnefo repo to server # Copy synnefo repo to server
......
...@@ -11,6 +11,7 @@ import logging ...@@ -11,6 +11,7 @@ import logging
import fabric.api as fabric import fabric.api as fabric
from ConfigParser import ConfigParser, DuplicateSectionError from ConfigParser import ConfigParser, DuplicateSectionError
from kamaki.cli import config as kamaki_config
from kamaki.clients.astakos import AstakosClient from kamaki.clients.astakos import AstakosClient
from kamaki.clients.cyclades import CycladesClient from kamaki.clients.cyclades import CycladesClient
from kamaki.clients.image import ImageClient from kamaki.clients.image import ImageClient
...@@ -84,7 +85,7 @@ class _MyFormatter(logging.Formatter): ...@@ -84,7 +85,7 @@ class _MyFormatter(logging.Formatter):
class SynnefoCI(object): class SynnefoCI(object):
"""SynnefoCI python class""" """SynnefoCI python class"""
def __init__(self, cleanup_config=False): def __init__(self, cleanup_config=False, cloud=None):
""" Initialize SynnefoCI python class """ Initialize SynnefoCI python class
Setup logger, local_dir, config and kamaki Setup logger, local_dir, config and kamaki
...@@ -117,6 +118,16 @@ class SynnefoCI(object): ...@@ -117,6 +118,16 @@ class SynnefoCI(object):
else: else:
self.config.read(self.config.get('Global', 'temporary_config')) 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 # Initialize variables
self.fabric_installed = False self.fabric_installed = False
self.kamaki_installed = False self.kamaki_installed = False
...@@ -128,10 +139,16 @@ class SynnefoCI(object): ...@@ -128,10 +139,16 @@ class SynnefoCI(object):
Setup cyclades_client and image_client 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)) 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)) #self.logger.debug("Token is %s" % _green(token))
astakos_client = AstakosClient(auth_url, token) astakos_client = AstakosClient(auth_url, token)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment