- $ yardstick samples/ping-task.yaml
-"""
-
-import sys
-import yaml
-import atexit
-import pkg_resources
-
-from yardstick.benchmark.context.model import Context
-from yardstick.benchmark.runners import base as base_runner
-from yardstick.cmdparser import CmdParser
-from yardstick.orchestrator.heat import HeatStack
-
-
-class TaskParser(object):
- '''Parser for task config files in yaml format'''
- def __init__(self, path):
- self.path = path
-
- def parse(self):
- '''parses the task file and return an context and scenario instances'''
- print "Parsing task config:", self.path
- try:
- with open(self.path) as stream:
- cfg = yaml.load(stream)
- except IOError as ioerror:
- sys.exit(ioerror)
-
- if cfg["schema"] != "yardstick:task:0.1":
- sys.exit("error: file %s has unknown schema %s" % (self.path,
- cfg["schema"]))
- context = Context()
- context.init(cfg["context"])
-
- run_in_parallel = cfg.get("run_in_parallel", False)
-
- # TODO we need something better here, a class that represent the file
- return cfg["scenarios"], run_in_parallel, context
-
-
-def atexit_handler():
- '''handler for process termination'''
- base_runner.Runner.terminate_all()
-
- if HeatStack.stacks_exist():
- print "Deleting all stacks"
- HeatStack.delete_all()
-