Merge "Adding python package requirement for VNF testing."
[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 from __future__ import absolute_import
10 import uuid
11 import os
12 import logging
13
14 from api import conf
15 from api.utils import common as common_utils
16
17 logger = logging.getLogger(__name__)
18
19
20 def runTestCase(args):
21     try:
22         opts = args.get('opts', {})
23         testcase = args['testcase']
24     except KeyError:
25         return common_utils.error_handler('Lack of testcase argument')
26
27     testcase_name = conf.TEST_CASE_PRE + testcase
28     testcase = os.path.join(conf.TEST_CASE_PATH, testcase_name + '.yaml')
29
30     task_id = str(uuid.uuid4())
31
32     command_list = ['task', 'start']
33     command_list = common_utils.get_command_list(command_list, opts, testcase)
34     logger.debug('The command_list is: %s', command_list)
35
36     logger.debug('Start to execute command list')
37     task_dict = {
38         'task_id': task_id,
39         'details': testcase_name
40     }
41     common_utils.exec_command_task(command_list, task_dict)
42
43     return common_utils.result_handler('success', task_id)