diff options
author | xudan <xudan16@huawei.com> | 2019-11-13 03:32:24 -0500 |
---|---|---|
committer | Dan Xu <xudan16@huawei.com> | 2019-11-19 10:57:03 +0000 |
commit | 88dee82da16683c7796036ae6e20a2d7c1f6b162 (patch) | |
tree | d82bb8ead2c4b8bdfe66d817e9159c90f1a6fb6a /dovetail/container.py | |
parent | b88e2328f7960d88aa979d01ad6ba6f06519b899 (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/container.py')
-rw-r--r-- | dovetail/container.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/dovetail/container.py b/dovetail/container.py index ec9b1fb2..b2a9428f 100644 --- a/dovetail/container.py +++ b/dovetail/container.py @@ -58,23 +58,28 @@ class Container(object): kwargs = dt_utils.get_value_from_dict('opts', project_cfg) shell = dt_utils.get_value_from_dict('shell', project_cfg) if not shell: - return None + return None, "Lacking of key word 'shell' in config file." env_list = dt_utils.get_value_from_dict('envs', project_cfg) if env_list: kwargs['environment'] = \ [env for env in env_list if env is not None] volume_list = dt_utils.get_value_from_dict('volumes', project_cfg) kwargs['volumes'] = [vol for vol in volume_list if vol is not None] + + kwargs['mounts'], msg = dt_utils.get_mount_list(project_cfg) + if not kwargs['mounts']: + return None, msg + kwargs['extra_hosts'] = dt_utils.get_hosts_info(self.logger) try: self.container = self.client.containers.run( docker_image, shell, **kwargs) except (docker.errors.ContainerError, docker.errors.ImageNotFound, - docker.errors.APIError): - return None + docker.errors.APIError) as e: + return None, e - return self.container.id + return self.container.id, 'Successfully to create container.' def get_image_id(self, image_name): try: |