From 88dee82da16683c7796036ae6e20a2d7c1f6b162 Mon Sep 17 00:00:00 2001 From: xudan Date: Wed, 13 Nov 2019 03:32:24 -0500 Subject: Fix exception when running HA tests without pod.yaml 1. use volumes '-v' to map files/directories which may be non-existing 2. use mounts '--mount' to map files/directories which couldn't be non-existing JIRA: DOVETAIL-789 Change-Id: I2184e5baed3d1491a2df4d3a1a77a11e3e9b4fc8 Signed-off-by: xudan --- dovetail/utils/dovetail_utils.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'dovetail/utils/dovetail_utils.py') diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py index 306dacd1..1c4aca9d 100644 --- a/dovetail/utils/dovetail_utils.py +++ b/dovetail/utils/dovetail_utils.py @@ -21,6 +21,7 @@ from distutils.version import LooseVersion import yaml import python_hosts import docker +from docker.types import Mount from dovetail import constants from dovetail.utils.dovetail_config import DovetailConfig as dt_cfg @@ -432,3 +433,26 @@ def push_results_to_db(case_name, details, start_date, stop_date, logger): except Exception: logger.exception('The results cannot be pushed to DB.') return False + + +def get_mount_list(project_cfg): + mount_list = [] + mounts = get_value_from_dict('mounts', project_cfg) + for mount in mounts: + if mount: + param_dict = {} + for param in mount.split(','): + key_word = param.split('=') + + if len(key_word) != 2: + return None, 'Error mount {}.'.format(mount) + + param_dict[key_word[0]] = key_word[1] + try: + mount_list.append(Mount(target=param_dict['target'], + source=param_dict['source'], + type='bind')) + except Exception as e: + return None, e + + return mount_list, 'Successfully to get mount list.' -- cgit 1.2.3-korg