X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=examples%2Fomf%2Fnitos_testbed_bootstrap.py;h=6d70818d44b7cd99a2dc9c9d8adc336cff4c3677;hb=039fbd9629d7570d4c175a5448d24badcd0f3aba;hp=014d3eb6db281ab4249770a6a3ce225e49f91d71;hpb=9908367cf532a7bac74288c23c2024dacb3683c8;p=nepi.git
diff --git a/examples/omf/nitos_testbed_bootstrap.py b/examples/omf/nitos_testbed_bootstrap.py
index 014d3eb6..6d70818d 100644
--- a/examples/omf/nitos_testbed_bootstrap.py
+++ b/examples/omf/nitos_testbed_bootstrap.py
@@ -1,124 +1,126 @@
-#!/usr/bin/env python
-#
-# NEPI, a framework to manage network experiments
-# Copyright (C) 2013 INRIA
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation;
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-#
-# Author: Alina Quereilhac
-# Maksym Gabielkov
-#
-
-## This is a maintenance script used to bootstrap the nodes from
-## Nitos testbed (NITLab) before running a OMF experiment using
-## Nitos nodes. This fixes the problem of Resource Controller
-## misbehaving by restarting it and it also loads the ath5k driver.
-
-# Example of how to run this experiment (replace with your information):
-#
-# $ cd
-# python examples/linux/nitos_testbed_bootstrap.py -H -U -i -g -u
-#
-
-from nepi.execution.ec import ExperimentController
-from nepi.execution.resource import ResourceAction, ResourceState
-
-from optparse import OptionParser
-import os
-
-usage = ("usage: %prog -H -U -i -g -u ")
-
-parser = OptionParser(usage = usage)
-parser.add_option("-H", "--hosts", dest="hosts",
- help="Space separated list of hosts", type="str")
-parser.add_option("-U", "--username", dest="username",
- help="Username for the nitos hosts (usually root)",
- type="str", default="root" )
-parser.add_option("-g", "--gateway", dest="gateway",
- help="Nitos gateway hostname",
- type="str", default="nitlab.inf.uth.gr")
-parser.add_option("-u", "--gateway-user", dest="gateway_username",
- help="Nitos gateway username (slicename)",
- type="str", default="nitlab.inf.uth.gr")
-parser.add_option("-i", "--ssh-key", dest="ssh_key",
- help="Path to private SSH key to be used for connection",
- type="str")
-(options, args) = parser.parse_args()
-
-hosts = options.hosts
-username = options.username
-gateway = options.gateway
-gateway_username = options.gateway_username
-identity = options.ssh_key
-
-apps = []
-
-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="60s")
-
-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", 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="300s")
-
- modprobe_app = ec.register_resource("linux::Application")
- ec.set(modprobe_app, "command", "modprobe ath5k && ip a | grep wlan0")
- ec.register_connection(modprobe_app, node)
- apps.append(modprobe_app)
-
- rc_app = ec.register_resource("linux::Application")
- ec.set(rc_app, "command", "service omf_rc stop; service omf_rc start")
- ec.register_connection(rc_app, node)
- apps.append(rc_app)
-
-print "This might take time..."
-
-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")
-
-ec.shutdown()
-
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation;
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+# Author: Alina Quereilhac
+# Maksym Gabielkov
+#
+
+## This is a maintenance script used to bootstrap the nodes from
+## Nitos testbed (NITLab) before running a OMF experiment using
+## Nitos nodes. This fixes the problem of Resource Controller
+## misbehaving by restarting it and it also loads the ath5k driver.
+
+# Example of how to run this experiment (replace with your information):
+#
+# $ cd
+# python examples/linux/nitos_testbed_bootstrap.py -H -U -i -g -u
+#
+
+from __future__ import print_function
+
+from nepi.execution.ec import ExperimentController
+from nepi.execution.resource import ResourceAction, ResourceState
+
+from optparse import OptionParser
+import os
+
+usage = ("usage: %prog -H -U -i -g -u ")
+
+parser = OptionParser(usage = usage)
+parser.add_option("-H", "--hosts", dest="hosts",
+ help="Space separated list of hosts", type="str")
+parser.add_option("-U", "--username", dest="username",
+ help="Username for the nitos hosts (usually root)",
+ type="str", default="root" )
+parser.add_option("-g", "--gateway", dest="gateway",
+ help="Nitos gateway hostname",
+ type="str", default="nitlab.inf.uth.gr")
+parser.add_option("-u", "--gateway-user", dest="gateway_username",
+ help="Nitos gateway username (slicename)",
+ type="str", default="nitlab.inf.uth.gr")
+parser.add_option("-i", "--ssh-key", dest="ssh_key",
+ help="Path to private SSH key to be used for connection",
+ type="str")
+(options, args) = parser.parse_args()
+
+hosts = options.hosts
+username = options.username
+gateway = options.gateway
+gateway_username = options.gateway_username
+identity = options.ssh_key
+
+apps = []
+
+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="60s")
+
+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", 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="300s")
+
+ modprobe_app = ec.register_resource("linux::Application")
+ ec.set(modprobe_app, "command", "modprobe ath5k && ip a | grep wlan0")
+ ec.register_connection(modprobe_app, node)
+ apps.append(modprobe_app)
+
+ rc_app = ec.register_resource("linux::Application")
+ ec.set(rc_app, "command", "service omf_rc stop; service omf_rc start")
+ ec.register_connection(rc_app, node)
+ apps.append(rc_app)
+
+print("This might take time...")
+
+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"))
+
+ec.shutdown()
+