From 04b471c90f38afe8dc0018f1b2c4e5d3dc9f4384 Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Sun, 18 Jan 2015 20:13:50 +0100 Subject: [PATCH] omf bootstrap --- .../{linux => omf}/nitos_testbed_bootstrap.py | 50 +++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) rename examples/{linux => omf}/nitos_testbed_bootstrap.py (63%) diff --git a/examples/linux/nitos_testbed_bootstrap.py b/examples/omf/nitos_testbed_bootstrap.py similarity index 63% rename from examples/linux/nitos_testbed_bootstrap.py rename to examples/omf/nitos_testbed_bootstrap.py index ad44d126..34d2e3f8 100644 --- a/examples/linux/nitos_testbed_bootstrap.py +++ b/examples/omf/nitos_testbed_bootstrap.py @@ -27,11 +27,13 @@ # Example of how to run this experiment (replace with your information): # # $ cd -# python examples/linux/nitos_testbed_bootstrap.py -H -u -i -g -U +# python examples/linux/nitos_testbed_bootstrap.py -H -u -i -g -U # from nepi.execution.ec import ExperimentController -from optparse import OptionParser, SUPPRESS_HELP +from nepi.execution.resource import ResourceAction, ResourceState + +from optparse import OptionParser import os usage = ("usage: %prog -H -u -i -g -U ") @@ -53,34 +55,64 @@ parser.add_option("-i", "--ssh-key", dest="ssh_key", type="str") (options, args) = parser.parse_args() -hosts = options.hosts.split(" ") +hosts = options.hosts username = options.username gateway = options.gateway gateway_username = options.gateway_username -ssh_key = options.ssh_key +identity = options.ssh_key apps = [] -ec = ExperimentController(exp_id="ath5k") +ec = ExperimentController(exp_id="nitos_bootstrap") + +gw_node = ec.register_resource("linux::Node") +ec.set(gw_node, "username", gateway_username) +ec.set(gw_node, "hostname", gateway) +ec.set(gw_node, "identity", identity) +ec.set(gw_node, "cleanExperiment", True) + +load_cmd = "omf load -i nepi_OMF6_VLC_baseline_grid.ndz -t %s" % hosts +load_app = ec.register_resource("linux::Application") +ec.set(load_app, "command", load_cmd) +ec.register_connection(load_app, gw_node) + +reboot_cmd = "omf tell -a on -t %s" % hosts +reboot_app = ec.register_resource("linux::Application") +ec.set(reboot_app, "command", reboot_cmd) +ec.register_connection(reboot_app, gw_node) + +ec.register_condition(reboot_app, ResourceAction.START, load_app, + ResourceState.STOPPED, time="20s") + +hosts = hosts.split(",") for hostname in hosts: + host = hostname.split(".")[-1] node = ec.register_resource("linux::Node") ec.set(node, "username", username) - ec.set(node, "hostname", hostname) + ec.set(node, "hostname", host) + ec.set(node, "identity", identity) ec.set(node, "gateway", gateway) ec.set(node, "gatewayUser", gateway_username) ec.set(node, "cleanExperiment", True) - + ec.register_condition(node, ResourceAction.DEPLOY, reboot_app, + ResourceState.STOPPED, time="30s") + app = ec.register_resource("linux::Application") ec.set(app, "command", "modprobe ath5k && ip a | grep wlan0 && service omf_rc restart") ec.register_connection(app, node) apps.append(app) -ec.deploy() +ec.deploy(wait_all_ready=False) + ec.wait_finished(apps) +print ec.trace(load_app, "stdout") +print ec.trace(reboot_app, "stdout") + for app in apps: - print ec.trace(app, "stdout") + print ec.trace(app, "stdout") +ec.shutdown() -- 2.43.0