Split Yardstick CLI with Yardstick core logic
[yardstick.git] / yardstick / benchmark / core / runner.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 'runner' """
11
12 from yardstick.benchmark.runners.base import Runner
13 from yardstick.benchmark.core import print_hbar
14
15
16 class Runners(object):
17     '''Runner commands.
18
19        Set of commands to discover and display runner types.
20     '''
21
22     def list_all(self, args):
23         '''List existing runner types'''
24         types = Runner.get_types()
25         print_hbar(78)
26         print("| %-16s | %-60s" % ("Type", "Description"))
27         print_hbar(78)
28         for rtype in types:
29             print "| %-16s | %-60s" % (rtype.__execution_type__,
30                                        rtype.__doc__.split("\n")[0])
31         print_hbar(78)
32
33     def show(self, args):
34         '''Show details of a specific runner type'''
35         rtype = Runner.get_cls(args.type[0])
36         print rtype.__doc__