Commit 74a0ea92 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

ci: Add option to override configuration file

Add 'config_file' argument to SynnefoCI in order to use a different
configuration file. Also, added the corresponding option to 'snf-ci'
parent 73463250
...@@ -42,6 +42,8 @@ command: ...@@ -42,6 +42,8 @@ command:
def main(): def main():
parser = OptionParser(usage=USAGE) parser = OptionParser(usage=USAGE)
parser.add_option("--conf", dest="config_file", default=None,
help="Configuration file for SynnefoCI script"),
parser.add_option("-c", "--cloud", dest="kamaki_cloud", default=None, parser.add_option("-c", "--cloud", dest="kamaki_cloud", default=None,
help="Use specified cloud, as is in .kamakirc"), help="Use specified cloud, as is in .kamakirc"),
parser.add_option("-f", "--flavor", dest="flavor", default=None, parser.add_option("-f", "--flavor", dest="flavor", default=None,
...@@ -72,7 +74,8 @@ def main(): ...@@ -72,7 +74,8 @@ def main():
setattr(options, command, True) setattr(options, command, True)
cleanup_config = command in CLEAN_CONFIG_CMDS cleanup_config = command in CLEAN_CONFIG_CMDS
synnefo_ci = SynnefoCI(cleanup_config=cleanup_config, synnefo_ci = SynnefoCI(config_file=options.config_file,
cloud=options.kamaki_cloud) cloud=options.kamaki_cloud)
if getattr(options, CREATE_SERVER_CMD, False): if getattr(options, CREATE_SERVER_CMD, False):
...@@ -16,6 +16,8 @@ from kamaki.clients.astakos import AstakosClient ...@@ -16,6 +16,8 @@ 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
DEFAULT_CONFIG_FILE = "new_config"
def _run(cmd, verbose): def _run(cmd, verbose):
"""Run fabric with verbose level""" """Run fabric with verbose level"""
...@@ -85,7 +87,7 @@ class _MyFormatter(logging.Formatter): ...@@ -85,7 +87,7 @@ class _MyFormatter(logging.Formatter):
class SynnefoCI(object): class SynnefoCI(object):
"""SynnefoCI python class""" """SynnefoCI python class"""
def __init__(self, cleanup_config=False, cloud=None): def __init__(self, config_file=None, 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
...@@ -102,13 +104,14 @@ class SynnefoCI(object): ...@@ -102,13 +104,14 @@ class SynnefoCI(object):
self.repo_dir = os.path.dirname(self.ci_dir) self.repo_dir = os.path.dirname(self.ci_dir)
# Read config file # Read config file
default_conffile = os.path.join(self.ci_dir, "new_config") if config_file is None:
self.conffile = os.environ.get("SYNNEFO_CI_CONFIG_FILE", config_file = DEFAULT_CONFIG_FILE
default_conffile) if not os.path.isabs(config_file):
config_file = os.path.join(self.ci_dir, config_file)
self.config = ConfigParser() self.config = ConfigParser()
self.config.optionxform = str self.config.optionxform = str
temp_config = self.config.get('Global', 'temporary_config') temp_config = self.config.get('Global', 'temporary_config')
if cleanup_config: if cleanup_config:
try: try:
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