summaryrefslogtreecommitdiffstats
path: root/dovetail/utils/dovetail_utils.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2019-11-13 03:32:24 -0500
committerDan Xu <xudan16@huawei.com>2019-11-19 10:57:03 +0000
commit88dee82da16683c7796036ae6e20a2d7c1f6b162 (patch)
treed82bb8ead2c4b8bdfe66d817e9159c90f1a6fb6a /dovetail/utils/dovetail_utils.py
parentb88e2328f7960d88aa979d01ad6ba6f06519b899 (diff)
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 <xudan16@huawei.com>
Diffstat (limited to 'dovetail/utils/dovetail_utils.py')
-rw-r--r--dovetail/utils/dovetail_utils.py24
1 files changed, 24 insertions, 0 deletions
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.'