d4dc246ef07c0cc5aa3121733b221ad9c5aaa16e
[yardstick.git] / api / resources / release_action.py
1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import uuid
10 import os
11 import logging
12
13 from api import conf
14 from api.utils import common as common_utils
15
16 logger = logging.getLogger(__name__)
17
18
19 def runTestCase(args):
20     try:
21         opts = args.get('opts', {})
22         testcase = args['testcase']
23     except KeyError:
24         return common_utils.error_handler('Lack of testcase argument')
25
26     testcase_name = conf.TEST_CASE_PRE + testcase
27     testcase = os.path.join(conf.TEST_CASE_PATH, testcase_name + '.yaml')
28
29     task_id = str(uuid.uuid4())
30
31     command_list = ['task', 'start']
32     command_list = common_utils.get_command_list(command_list, opts, testcase)
33     logger.debug('The command_list is: %s', command_list)
34
35     logger.debug('Start to execute command list')
36     task_dict = {
37         'task_id': task_id,
38         'details': testcase_name
39     }
40     common_utils.exec_command_task(command_list, task_dict)
41
42     return common_utils.result_handler('success', task_id)