Merge "Record test case names when run a task using API"
[yardstick.git] / yardstick / cmd / commands / task.py
1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB 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 """ Handler for yardstick command 'task' """
11 from yardstick.benchmark.core.task import Task
12 from yardstick.common.utils import cliargs
13 from yardstick.cmd.commands import change_osloobj_to_paras
14
15
16 output_file_default = "/tmp/yardstick.out"
17
18
19 class TaskCommands(object):
20     '''Task commands.
21
22        Set of commands to manage benchmark tasks.
23     '''
24
25     @cliargs("inputfile", type=str, help="path to task or suite file", nargs=1)
26     @cliargs("--task-args", dest="task_args",
27              help="Input task args (dict in json). These args are used"
28              "to render input task that is jinja2 template.")
29     @cliargs("--task-args-file", dest="task_args_file",
30              help="Path to the file with input task args (dict in "
31              "json/yaml). These args are used to render input"
32              "task that is jinja2 template.")
33     @cliargs("--keep-deploy", help="keep context deployed in cloud",
34              action="store_true")
35     @cliargs("--parse-only", help="parse the config file and exit",
36              action="store_true")
37     @cliargs("--output-file", help="file where output is stored, default %s" %
38              output_file_default, default=output_file_default)
39     @cliargs("--suite", help="process test suite file instead of a task file",
40              action="store_true")
41     def do_start(self, args, **kwargs):
42         param = change_osloobj_to_paras(args)
43         Task().start(param)