summaryrefslogtreecommitdiffstats
path: root/dovetail/container.py
diff options
context:
space:
mode:
Diffstat (limited to 'dovetail/container.py')
-rw-r--r--dovetail/container.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/dovetail/container.py b/dovetail/container.py
index ae7c8e2e..11c64f49 100644
--- a/dovetail/container.py
+++ b/dovetail/container.py
@@ -8,6 +8,7 @@
#
import os
+import yaml
import utils.dovetail_logger as dt_logger
import utils.dovetail_utils as dt_utils
@@ -149,10 +150,26 @@ class Container(object):
' -v %s:%s ' % (dovetail_config['userconfig_dir'],
dovetail_config["functest"]['config']['dir'])
+ hosts_config = ""
+ hosts_config_path = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), os.pardir, 'userconfig'))
+ try:
+ with open(os.path.join(hosts_config_path, 'hosts.yaml')) as f:
+ hosts_info = yaml.safe_load(f)
+ if hosts_info['hosts_info']:
+ for host in hosts_info['hosts_info']:
+ hosts_config += " --add-host "
+ hosts_config += str(host)
+ cls.logger.info('get hosts info %s', hosts_config)
+ except Exception:
+ cls.logger.warn('fail to get hosts info in %s/hosts.yaml, \
+ maybe some issue with domain name resolution',
+ hosts_config_path)
+
result_volume = ' -v %s:%s ' % (dovetail_config['result_dir'],
dovetail_config[type]['result']['dir'])
- cmd = 'sudo docker run %s %s %s %s %s %s %s /bin/bash' % \
- (opts, envs, config, openrc, config_volume,
+ cmd = 'sudo docker run %s %s %s %s %s %s %s %s /bin/bash' % \
+ (opts, envs, config, hosts_config, openrc, config_volume,
result_volume, docker_image)
dt_utils.exec_cmd(cmd, cls.logger)
ret, container_id = \