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: Alina Quereilhac <alina.quereilhac@inria.fr>
20 # Example of how to run this experiment (replace with your information):
23 # python examples/linux/ping.py -a <hostname> -u <username> -i <ssh-key>
26 from nepi.execution.ec import ExperimentController
28 from optparse import OptionParser, SUPPRESS_HELP
31 usage = ("usage: %prog -a <hostanme> -u <username> -i <ssh-key>")
33 parser = OptionParser(usage = usage)
34 parser.add_option("-a", "--hostname", dest="hostname",
35 help="Remote host", type="str")
36 parser.add_option("-u", "--username", dest="username",
37 help="Username to SSH to remote host", type="str")
38 parser.add_option("-i", "--ssh-key", dest="ssh_key",
39 help="Path to private SSH key to be used for connection",
41 (options, args) = parser.parse_args()
43 hostname = options.hostname
44 username = options.username
45 ssh_key = options.ssh_key
47 ec = ExperimentController(exp_id = "ping-exp")
49 node = ec.register_resource("linux::Node")
50 ec.set(node, "hostname", hostname)
51 ec.set(node, "username", username)
52 ec.set(node, "identity", ssh_key)
53 ec.set(node, "cleanExperiment", True)
54 ec.set(node, "cleanProcesses", True)
56 app = ec.register_resource("linux::Application")
57 ec.set(app, "command", "ping -c3 nepi.inria.fr")
58 ec.register_connection(app, node)
64 print ec.trace(app, "stdout")