summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/api/resources/v1/envs.py41
-rw-r--r--functest/api/urls.py5
-rw-r--r--functest/ci/download_images.sh4
-rw-r--r--functest/ci/run_tests.py4
-rw-r--r--functest/ci/testcases.yaml6
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_base.py6
-rw-r--r--requirements.txt1
-rw-r--r--upper-constraints.txt1
8 files changed, 54 insertions, 14 deletions
diff --git a/functest/api/resources/v1/envs.py b/functest/api/resources/v1/envs.py
index 9c455198d..fb76fa63f 100644
--- a/functest/api/resources/v1/envs.py
+++ b/functest/api/resources/v1/envs.py
@@ -10,11 +10,12 @@
Resources to handle environment related requests
"""
+import IPy
from flask import jsonify
from functest.api.base import ApiResource
-from functest.cli.commands.cli_env import Env
from functest.api.common import api_utils
+from functest.cli.commands.cli_env import Env
import functest.utils.functest_utils as ft_utils
@@ -38,3 +39,41 @@ class V1Envs(ApiResource):
return api_utils.result_handler(status=1, data=str(err))
return api_utils.result_handler(
status=0, data="Prepare env successfully")
+
+ def update_hosts(self, hosts_info): # pylint: disable=no-self-use
+ """ Update hosts info """
+
+ if not isinstance(hosts_info, dict):
+ return api_utils.result_handler(
+ status=1, data='Error, args should be a dict')
+
+ for key, value in hosts_info.items():
+ if key:
+ try:
+ IPy.IP(value)
+ except Exception: # pylint: disable=broad-except
+ return api_utils.result_handler(
+ status=1, data='The IP %s is invalid' % value)
+ else:
+ return api_utils.result_handler(
+ status=1, data='Domain name is absent')
+
+ try:
+ functest_flag = "# SUT hosts info for Functest"
+ hosts_list = ('\n{} {} {}'.format(ip, host_name, functest_flag)
+ for host_name, ip in hosts_info.items())
+
+ with open("/etc/hosts", 'r') as file_hosts:
+ origin_lines = [line for line in file_hosts
+ if functest_flag not in line]
+
+ with open("/etc/hosts", 'w') as file_hosts:
+ file_hosts.writelines(origin_lines)
+ file_hosts.write(functest_flag)
+ file_hosts.writelines(hosts_list)
+ except Exception: # pylint: disable=broad-except
+ return api_utils.result_handler(
+ status=1, data='Error when updating hosts info')
+ else:
+ return api_utils.result_handler(
+ status=0, data='Update hosts info successfully')
diff --git a/functest/api/urls.py b/functest/api/urls.py
index 72c2c53bb..0cc22f80f 100644
--- a/functest/api/urls.py
+++ b/functest/api/urls.py
@@ -25,8 +25,9 @@ URLPATTERNS = [
# GET /api/v1/functest/envs => GET environment
Url('/api/v1/functest/envs', 'v1_envs'),
- # POST /api/v1/functest/envs/action , {"action":"prepare"}
- # => Prepare environment
+ # POST /api/v1/functest/envs/action
+ # {"action":"prepare"} => Prepare environment
+ # {"action":"update_hosts", "args": {}} => Update hosts info
Url('/api/v1/functest/envs/action', 'v1_envs'),
# GET /api/v1/functest/openstack/credentials => GET credentials
diff --git a/functest/ci/download_images.sh b/functest/ci/download_images.sh
index 88474d3a7..cc0abc142 100644
--- a/functest/ci/download_images.sh
+++ b/functest/ci/download_images.sh
@@ -20,6 +20,4 @@ https://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloud
http://cloud.centos.org/altarch/7/images/aarch64/CentOS-7-aarch64-GenericCloud.qcow2.xz
EOF
-xz --decompress --force ${1:-/home/opnfv/functest/images}/CentOS-7-aarch64-GenericCloud.qcow2.xz
-
-exit $?
+xz --decompress --force --keep ${1:-/home/opnfv/functest/images}/CentOS-7-aarch64-GenericCloud.qcow2.xz
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index 87e3d37ba..feafa89e6 100644
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -189,9 +189,9 @@ class Runner(object):
def main(self, **kwargs):
if 'noclean' in kwargs:
- self.clean_flag = False
+ self.clean_flag = not kwargs['noclean']
if 'report' in kwargs:
- self.report_flag = True
+ self.report_flag = kwargs['report']
try:
if 'test' in kwargs:
self.source_rc_file()
diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml
index fac81267f..ce71c9b6f 100644
--- a/functest/ci/testcases.yaml
+++ b/functest/ci/testcases.yaml
@@ -324,10 +324,10 @@ tiers:
criteria: 100
blocking: false
description: >-
- Test suite for odl-sfc to test two chains and two SFs
+ Test suite for odl-sfc to test two chains with one SF and one chain with two SFs
dependencies:
- installer: '(apex)|(fuel)'
- scenario: 'odl_l2-sfc'
+ installer: ''
+ scenario: 'odl.*sfc'
run:
module: 'functest.core.feature'
class: 'BashFeature'
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index 40fcb07f0..6e9080654 100644
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -113,13 +113,13 @@ class VPingBase(testcase.TestCase):
vping_physical_network = None
vping_segmentation_id = None
- if (hasattr(CONST, 'network_type')):
+ if (hasattr(CONST, 'vping_network_type')):
vping_network_type = CONST.__getattribute__(
'vping_network_type')
- if (hasattr(CONST, 'physical_network')):
+ if (hasattr(CONST, 'vping_physical_network')):
vping_physical_network = CONST.__getattribute__(
'vping_physical_network')
- if (hasattr(CONST, 'segmentation_id')):
+ if (hasattr(CONST, 'vping_segmentation_id')):
vping_segmentation_id = CONST.__getattribute__(
'vping_segmentation_id')
diff --git a/requirements.txt b/requirements.txt
index e1d34a36a..ba5d91cb8 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -23,6 +23,7 @@ openbaton-cli
cloudify_rest_client
Flask!=0.11,<1.0,>=0.10 # BSD
Flask-RESTful>=0.3.5 # BSD
+IPy
mock>=2.0 # BSD
iniparse==0.4
PrettyTable<0.8,>=0.7.1 # BSD
diff --git a/upper-constraints.txt b/upper-constraints.txt
index 74d363c50..fae94270c 100644
--- a/upper-constraints.txt
+++ b/upper-constraints.txt
@@ -14,3 +14,4 @@ robotframework-httplibrary===0.4.2
robotframework-requests===0.4.7
robotframework-sshlibrary===2.1.3;python_version=='2.7'
rally===0.9.1
+IPy===0.83