From 9c7563db2dae93e131a75fe1fa8e0c8d0cd04a0f Mon Sep 17 00:00:00 2001 From: chenjiankun Date: Thu, 20 Jul 2017 05:12:06 +0000 Subject: 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 --- api/resources/v2/testsuites.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'api') 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}) -- cgit 1.2.3-korg