diff options
author | 2017-09-15 16:45:41 -0700 | |
---|---|---|
committer | 2017-10-03 11:00:07 -0700 | |
commit | bb9a5d2d6dcff286df4a7dbc601b6d777abeed6a (patch) | |
tree | 989d1a25f1b5e8a3e5f65846e4eb7894f3aea0d7 /yardstick/common | |
parent | 865dd398b8bc0e37f795c754b7f28660eb853d09 (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')
-rw-r--r-- | yardstick/common/constants.py | 21 | ||||
-rw-r--r-- | yardstick/common/utils.py | 14 |
2 files changed, 19 insertions, 16 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: diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py index 68c9ed63f..6ac99a5a9 100644 --- a/yardstick/common/utils.py +++ b/yardstick/common/utils.py @@ -37,7 +37,6 @@ from oslo_utils import importutils from oslo_serialization import jsonutils import yardstick -from yardstick.common.yaml_loader import yaml_load logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) @@ -94,19 +93,6 @@ def import_modules_from_package(package): logger.exception("unable to import %s", module_name) -def parse_yaml(file_path): - try: - with open(file_path) as f: - value = yaml_load(f) - except IOError: - return {} - except OSError as e: - if e.errno != errno.EEXIST: - raise - else: - return value - - def makedirs(d): try: os.makedirs(d) |