3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 2 as
8 # published by the Free Software Foundation;
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Lucia Guevgeozian <lucia.guevgeozian_odizzio@inria.fr>
19 # Alina Quereilhac <alina.quereilhac@inria.fr>
22 # Example of how to run this experiment (replace with your information):
25 # python examples/planetlab/ping.py -s <pl-slice> -u <pl-user> -p <pl-password> -k <pl-ssh-key>
28 from nepi.execution.ec import ExperimentController
30 from optparse import OptionParser
33 usage = ("usage: %prog -s <pl-slice> -u <pl-user> -p <pl-password> "
36 parser = OptionParser(usage = usage)
37 parser.add_option("-s", "--pl-slice", dest="pl_slice",
38 help="PlanetLab slicename", type="str")
39 parser.add_option("-u", "--pl-user", dest="pl_user",
40 help="PlanetLab web username", type="str")
41 parser.add_option("-p", "--pl-password", dest="pl_password",
42 help="PlanetLab web password", type="str")
43 parser.add_option("-k", "--pl-ssh-key", dest="pl_ssh_key",
44 help="Path to private SSH key associated with the PL account",
47 (options, args) = parser.parse_args()
49 pl_slice = options.pl_slice
50 pl_ssh_key = options.pl_ssh_key
51 pl_user = options.pl_user
52 pl_password = options.pl_password
54 ## Create the experiment controller
55 ec = ExperimentController(exp_id = "pl_ping")
57 # Register a Planetlab Node with no restrictions, it can be any node
58 node = ec.register_resource("planetlab::Node")
60 # The username in this case is the slice name, the one to use for login in
61 # via ssh into PlanetLab nodes. Replace with your own slice name.
62 ec.set(node, "username", pl_slice)
63 ec.set(node, "identity", pl_ssh_key)
65 # The pluser and plpassword are the ones used to login in the PlanetLab web
66 # site. Replace with your own user and password account information.
67 ec.set(node, "pluser", pl_user)
68 ec.set(node, "plpassword", pl_password)
70 # Remove previous results
71 ec.set(node, "cleanExperiment", True)
72 ec.set(node, "cleanProcesses", True)
74 # Define a ping application
75 app = ec.register_resource("linux::Application")
76 ec.set(app, "command", "ping -c3 nepi.inria.fr")
78 # Connect the application to the node
79 ec.register_connection(node, app)
81 # Deploy the experiment:
84 # Wait until the application is finish to retrive the trace:
87 trace = ec.trace(app, "stdout")
89 print "PING outout ", trace
91 # Do the experiment controller shutdown