diff options
Diffstat (limited to 'dovetail/utils')
-rw-r--r-- | dovetail/utils/dovetail_config.py | 13 | ||||
-rw-r--r-- | dovetail/utils/dovetail_utils.py | 28 |
2 files changed, 38 insertions, 3 deletions
diff --git a/dovetail/utils/dovetail_config.py b/dovetail/utils/dovetail_config.py index d3b54192..b152cc8a 100644 --- a/dovetail/utils/dovetail_config.py +++ b/dovetail/utils/dovetail_config.py @@ -21,9 +21,16 @@ class DovetailConfig(object): cls.dovetail_config = yaml.safe_load(f) for extra_config_file in cls.dovetail_config['include_config']: - with open(os.path.join(conf_path, extra_config_file)) as f: - extra_config = yaml.safe_load(f) - cls.dovetail_config.update(extra_config) + + # The yardstick config file needs to be parsed later. + # Because it's related to the exact test case. + if extra_config_file.startswith("yardstick"): + continue + else: + file_path = os.path.join(conf_path, extra_config_file) + with open(file_path) as f: + extra_config = yaml.safe_load(f) + cls.dovetail_config.update(extra_config) path = os.path.join(conf_path, cls.dovetail_config['cli_file_name']) with open(path) as f: diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py index 2c16ca71..be2974b6 100644 --- a/dovetail/utils/dovetail_utils.py +++ b/dovetail/utils/dovetail_utils.py @@ -379,3 +379,31 @@ def get_hosts_info(logger=None): logger.error("There is no key {} in file {}" .format(e, hosts_config_file)) return hosts_config + + +def read_yaml_file(file_path, logger=None): + if not os.path.isfile(file_path): + logger.error("File {} doesn't exist.".format(file_path)) + return None + try: + with open(file_path, 'r') as f: + content = yaml.safe_load(f) + return content + except Exception as e: + logger.exception("Failed to read file {}, exception: {}" + .format(file_path, e)) + return None + + +def read_plain_file(file_path, logger=None): + if not os.path.isfile(file_path): + logger.error("File {} doesn't exist.".format(file_path)) + return None + try: + with open(file_path, 'r') as f: + content = f.read() + return content + except Exception as e: + logger.exception("Failed to read file {}, exception: {}" + .format(file_path, e)) + return None |