aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common/constants.py
diff options
context:
space:
mode:
authorEdward MacGillivray <edward.s.macgillivray@intel.com>2017-09-15 16:45:41 -0700
committerEdward MacGillivray <edward.s.macgillivray@intel.com>2017-09-26 20:03:04 +0000
commit3de95504a9a329cefcdec2ea9508709118bbf94e (patch)
tree246df74d6323ec4e00207a5f02dbb57674774ce3 /yardstick/common/constants.py
parentc84187fc404d44082826f98b47c28d3d8f6690e5 (diff)
Ensure that at least one handler is available
https://jira.opnfv.org/browse/YARDSTICK-773?filter=-3 Remove dependency of yardstick on utils methods Change-Id: Iadf502364a7f08c279a8f0d17d7e45e8047f4066 Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com>
Diffstat (limited to 'yardstick/common/constants.py')
-rw-r--r--yardstick/common/constants.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py
index b416f42b9..32ed746df 100644
--- a/yardstick/common/constants.py
+++ b/yardstick/common/constants.py
@@ -8,11 +8,16 @@
##############################################################################
from __future__ import absolute_import
import os
+import errno
+
from functools import reduce
import pkg_resources
-from yardstick.common.utils import parse_yaml
+# this module must only import other modules that do
+# not require loggers to be created, so this cannot
+# include yardstick.common.utils
+from yardstick.common.yaml_loader import yaml_load
dirname = os.path.dirname
abspath = os.path.abspath
@@ -29,7 +34,19 @@ def get_param(key, default=''):
# don't re-parse yaml for each lookup
if not CONF:
- CONF.update(parse_yaml(conf_file))
+ # do not use yardstick.common.utils.parse_yaml
+ # since yardstick.common.utils creates a logger
+ # and so it cannot be imported before this code
+ try:
+ with open(conf_file) as f:
+ value = yaml_load(f)
+ except IOError:
+ pass
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
+ else:
+ CONF.update(value)
try:
return reduce(lambda a, b: a[b], key.split('.'), CONF)
except KeyError: