aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sfc/lib/config.py3
-rw-r--r--sfc/lib/test_utils.py21
2 files changed, 20 insertions, 4 deletions
diff --git a/sfc/lib/config.py b/sfc/lib/config.py
index 28541ce3..6ced2763 100644
--- a/sfc/lib/config.py
+++ b/sfc/lib/config.py
@@ -89,8 +89,7 @@ class CommonConfig(object):
"defaults.image_format", self.config_file)
self.image_url = ft_utils.get_parameter_from_yaml(
"defaults.image_url", self.config_file)
- self.dir_functest_data = ft_utils.get_functest_config(
- "general.dir.functest_data")
+ self.dir_functest_data = getattr(config.CONF, 'dir_functest_data')
class TestcaseConfig(object):
diff --git a/sfc/lib/test_utils.py b/sfc/lib/test_utils.py
index a04f1e24..c495aa11 100644
--- a/sfc/lib/test_utils.py
+++ b/sfc/lib/test_utils.py
@@ -10,9 +10,10 @@
import os
import subprocess
import time
+import shutil
+import urllib
import logging
-import functest.utils.functest_utils as ft_utils
logger = logging.getLogger(__name__)
@@ -51,13 +52,29 @@ def run_cmd_remote(ip, cmd, username="root", passwd="opnfv"):
return run_cmd(ssh_cmd)
+def download_url(url, dest_path):
+ """
+ Download a file to a destination path given a URL
+ """
+ name = url.rsplit('/')[-1]
+ dest = dest_path + "/" + name
+ try:
+ response = urllib.urlopen(url)
+ except Exception:
+ return False
+
+ with open(dest, 'wb') as lfile:
+ shutil.copyfileobj(response, lfile)
+ return True
+
+
def download_image(url, image_path):
image_filename = os.path.basename(image_path)
image_url = "%s/%s" % (url, image_filename)
image_dir = os.path.dirname(image_path)
if not os.path.isfile(image_path):
logger.info("Downloading image")
- ft_utils.download_url(image_url, image_dir)
+ download_url(image_url, image_dir)
else:
logger.info("Using old image")