aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/main.py
diff options
context:
space:
mode:
authorHans Feldt <hans.feldt@ericsson.com>2015-06-05 10:17:01 +0200
committerHans Feldt <hans.feldt@ericsson.com>2015-06-09 13:05:12 +0000
commitadf4a310ea7138866e77b0759a07042daac0cca7 (patch)
tree682d385c85622a73aa0a1a25ba37d52e6a61c9bd /yardstick/main.py
parent508e01d81a96c8ede773e6d0dd332892e9600ea7 (diff)
Add support for multiple contexts(stacks)
A list of contexts can be specified, cross referencing between contexts is supported and shown in the added sample file. TBD can placement group work between stacks? Change-Id: I26dbe94e52ba0be5e49f50fd70540a57de2204cb JIRA: YARDSTICK-31 Signed-off-by: Hans Feldt <hans.feldt@ericsson.com>
Diffstat (limited to 'yardstick/main.py')
-rwxr-xr-xyardstick/main.py54
1 files changed, 35 insertions, 19 deletions
diff --git a/yardstick/main.py b/yardstick/main.py
index 050a56436..5669fde10 100755
--- a/yardstick/main.py
+++ b/yardstick/main.py
@@ -23,7 +23,6 @@ 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):
@@ -43,43 +42,58 @@ class TaskParser(object):
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"])
+
+ # TODO: support one or many contexts? Many would simpler and precise
+ if "context" in cfg:
+ context_cfgs = [cfg["context"]]
+ else:
+ context_cfgs = cfg["contexts"]
+
+ for cfg_attrs in context_cfgs:
+ context = Context()
+ context.init(cfg_attrs)
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
+ return cfg["scenarios"], run_in_parallel
def atexit_handler():
'''handler for process termination'''
base_runner.Runner.terminate_all()
- if HeatStack.stacks_exist():
- print "Deleting all stacks"
- HeatStack.delete_all()
+ if len(Context.list) > 0:
+ print "Undeploying all contexts"
+ for context in Context.list:
+ context.undeploy()
-def run_one_scenario(scenario_cfg, context, output_file):
+def run_one_scenario(scenario_cfg, output_file):
'''run one scenario using context'''
key_filename = pkg_resources.resource_filename(
'yardstick.resources', 'files/yardstick_key')
- host = context.get_server(scenario_cfg["host"])
+ host = Context.get_server(scenario_cfg["host"])
runner_cfg = scenario_cfg["runner"]
runner_cfg['host'] = host.floating_ip["ipaddr"]
- runner_cfg['user'] = context.user
+ runner_cfg['user'] = host.context.user
runner_cfg['key_filename'] = key_filename
runner_cfg['output_filename'] = output_file
- target = context.get_server(scenario_cfg["target"])
+ # TODO target should be optional to support single VM scenarios
+ target = Context.get_server(scenario_cfg["target"])
if target.floating_ip:
runner_cfg['target'] = target.floating_ip["ipaddr"]
- # TODO hardcoded name below, a server can be attached to several nets
- scenario_cfg["ipaddr"] = target.ports["test"]["ipaddr"]
+ # TODO scenario_cfg["ipaddr"] is bad, "dest_ip" is better
+ if host.context != target.context:
+ # target is in another context, get its public IP
+ scenario_cfg["ipaddr"] = target.floating_ip["ipaddr"]
+ else:
+ # TODO hardcoded name below, a server can be attached to several nets
+ scenario_cfg["ipaddr"] = target.ports["test"]["ipaddr"]
runner = base_runner.Runner.get(runner_cfg)
@@ -105,17 +119,18 @@ def main():
prog_args = CmdParser().parse_args()
parser = TaskParser(prog_args.taskfile[0])
- scenarios, run_in_parallel, context = parser.parse()
+ scenarios, run_in_parallel = parser.parse()
if prog_args.parse_only:
sys.exit(0)
- context.deploy()
+ for context in Context.list:
+ context.deploy()
runners = []
if run_in_parallel:
for scenario in scenarios:
- runner = run_one_scenario(scenario, context, prog_args.output_file)
+ runner = run_one_scenario(scenario, prog_args.output_file)
runners.append(runner)
# Wait for runners to finish
@@ -125,15 +140,16 @@ def main():
else:
# run serially
for scenario in scenarios:
- runner = run_one_scenario(scenario, context, prog_args.output_file)
+ runner = run_one_scenario(scenario, prog_args.output_file)
runner_join(runner)
print "Runner ended, output in", prog_args.output_file
if prog_args.keep_deploy:
# keep deployment, forget about stack (hide it for exit handler)
- context.stack = None
+ Context.list = []
else:
- context.undeploy()
+ for context in Context.list:
+ context.undeploy()
print "Done, exiting"