summaryrefslogtreecommitdiffstats
path: root/dovetail
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2019-05-14 08:28:56 -0400
committerDan Xu <xudan16@huawei.com>2019-06-12 01:33:40 +0000
commitd1091a5e7c5f6b466d678fca0f47801d3e3f0e1a (patch)
treed216efaf5504ceda2c4b8edb563cf3ae7686c1c8 /dovetail
parentfe1a78666f215a568866c4b5eb28c8feda0ad278 (diff)
Add RESTful APIs into Dovetail container
JIRA: DOVETAIL-774 Change-Id: Ifb934eaeda52c1d316d80d9bb9c1890ffb71049c Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail')
-rw-r--r--dovetail/api/app/__init__.py0
-rw-r--r--dovetail/api/app/constants.py2
-rw-r--r--dovetail/api/app/routes.py19
-rw-r--r--dovetail/api/app/server.py24
-rwxr-xr-xdovetail/api/boot.sh4
-rw-r--r--dovetail/testcase.py2
6 files changed, 51 insertions, 0 deletions
diff --git a/dovetail/api/app/__init__.py b/dovetail/api/app/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/dovetail/api/app/__init__.py
diff --git a/dovetail/api/app/constants.py b/dovetail/api/app/constants.py
new file mode 100644
index 00000000..14d9145e
--- /dev/null
+++ b/dovetail/api/app/constants.py
@@ -0,0 +1,2 @@
+NFVI_PROJECT = ['bottlenecks', 'functest', 'yardstick']
+VNF_PROJECT = ['onap-vtp', 'onap-vvp']
diff --git a/dovetail/api/app/routes.py b/dovetail/api/app/routes.py
new file mode 100644
index 00000000..c235cb48
--- /dev/null
+++ b/dovetail/api/app/routes.py
@@ -0,0 +1,19 @@
+#!flask/bin/python
+
+from flask import Flask, jsonify
+
+import server
+
+app = Flask(__name__)
+
+
+@app.route('/api/v1/scenario/nfvi/testsuites', methods=['GET'])
+def get_all_testsuites():
+ testsuites = server.list_testsuites()
+ return jsonify({'testsuites': testsuites}), 200
+
+
+@app.route('/api/v1/scenario/nfvi/testcases', methods=['GET'])
+def get_testcases():
+ testcases = server.list_testcases()
+ return jsonify({'testcases': testcases}), 200
diff --git a/dovetail/api/app/server.py b/dovetail/api/app/server.py
new file mode 100644
index 00000000..4428c251
--- /dev/null
+++ b/dovetail/api/app/server.py
@@ -0,0 +1,24 @@
+import constants
+
+from dovetail.testcase import Testsuite, Testcase
+
+
+def list_testsuites():
+ return Testsuite.load()
+
+
+def list_testcases():
+ testcases = Testcase.load()
+ testcase_list = []
+ for key, value in testcases.items():
+ testcase = {'testCaseName': key,
+ 'description': value.objective(),
+ 'subTestCase': value.sub_testcase()}
+ if value.validate_type() in constants.NFVI_PROJECT:
+ testcase['scenario'] = 'nfvi'
+ elif value.validate_type() in constants.VNF_PROJECT:
+ testcase['scenario'] = 'vnf'
+ else:
+ testcase['scenario'] = 'unknown'
+ testcase_list.append(testcase)
+ return testcase_list
diff --git a/dovetail/api/boot.sh b/dovetail/api/boot.sh
new file mode 100755
index 00000000..dc49876a
--- /dev/null
+++ b/dovetail/api/boot.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd $(dirname $(readlink -f $0))
+exec gunicorn -b :5000 --access-logfile - --error-logfile - app.routes:app
diff --git a/dovetail/testcase.py b/dovetail/testcase.py
index 279c6ba0..deb00250 100644
--- a/dovetail/testcase.py
+++ b/dovetail/testcase.py
@@ -202,6 +202,7 @@ class Testcase(object):
else:
cls.logger.error('Failed to create test case: {}'
.format(testcase_file))
+ return cls.testcase_list
@classmethod
def get(cls, testcase_name):
@@ -403,6 +404,7 @@ class Testsuite(object):
with open(os.path.join(root, testsuite_yaml)) as f:
testsuite_yaml = yaml.safe_load(f)
cls.testsuite_list.update(testsuite_yaml)
+ return cls.testsuite_list
@classmethod
def get(cls, testsuite_name):