From: chenjiankun Date: Thu, 20 Jul 2017 05:12:06 +0000 (+0000) Subject: Add API(v2) to delete certain test suite X-Git-Tag: opnfv-5.0.RC1~357^2 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F35%2F37835%2F1;p=yardstick.git Add API(v2) to delete certain test suite JIRA: YARDSTICK-749 API: /api/v2/yardstick/testsuites/ METHOD: DELETE Change-Id: Idfb5086ab3ac9e7ea6f9512ee5c7f02090d554c0 Signed-off-by: chenjiankun --- diff --git a/api/resources/v2/testsuites.py b/api/resources/v2/testsuites.py index 2e23f5b82..ee942eff9 100644 --- a/api/resources/v2/testsuites.py +++ b/api/resources/v2/testsuites.py @@ -69,3 +69,13 @@ class V2Testsuite(ApiResource): 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})