From 2708ea7280b51bffb71093384dc49664c5440034 Mon Sep 17 00:00:00 2001 From: wym_libra Date: Tue, 8 Dec 2015 15:47:26 +0800 Subject: Add 'nodes' attribute to the scenario definition Defining the 'nodes' attribute which can include more node not only 'host' and 'target' Design etherpad link: https://etherpad.opnfv.org/p/yardstick_framework JIRA:- Change-Id: Ida18ebcda1c73c88d208aa11a10696d1063134ef Signed-off-by: wym_libra --- yardstick/cmd/commands/task.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'yardstick/cmd') diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index 0d7e9e66d..d6cd6984c 100755 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py @@ -287,7 +287,8 @@ def run_one_scenario(scenario_cfg, output_file): # TODO support get multi hosts/vms info context_cfg = {} - context_cfg['host'] = Context.get_server(scenario_cfg["host"]) + if "host" in scenario_cfg: + context_cfg['host'] = Context.get_server(scenario_cfg["host"]) if "target" in scenario_cfg: if is_ip_addr(scenario_cfg["target"]): @@ -303,6 +304,8 @@ def run_one_scenario(scenario_cfg, output_file): context_cfg["target"]["ipaddr"] = \ context_cfg["target"]["ip"] + if "nodes" in scenario_cfg: + context_cfg["nodes"] = parse_nodes_with_context(scenario_cfg) runner = base_runner.Runner.get(runner_cfg) print "Starting runner of type '%s'" % runner_cfg["type"] @@ -311,6 +314,17 @@ def run_one_scenario(scenario_cfg, output_file): return runner +def parse_nodes_with_context(scenario_cfg): + '''paras the 'nodes' fields in scenario ''' + nodes = scenario_cfg["nodes"] + + nodes_cfg = {} + for nodename in nodes: + nodes_cfg[nodename] = Context.get_server(nodes[nodename]) + + return nodes_cfg + + def runner_join(runner): '''join (wait for) a runner, exit process at runner failure''' status = runner.join() -- cgit 1.2.3-korg