summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--dovetail/container.py7
-rw-r--r--dovetail/test_runner.py11
-rw-r--r--dovetail/utils/offline/config.yaml6
-rwxr-xr-xdovetail/utils/offline/download.py8
-rwxr-xr-xdovetail/utils/offline/load.py22
6 files changed, 53 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 82b83ef8..9ae58f1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,4 @@ unittest_results.log
docs_build/
docs_output/
results/
+pre_config/
diff --git a/dovetail/container.py b/dovetail/container.py
index c0a925e9..2d8a9e20 100644
--- a/dovetail/container.py
+++ b/dovetail/container.py
@@ -181,6 +181,13 @@ class Container(object):
dt_utils.exec_cmd("sudo docker ps | grep " + docker_image +
" | awk '{print $1}' | head -1", cls.logger)
cls.container_list[type] = container_id
+
+ if 'sdnvpn' in str(testcase_name):
+ prefix_path = dt_cfg.dovetail_config[type]['config']['dir']
+ file_name = dt_cfg.dovetail_config['sdnvpn_image']
+ src_path = os.path.join(prefix_path, 'pre_config', file_name)
+ dest_path = '/home/opnfv/functest/images'
+ Container.pre_copy(container_id, src_path, dest_path)
return container_id
@classmethod
diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py
index cbc7e2d3..6ae410c1 100644
--- a/dovetail/test_runner.py
+++ b/dovetail/test_runner.py
@@ -49,13 +49,22 @@ class DockerRunner(object):
if dt_cfg.dovetail_config['offline']:
exist = Container.check_image_exist(self.testcase.validate_type())
if not exist:
- self.logger.error('%s image not exist offline running',
+ self.logger.error('%s image not exist when running offline',
self.testcase.validate_type())
return
else:
if not Container.pull_image(self.testcase.validate_type()):
self.logger.error("Failed to pull the image.")
return
+ # for sdnvpn, there is a need to download needed images to config_dir
+ # in dovetail_config.yml first.
+ if 'sdnvpn' in str(self.testcase.name()):
+ img_name = dt_cfg.dovetail_config['sdnvpn_image']
+ img_file = os.path.join(dt_cfg.dovetail_config['config_dir'],
+ img_name)
+ if not os.path.isfile(img_file):
+ self.logger.error('image %s not found', img_name)
+ return
container_id = Container.create(self.testcase.validate_type(),
self.testcase.name())
if not container_id:
diff --git a/dovetail/utils/offline/config.yaml b/dovetail/utils/offline/config.yaml
index ced42296..185686a5 100644
--- a/dovetail/utils/offline/config.yaml
+++ b/dovetail/utils/offline/config.yaml
@@ -20,3 +20,9 @@ docker_images:
tag: 3.5
store_name: image_mongo.docker
docker_save_path: /home/opnfv/dovetail/results/
+
+wgets:
+ sdnvpn:
+ source_url: http://artifacts.opnfv.org/sdnvpn/ubuntu-16.04-server-cloudimg-amd64-disk1.img
+ save_path: /home/opnfv/dovetail/results/
+ file_name: ubuntu-16.04-server-cloudimg-amd64-disk1.img
diff --git a/dovetail/utils/offline/download.py b/dovetail/utils/offline/download.py
index cda4ecca..3fb0cde2 100755
--- a/dovetail/utils/offline/download.py
+++ b/dovetail/utils/offline/download.py
@@ -41,6 +41,14 @@ class download(object):
cmd = 'sudo chmod og+rw %s' % image_save_path
dt_utils.exec_cmd(cmd)
+ if 'wgets' in keys:
+ for key, value in self.config['wgets'].items():
+ if value is not None:
+ wget_url = self.config['wgets'][key]['source_url']
+ wget_path = self.config['wgets'][key]['save_path']
+ cmd = 'sudo wget -nc %s -P %s' % (wget_url, wget_path)
+ dt_utils.exec_cmd(cmd)
+
if __name__ == '__main__':
download = download()
diff --git a/dovetail/utils/offline/load.py b/dovetail/utils/offline/load.py
index 9ddf6596..c56868a5 100755
--- a/dovetail/utils/offline/load.py
+++ b/dovetail/utils/offline/load.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import os
+import sys
import yaml
import dovetail.utils.dovetail_utils as dt_utils
@@ -22,12 +23,31 @@ class load(object):
for key, value in self.config['docker_images'].items():
if value is not None:
name = self.config['docker_images'][key]['store_name']
- image_save_path = ''.join([save_path, name])
+ image_save_path = os.path.join(save_path, name)
if os.path.isfile(image_save_path):
cmd = 'sudo docker load -i %s' % (image_save_path)
dt_utils.exec_cmd(cmd)
else:
print "file %s not exists" % image_save_path
+ if 'wgets' in keys:
+ for key, value in self.config['wgets'].items():
+ if value is not None:
+ try:
+ dovetail_home = os.environ["DOVETAIL_HOME"]
+ except KeyError:
+ print "env variable DOVETAIL_HOME not found"
+ sys.exit(1)
+ name = self.config['wgets'][key]['file_name']
+ save_path = self.config['wgets'][key]['save_path']
+ file_path = os.path.join(save_path, name)
+ dest_path = os.path.join(dovetail_home, 'pre_config')
+ if not os.path.isdir(dest_path):
+ os.mkdir(dest_path)
+ if os.path.isfile(file_path):
+ cmd = 'sudo cp %s %s' % (file_path, dest_path)
+ dt_utils.exec_cmd(cmd)
+ else:
+ print "file %s not exists" % file_path
if __name__ == '__main__':