aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-11-17 09:45:55 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-11-17 09:45:55 +0000
commit3e00b3a1eb53889ede21578d75856ebaf633e5d9 (patch)
tree32b5f593415b6446cd11e57cf40f5df0517ea95e /yardstick
parent1b9cc8a38a4866797bd49d006e22607b348f42ac (diff)
parent37dd0cbbcbcb1aa00b7f3aa2e74a6775c6a7f2fb (diff)
Merge "Create get_description and get_scenario_type for Scenario"
Diffstat (limited to 'yardstick')
-rw-r--r--yardstick/benchmark/core/scenario.py7
-rw-r--r--yardstick/benchmark/scenarios/base.py14
2 files changed, 17 insertions, 4 deletions
diff --git a/yardstick/benchmark/core/scenario.py b/yardstick/benchmark/core/scenario.py
index cd119c24c..28eb65230 100644
--- a/yardstick/benchmark/core/scenario.py
+++ b/yardstick/benchmark/core/scenario.py
@@ -10,7 +10,6 @@
""" Handler for yardstick command 'scenario' """
from __future__ import absolute_import
-from __future__ import print_function
from yardstick.benchmark.scenarios.base import Scenario
from yardstick.benchmark.core import print_hbar
@@ -27,9 +26,9 @@ class Scenarios(object): # pragma: no cover
print_hbar(78)
print("| %-16s | %-60s" % ("Type", "Description"))
print_hbar(78)
- for stype in types:
- print("| %-16s | %-60s" % (stype.__scenario_type__,
- stype.__doc__.split("\n")[0]))
+ for scenario_class in types:
+ print("| %-16s | %-60s" % (scenario_class.get_scenario_type(),
+ scenario_class.get_description()))
print_hbar(78)
def show(self, args):
diff --git a/yardstick/benchmark/scenarios/base.py b/yardstick/benchmark/scenarios/base.py
index 3cb138dd8..7af85834c 100644
--- a/yardstick/benchmark/scenarios/base.py
+++ b/yardstick/benchmark/scenarios/base.py
@@ -64,6 +64,20 @@ class Scenario(object):
raise RuntimeError("No such scenario type %s" % scenario_type)
+ @classmethod
+ def get_scenario_type(cls):
+ """Return a string with the scenario type, if defined"""
+ return str(getattr(cls, '__scenario_type__', None))
+
+ @classmethod
+ def get_description(cls):
+ """Return a single line string with the class description
+
+ This function will retrieve the class docstring and return the first
+ line, or 'None' if it's empty.
+ """
+ return cls.__doc__.splitlines()[0] if cls.__doc__ else str(None)
+
def _push_to_outputs(self, keys, values):
return dict(zip(keys, values))