From d8d2ef931c5883dd1a04e563ebb67b381af6f541 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 23 Aug 2013 11:39:02 -0500 Subject: [PATCH] Add teuthology.config, the start of a better system --- teuthology/config.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 teuthology/config.py diff --git a/teuthology/config.py b/teuthology/config.py new file mode 100644 index 0000000000..04e2aa299b --- /dev/null +++ b/teuthology/config.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +import os +import yaml +import logging + +CONF_FILE = os.path.join(os.environ['HOME'], '.teuthology.yaml') + +log = logging.getLogger(__name__) + + +class _Config(object): + def __init__(self): + self.__conf = {} + if not os.path.exists(CONF_FILE): + log.debug("%s not found", CONF_FILE) + return + + with file(CONF_FILE) as f: + conf_obj = yaml.safe_load_all(f) + for item in conf_obj: + self.__conf.update(item) + + @property + def lock_server(self): + return self.__conf.get('lock_server') + + @property + def queue_host(self): + return self.__conf.get('queue_host') + + @property + def queue_port(self): + return self.__conf.get('queue_port') + + @property + def sentry_dsn(self): + return self.__conf.get('sentry_dsn') + +config = _Config() -- 2.39.5