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 as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
21 # Example of how to run this experiment (replace with your information):
24 # python examples/linux/ping.py -a <hostname> -u <username> -i <ssh-key>
27 from nepi.execution.ec import ExperimentController
29 from optparse import OptionParser, SUPPRESS_HELP
32 usage = ("usage: %prog -a <hostanme> -u <username> -i <ssh-key>")
34 parser = OptionParser(usage = usage)
35 parser.add_option("-a", "--hostname", dest="hostname",
36 help="Remote host", type="str")
37 parser.add_option("-u", "--username", dest="username",
38 help="Username to SSH to remote host", type="str")
39 parser.add_option("-i", "--ssh-key", dest="ssh_key",
40 help="Path to private SSH key to be used for connection",
42 (options, args) = parser.parse_args()
44 hostname = options.hostname
45 username = options.username
46 ssh_key = options.ssh_key
48 ec = ExperimentController(exp_id = "ping-exp")
50 node = ec.register_resource("LinuxNode")
51 ec.set(node, "hostname", hostname)
52 ec.set(node, "username", username)
53 ec.set(node, "identity", ssh_key)
54 ec.set(node, "cleanHome", True)
55 ec.set(node, "cleanProcesses", True)
57 app = ec.register_resource("LinuxApplication")
58 ec.set(app, "command", "ping -c3 nepi.inria.fr")
59 ec.register_connection(app, node)
65 print ec.trace(app, "stdout")