2 NEPI, a framework to manage network experiments
3 Copyright (C) 2013 INRIA
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
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>
19 Julien Tribino <julien.tribino@inria.fr>
25 from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
26 from nepi.execution.ec import ExperimentController
29 ec = ExperimentController()
31 # Create and Configure the Nodes
33 node1 = ec.register_resource("OMFNode")
34 ec.set(node1, 'hostname', 'wlab12')
35 ec.set(node1, 'xmppServer', "xmpp-plexus.onelab.eu")
36 ec.set(node1, 'xmppUser', "nepi")
37 ec.set(node1, 'xmppPort', "5222")
38 ec.set(node1, 'xmppPassword', "1234")
40 iface1 = ec.register_resource("OMFWifiInterface")
41 ec.set(iface1, 'name', 'wlan0')
42 ec.set(iface1, 'mode', "adhoc")
43 ec.set(iface1, 'hw_mode', "g")
44 ec.set(iface1, 'essid', "ping")
45 ec.set(iface1, 'ip', "192.168.0.12/24")
47 node2 = ec.register_resource("OMFNode")
48 ec.set(node2, 'hostname', 'wlab49')
49 ec.set(node2, 'xmppServer', "xmpp-plexus.onelab.eu")
50 ec.set(node2, 'xmppUser', "nepi")
51 ec.set(node2, 'xmppPort', "5222")
52 ec.set(node2, 'xmppPassword', "1234")
54 iface2 = ec.register_resource("OMFWifiInterface")
55 ec.set(iface2, 'name', 'wlan0')
56 ec.set(iface2, 'mode', "adhoc")
57 ec.set(iface2, 'hw_mode', "g")
58 ec.set(iface2, 'essid', "ping")
59 ec.set(iface2, 'ip', "192.168.0.49/24")
61 chan = ec.register_resource("OMFChannel")
62 ec.set(chan, 'channel', "6")
64 # Create and Configure the Application
65 app1 = ec.register_resource("OMFApplication")
66 ec.set(app1, 'command', '/bin/ping -c5 192.168.0.49')
67 ec.set(app1, 'env', "")
69 app2 = ec.register_resource("OMFApplication")
70 ec.set(app2, 'command', '/bin/ping -c5 192.168.0.12')
71 ec.set(app2, 'env', "")
75 ec.register_connection(iface1, node1)
76 ec.register_connection(iface2, node2)
77 ec.register_connection(iface1, chan)
78 ec.register_connection(iface2, chan)
79 ec.register_connection(app1, node1)
80 ec.register_connection(app2, node2)
82 ec.register_condition([app2], ResourceAction.START, app1, ResourceState.STARTED , "2s")
83 ec.register_condition([app1,app2], ResourceAction.STOP, app2, ResourceState.STARTED , "10s")
89 ec.wait_finished([app1,app2])
91 stdout_1 = ec.trace(app1, "stdout")
92 stdout_2 = ec.trace(app2, "stdout")
94 # Choose a directory to store the traces, by default
95 # It it the folder ehere you run Nepi.
97 f = open("app1.txt", "w")
101 g = open("app2.txt", "w")