Add 'nodes' attribute to the scenario definition
[yardstick.git] / yardstick / cmd / commands / task.py
index 0d7e9e6..d6cd698 100755 (executable)
@@ -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()