diff options
Diffstat (limited to 'yardstick/benchmark/core/task.py')
-rw-r--r-- | yardstick/benchmark/core/task.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py index 9605e9426..2c67e736c 100644 --- a/yardstick/benchmark/core/task.py +++ b/yardstick/benchmark/core/task.py @@ -25,14 +25,17 @@ import errno import collections from six.moves import filter +from jinja2 import Environment from yardstick.benchmark.contexts.base import Context from yardstick.benchmark.runners import base as base_runner +from yardstick.common.yaml_loader import yaml_load from yardstick.dispatcher.base import Base as DispatcherBase from yardstick.common.task_template import TaskTemplate from yardstick.common.utils import source_env from yardstick.common import utils from yardstick.common import constants +from yardstick.common.html_template import report_template output_file_default = "/tmp/yardstick.out" config_file = '/etc/yardstick/yardstick.conf' @@ -146,6 +149,7 @@ class Task(object): # pragma: no cover result = self._get_format_result(testcases) self._do_output(output_config, result) + self._generate_reporting(result) total_end_time = time.time() LOG.info("total finished in %d secs", @@ -158,6 +162,13 @@ class Task(object): # pragma: no cover print("Done, exiting") return result + def _generate_reporting(self, result): + env = Environment() + with open(constants.REPORTING_FILE, 'w') as f: + f.write(env.from_string(report_template).render(result)) + + LOG.info('yardstick reporting generate in %s', constants.REPORTING_FILE) + def _set_log(self): log_format = '%(asctime)s %(name)s %(filename)s:%(lineno)d %(levelname)s %(message)s' log_formatter = logging.Formatter(log_format) @@ -428,7 +439,7 @@ class TaskParser(object): # pragma: no cover try: with open(self.path) as stream: - cfg = yaml.load(stream) + cfg = yaml_load(stream) except IOError as ioerror: sys.exit(ioerror) @@ -492,7 +503,7 @@ class TaskParser(object): # pragma: no cover raise e print("Input task is:\n%s\n" % rendered_task) - cfg = yaml.load(rendered_task) + cfg = yaml_load(rendered_task) except IOError as ioerror: sys.exit(ioerror) @@ -648,7 +659,7 @@ def parse_task_args(src_name, args): return args try: - kw = args and yaml.safe_load(args) + kw = args and yaml_load(args) kw = {} if kw is None else kw except yaml.parser.ParserError as e: print_invalid_header(src_name, args) |