6b5a249be77c0fb21045429df4829fce42b89aaa
[nepi.git] / examples / linux / ping.py
1 #!/usr/bin/env python
2 #
3 #    NEPI, a framework to manage network experiments
4 #    Copyright (C) 2013 INRIA
5 #
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.
10 #
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.
15 #
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/>.
18 #
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20
21 from nepi.execution.ec import ExperimentController 
22
23 ec = ExperimentController(exp_id = "ping-exp")
24         
25 hostname = ## Add a string with the target hostname
26 username = ## Add a string with the username to SSH hostname
27
28 node = ec.register_resource("LinuxNode")
29 ec.set(node, "hostname", hostname)
30 ec.set(node, "username", username)
31 ec.set(node, "cleanHome", True)
32 ec.set(node, "cleanProcesses", True)
33
34 app = ec.register_resource("LinuxApplication")
35 ec.set(app, "command", "ping -c3 www.google.com")
36 ec.register_connection(app, node)
37
38 ec.deploy()
39
40 ec.wait_finished(app)
41
42 print ec.trace(app, "stdout")
43
44 ec.shutdown()