Fixing comment in example
[nepi.git] / examples / omf / nitos_testbed_bootstrap.py
index 34d2e3f..014d3eb 100644 (file)
@@ -1,11 +1,11 @@
+#!/usr/bin/env python\r
 #\r
 #    NEPI, a framework to manage network experiments\r
-#    Copyright (C) 2014 INRIA\r
+#    Copyright (C) 2013 INRIA\r
 #\r
 #    This program is free software: you can redistribute it and/or modify\r
-#    it under the terms of the GNU General Public License as published by\r
-#    the Free Software Foundation, either version 3 of the License, or\r
-#    (at your option) any later version.\r
+#    it under the terms of the GNU General Public License version 2 as\r
+#    published by the Free Software Foundation;\r
 #\r
 #    This program is distributed in the hope that it will be useful,\r
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
@@ -27,7 +27,7 @@
 # Example of how to run this experiment (replace with your information):\r
 #\r
 # $ cd <path-to-nepi>\r
-# python examples/linux/nitos_testbed_bootstrap.py -H <omf.nitos.node0XX,omf.nitos.node0ZZ,..> -u <nitos-username> -i <ssh-key> -g <nitos-gateway> -U <nitos-gateway-username>\r
+# python examples/linux/nitos_testbed_bootstrap.py -H <omf.nitos.node0XX,omf.nitos.node0ZZ,..> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <nitos-slice>\r
 #\r
 \r
 from nepi.execution.ec import ExperimentController\r
@@ -36,19 +36,19 @@ from nepi.execution.resource import ResourceAction, ResourceState
 from optparse import OptionParser\r
 import os\r
 \r
-usage = ("usage: %prog -H <list-of-nitos-hosts> -u <nitos-username> -i <ssh-key> -g <nitos-gateway> -U <nitos-gateway-username>")\r
+usage = ("usage: %prog -H <list-of-nitos-hosts> -U <node-username> -i <ssh-key> -g <nitos-gateway> -u <slicename>")\r
 \r
 parser = OptionParser(usage = usage)\r
 parser.add_option("-H", "--hosts", dest="hosts", \r
         help="Space separated list of hosts", type="str")\r
-parser.add_option("-u", "--username", dest="username", \r
+parser.add_option("-U", "--username", dest="username", \r
         help="Username for the nitos hosts (usually root)", \r
         type="str", default="root" )\r
 parser.add_option("-g", "--gateway", dest="gateway", \r
         help="Nitos gateway hostname", \r
         type="str", default="nitlab.inf.uth.gr")\r
-parser.add_option("-U", "--gateway-user", dest="gateway_username", \r
-        help="Nitos gateway username", \r
+parser.add_option("-u", "--gateway-user", dest="gateway_username", \r
+        help="Nitos gateway username (slicename)", \r
         type="str", default="nitlab.inf.uth.gr")\r
 parser.add_option("-i", "--ssh-key", dest="ssh_key", \r
         help="Path to private SSH key to be used for connection", \r
@@ -82,7 +82,7 @@ ec.set(reboot_app, "command", reboot_cmd)
 ec.register_connection(reboot_app, gw_node)\r
 \r
 ec.register_condition(reboot_app, ResourceAction.START, load_app, \r
-            ResourceState.STOPPED, time="20s") \r
+            ResourceState.STOPPED, time="60s") \r
 \r
 hosts = hosts.split(",")\r
 \r
@@ -96,13 +96,19 @@ for hostname in hosts:
     ec.set(node, "gatewayUser", gateway_username)\r
     ec.set(node, "cleanExperiment", True)\r
     ec.register_condition(node, ResourceAction.DEPLOY, reboot_app, \r
-            ResourceState.STOPPED, time="30s") \r
+            ResourceState.STOPPED, time="300s") \r
  \r
-    app = ec.register_resource("linux::Application")\r
-    ec.set(app, "command", "modprobe ath5k && ip a | grep wlan0 && service omf_rc restart")\r
-    ec.register_connection(app, node)\r
-   \r
-    apps.append(app)\r
+    modprobe_app = ec.register_resource("linux::Application")\r
+    ec.set(modprobe_app, "command", "modprobe ath5k && ip a | grep wlan0")\r
+    ec.register_connection(modprobe_app, node)\r
+    apps.append(modprobe_app)\r
+\r
+    rc_app = ec.register_resource("linux::Application")\r
+    ec.set(rc_app, "command", "service omf_rc stop; service omf_rc start")\r
+    ec.register_connection(rc_app, node)\r
+    apps.append(rc_app)\r
+\r
+print "This might take time..."\r
 \r
 ec.deploy(wait_all_ready=False)\r
 \r