Merge "This Patch is used to add grafana config to opnfv dashboard for kvmfornfv_cycl...
[yardstick.git] / api / resources / testsuites_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
10 """Yardstick test suite api action"""
11
12 from __future__ import absolute_import
13 import uuid
14 import os
15 import logging
16
17 from api import conf
18 from api.utils import common as common_utils
19
20 logger = logging.getLogger(__name__)
21
22
23 def runTestSuite(args):
24     try:
25         opts = args.get('opts', {})
26         testsuite = args['testsuite']
27     except KeyError:
28         return common_utils.error_handler('Lack of testsuite argument')
29
30     if 'suite' not in opts:
31         opts['suite'] = 'true'
32
33     testsuite = os.path.join(conf.TEST_SUITE_PATH,
34                              conf.TEST_SUITE_PRE + testsuite + '.yaml')
35
36     task_id = str(uuid.uuid4())
37
38     command_list = ['task', 'start']
39     command_list = common_utils.get_command_list(command_list, opts, testsuite)
40     logger.debug('The command_list is: %s', command_list)
41
42     logger.debug('Start to execute command list')
43     common_utils.exec_command_task(command_list, task_id)
44
45     return common_utils.result_handler('success', task_id)