summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeriyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>2018-02-27 08:46:49 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-02-27 08:46:49 +0000
commitb12c075fc625d1f13e3864d11aba30650e0c96a6 (patch)
tree727632211d91e3a3eefc489258f1e7acaa82abe1
parenta459c11cf7450a685aa72f6f73d7dc6a88e867dd (diff)
parentfe077e8bbd41907db20765174a2bff388a1321a3 (diff)
Merge "Stop relying on internal Functest utils"
-rw-r--r--sdnvpn/lib/openstack_utils.py25
-rw-r--r--sdnvpn/test/functest/testcase_3.py3
2 files changed, 22 insertions, 6 deletions
diff --git a/sdnvpn/lib/openstack_utils.py b/sdnvpn/lib/openstack_utils.py
index 98da48b..49771d5 100644
--- a/sdnvpn/lib/openstack_utils.py
+++ b/sdnvpn/lib/openstack_utils.py
@@ -10,8 +10,10 @@
import logging
import os.path
+import shutil
import sys
import time
+import urllib
from keystoneauth1 import loading
from keystoneauth1 import session
@@ -22,8 +24,8 @@ from novaclient import client as novaclient
from keystoneclient import client as keystoneclient
from neutronclient.neutron import client as neutronclient
+from functest.utils import config
from functest.utils import env
-import functest.utils.functest_utils as ft_utils
logger = logging.getLogger(__name__)
@@ -224,13 +226,29 @@ def get_heat_client(other_creds={}):
return heatclient.Client(get_heat_client_version(), session=sess)
+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_and_add_image_on_glance(glance, image_name, image_url, data_dir):
try:
dest_path = data_dir
if not os.path.exists(dest_path):
os.makedirs(dest_path)
file_name = image_url.rsplit('/')[-1]
- if not ft_utils.download_url(image_url, dest_path):
+ if not download_url(image_url, dest_path):
return False
except Exception:
raise Exception("Impossible to download image from {}".format(
@@ -343,8 +361,7 @@ def create_flavor(nova_client, flavor_name, ram, disk, vcpus, public=True):
flavor = nova_client.flavors.create(
flavor_name, ram, vcpus, disk, is_public=public)
try:
- extra_specs = ft_utils.get_functest_config(
- 'general.flavor_extra_specs')
+ extra_specs = getattr(config.CONF, 'flavor_extra_specs')
flavor.set_keys(extra_specs)
except ValueError:
# flavor extra specs are not configured, therefore skip the update
diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py
index 6e7cbae..54ae122 100644
--- a/sdnvpn/test/functest/testcase_3.py
+++ b/sdnvpn/test/functest/testcase_3.py
@@ -16,7 +16,6 @@ import logging
import os
import sys
-from functest.utils import functest_utils as ft_utils
from sdnvpn.lib import quagga
from sdnvpn.lib import openstack_utils as os_utils
from sdnvpn.lib import utils as test_utils
@@ -139,7 +138,7 @@ def main():
# Taken from the sfc tests
if not os.path.isfile(COMMON_CONFIG.ubuntu_image_path):
logger.info("Downloading image")
- ft_utils.download_url(
+ os_utils.download_url(
"http://artifacts.opnfv.org/sdnvpn/"
"ubuntu-16.04-server-cloudimg-amd64-disk1.img",
"/home/opnfv/functest/data/")