import logging
import os.path
+import shutil
import sys
import time
+import urllib
from keystoneauth1 import loading
from keystoneauth1 import session
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__)
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(
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
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
# 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/")