8bcd47f3ba91c886410c0300ccb58b63b34aee1c
[nepi.git] / examples / linux / testing / multihop_ssh.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: Lucia Guevgeozian <lucia.guevgeozian_odizzio@inria.fr>
20
21 from nepi.execution.ec import ExperimentController
22 from nepi.execution.resource import ResourceAction, ResourceState
23
24 # Create the EC
25 exp_id = "multihop_ssh"
26 ec = ExperimentController(exp_id)
27
28 # server
29 node1 = ec.register_resource("LinuxNode")
30 ec.set(node1, "hostname", "wlab29.")
31 ec.set(node1, "username", "root")
32 ec.set(node1, "gatewayUser", "etourdi")
33 ec.set(node1, "gateway", "etourdi.pl.sophia.inria.fr")
34 ec.set(node1, "cleanHome", True)
35 ec.set(node1, "cleanProcesses", True)
36
37 # client
38 node2 = ec.register_resource("LinuxNode")
39 ec.set(node2, "hostname", "wlab5.")
40 ec.set(node2, "username", "root")
41 ec.set(node2, "gatewayUser", "etourdi")
42 ec.set(node2, "gateway", "etourdi.pl.sophia.inria.fr")
43 ec.set(node2, "cleanHome", True)
44 ec.set(node2, "cleanProcesses", True)
45
46 app1 = ec.register_resource("LinuxApplication")
47 video= "../big_buck_bunny_240p_mpeg4_lq.ts"
48 ec.set(app1, "sources", video)
49 command = "cat ${SRC}/big_buck_bunny_240p_mpeg4_lq.ts| nc wlab5. 1234" 
50 ec.set(app1, "command", command)
51 ec.register_connection(app1, node1)
52
53 app2 = ec.register_resource("LinuxApplication")
54 command = "nc -dl 1234 > big_buck_copied_movie.ts"
55 ec.set(app2, "command", command)
56 ec.register_connection(app2, node2)
57
58 # Register conditions
59 ec.register_condition(app1, ResourceAction.START, app2, ResourceState.STARTED)
60
61 # Deploy
62 ec.deploy()
63
64 ec.wait_finished([app1, app2])
65
66 ec.shutdown()
67
68 # End