X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=api%2Fresources%2Fv2%2Ftestsuites.py;h=ee942eff99034b6d9866733e52043b22a6ea5214;hb=acc000cff316fa9883217121a3c30b0e2145a363;hp=189988ea4137a1cbaef8f68c3240a91de45c54a6;hpb=50be49a89258a373aa1bb61b9f7fd2f26f9241e8;p=yardstick.git diff --git a/api/resources/v2/testsuites.py b/api/resources/v2/testsuites.py index 189988ea4..ee942eff9 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,27 @@ 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}) + + def delete(self, suite_name): + suite_path = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(suite_name)) + try: + os.remove(suite_path) + 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': suite_name})