Planetlab examples
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Tue, 16 Sep 2014 16:00:15 +0000 (18:00 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Tue, 16 Sep 2014 16:00:15 +0000 (18:00 +0200)
examples/planetlab/ccn_simple_transfer.py [moved from examples/planetlab/ccn/two_nodes_file_retrieval.py with 100% similarity]
examples/planetlab/ping.py [moved from examples/planetlab/ping_experiment.py with 52% similarity]
examples/planetlab/select_nodes.py
examples/planetlab/testing/blacklist.py [moved from examples/planetlab/blacklist.py with 100% similarity]
examples/planetlab/testing/scalability.py [moved from examples/planetlab/scalability.py with 100% similarity]

similarity index 52%
rename from examples/planetlab/ping_experiment.py
rename to examples/planetlab/ping.py
index 4a693fd..e36ba61 100644 (file)
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 # Author: Lucia Guevgeozian <lucia.guevgeozian_odizzio@inria.fr>
+#         Alina Quereilhac <alina.quereilhac@inria.fr>
+#
+
+# Example of how to run this experiment (replace with your information):
+#
+# $ cd <path-to-nepi>
+# python examples/planetlab/ping.py -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key>  
+
 
 from nepi.execution.ec import ExperimentController
-from nepi.execution.resource import ResourceAction, ResourceState
 
+from optparse import OptionParser
 import os
 
-exp_id = "ping_exp"
+usage = ("usage: %prog -s <pl-slice> -u <pl-user> -p <pl-password> "
+     "-k <pl-ssh-key>")
+
+parser = OptionParser(usage = usage)
+parser.add_option("-s", "--pl-slice", dest="pl_slice",
+        help="PlanetLab slicename", type="str")
+parser.add_option("-u", "--pl-user", dest="pl_user",
+        help="PlanetLab web username", type="str")
+parser.add_option("-p", "--pl-password", dest="pl_password",
+        help="PlanetLab web password", type="str")
+parser.add_option("-k", "--pl-ssh-key", dest="pl_ssh_key",
+        help="Path to private SSH key associated with the PL account",
+        type="str")
 
-# Create the entity Experiment Controller:
-ec = ExperimentController(exp_id)
+(options, args) = parser.parse_args()
 
-# Register the nodes resources:
+pl_slice = options.pl_slice
+pl_ssh_key = options.pl_ssh_key
+pl_user = options.pl_user
+pl_password = options.pl_password
+
+## Create the experiment controller
+ec = ExperimentController(exp_id = "pl_ping")
+
+# Register a Planetlab Node with no restrictions, it can be any node
+node = ec.register_resource("PlanetlabNode")
 
 # The username in this case is the slice name, the one to use for login in 
 # via ssh into PlanetLab nodes. Replace with your own slice name.
-username = "inria_sfatest"
+ec.set(node, "username", pl_slice)
+ec.set(node, "identity", pl_ssh_key)
 
 # The pluser and plpassword are the ones used to login in the PlanetLab web 
 # site. Replace with your own user and password account information.
-pl_user = "lucia.guevgeozian_odizzio@inria.fr"
-pl_password =  os.environ.get("PL_PASS")
-
-# Define a Planetlab Node with no restriction, it can be any node
-node = ec.register_resource('PlanetlabNode')
-ec.set(node, "username", username)
 ec.set(node, "pluser", pl_user)
 ec.set(node, "plpassword", pl_password)
+
+# Remove previous results
 ec.set(node, "cleanHome", True)
 ec.set(node, "cleanProcesses", True)
 
 # Define a ping application
-app = ec.register_resource('LinuxApplication')
-ec.set(app, 'command', 'ping -c5 google.com > ping_google.txt')
+app = ec.register_resource("LinuxApplication")
+ec.set(app, "command", "ping -c3 nepi.inria.fr")
 
 # Connect the application to the node
 ec.register_connection(node, app)
@@ -60,14 +85,9 @@ ec.deploy()
 # Wait until the application is finish to retrive the trace:
 ec.wait_finished(app)
 
-trace = ec.trace(app, 'ping_google.txt')
+trace = ec.trace(app, "stdout")
 
-# Choose a directory to store the traces locally, change to a convenient path for you:
-directory = "examples/planetlab/"
-trace_file = directory + "ping_google.txt"
-f = open(trace_file, "w")
-f.write(trace)
-f.close()
+print "PING outout ", trace
 
 # Do the experiment controller shutdown:
 ec.shutdown()
index 4151932..c95ef06 100644 (file)
@@ -1,6 +1,32 @@
+#
+#    NEPI, a framework to manage network experiments
+#    Copyright (C) 2014 INRIA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+#
+
+# Example of how to run this experiment (replace with your information):
+#
+# $ cd <path-to-nepi>
+# python examples/planetlab/select_nodes.py -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key> -c <country> -o <operating-system> -n <node-count> 
+
+
 from nepi.execution.ec import ExperimentController
 
-from optparse import OptionParser, SUPPRESS_HELP
+from optparse import OptionParser
 import os
 
 usage = ("usage: %prog -s <pl-slice> -u <pl-user> -p <pl-password> "