aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKubi <jean.gaoliang@huawei.com>2016-11-14 10:03:36 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-11-14 10:03:36 +0000
commit6311eca37a36efd24436034d5ab43c81045917a2 (patch)
tree32db2cd46b61184f4a1a4fb7eb520352ab2c4e0f
parent293a8ed0c22d7944c8fc671792683d45d3fa8d48 (diff)
parent1873da9a908a50fe70a074731e3643297b6eab6d (diff)
Merge "Add task call entry in cli for REST API"
-rw-r--r--yardstick/cmd/cli.py35
-rw-r--r--yardstick/cmd/commands/task.py2
2 files changed, 34 insertions, 3 deletions
diff --git a/yardstick/cmd/cli.py b/yardstick/cmd/cli.py
index dd74836cb..f2406bf08 100644
--- a/yardstick/cmd/cli.py
+++ b/yardstick/cmd/cli.py
@@ -101,8 +101,7 @@ class YardstickCLI():
cmd_subparsers = subparser.add_subparsers(title='subcommands')
self._find_actions(cmd_subparsers, command_object)
- def main(self, argv):
- '''run the command line interface'''
+ def _register_cli_opt(self):
# register subcommands to parse additional command line arguments
def parser(subparsers):
@@ -114,10 +113,14 @@ class YardstickCLI():
handler=parser)
CONF.register_cli_opt(category_opt)
+ def _load_cli_config(self, argv):
+
# load CLI args and config files
CONF(argv, project="yardstick", version=self._version,
default_config_files=find_config_files(CONFIG_SEARCH_PATHS))
+ def _handle_global_opts(self):
+
# handle global opts
logger = logging.getLogger('yardstick')
logger.setLevel(logging.WARNING)
@@ -128,6 +131,34 @@ class YardstickCLI():
if CONF.debug:
logger.setLevel(logging.DEBUG)
+ def _dispath_func_notask(self):
+
# dispatch to category parser
func = CONF.category.func
func(CONF.category)
+
+ def _dispath_func_task(self, task_id, timestamp):
+
+ # dispatch to category parser
+ func = CONF.category.func
+ func(CONF.category, task_id=task_id, timestamp=timestamp)
+
+ def main(self, argv): # pragma: no cover
+ '''run the command line interface'''
+ self._register_cli_opt()
+
+ self._load_cli_config(argv)
+
+ self._handle_global_opts()
+
+ self._dispath_func_notask()
+
+ def api(self, argv, task_id, timestamp): # pragma: no cover
+ '''run the api interface'''
+ self._register_cli_opt()
+
+ self._load_cli_config(argv)
+
+ self._handle_global_opts()
+
+ self._dispath_func_task(task_id, timestamp)
diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py
index b38e084ac..a10a2a8a3 100644
--- a/yardstick/cmd/commands/task.py
+++ b/yardstick/cmd/commands/task.py
@@ -51,7 +51,7 @@ class TaskCommands(object):
output_file_default, default=output_file_default)
@cliargs("--suite", help="process test suite file instead of a task file",
action="store_true")
- def do_start(self, args):
+ def do_start(self, args, **kwargs):
'''Start a benchmark scenario.'''
atexit.register(atexit_handler)