diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-07-20 04:19:29 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-07-20 04:19:29 +0000 |
commit | f37a9432640c981c77120e416fc6c08d6fd2ff77 (patch) | |
tree | 44cb871743002ff04ec7321cf2f57e23b406021f | |
parent | 376a81e9c5f405edebf260851177a42551dec573 (diff) |
Add API(v2) to get certain test suite info
JIRA: YARDSTICK-748
API: /api/v2/yardstick/testsuites/<suite_name>
METHOD: GET
Change-Id: I0d60ddedff4f76504ebd2e61257bf1b9cad3b923
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
-rw-r--r-- | api/resources/v2/testsuites.py | 15 | ||||
-rw-r--r-- | api/urls.py | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/api/resources/v2/testsuites.py b/api/resources/v2/testsuites.py index 189988ea4..2e23f5b82 100644 --- a/api/resources/v2/testsuites.py +++ b/api/resources/v2/testsuites.py @@ -1,4 +1,5 @@ import os +import errno import logging import yaml @@ -54,3 +55,17 @@ class V2Testsuites(ApiResource): yaml.dump(suite_content, f, default_flow_style=False) return result_handler(consts.API_SUCCESS, {'suite': suite_name}) + + +class V2Testsuite(ApiResource): + + def get(self, suite_name): + suite_path = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(suite_name)) + try: + with open(suite_path) as f: + data = f.read() + except IOError as e: + if e.errno == errno.ENOENT: + return result_handler(consts.API_ERROR, 'suite does not exist') + + return result_handler(consts.API_SUCCESS, {'testsuite': data}) diff --git a/api/urls.py b/api/urls.py index 5c7e9f7b5..2211348f3 100644 --- a/api/urls.py +++ b/api/urls.py @@ -52,5 +52,5 @@ urlpatterns = [ Url('/api/v2/yardstick/testsuites', 'v2_testsuites'), Url('/api/v2/yardstick/testsuites/action', 'v2_testsuites'), - Url('/api/v2/yardstick/testsuites/<suite_name>', 'v2_testsuites') + Url('/api/v2/yardstick/testsuites/<suite_name>', 'v2_testsuite') ] |