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>
24 from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
25 from nepi.execution.ec import ExperimentController
28 ec = ExperimentController()
31 # Create and Configure the Nodes
32 node1 = ec.register_resource("OMFNode")
33 ec.set(node1, 'hostname', 'omf.nitos.node0XX')
34 ec.set(node1, 'xmppSlice', "ZZZ")
35 ec.set(node1, 'xmppHost', "nitlab.inf.uth.gr")
36 ec.set(node1, 'xmppPort', "5222")
37 ec.set(node1, 'xmppPassword', "1234")
39 node2 = ec.register_resource("OMFNode")
40 ec.set(node2, 'hostname', "omf.nitos.node0YY")
41 ec.set(node2, 'xmppSlice', "ZZZ")
42 ec.set(node2, 'xmppHost', "nitlab.inf.uth.gr")
43 ec.set(node2, 'xmppPort', "5222")
44 ec.set(node2, 'xmppPassword', "1234")
46 # Create and Configure the Interfaces
47 iface1 = ec.register_resource("OMFWifiInterface")
48 ec.set(iface1, 'alias', "w0")
49 ec.set(iface1, 'mode', "adhoc")
50 ec.set(iface1, 'type', "g")
51 ec.set(iface1, 'essid', "vlcexp")
52 ec.set(iface1, 'ip', "192.168.0.XX")
53 ec.set(iface1, 'xmppSlice', "ZZZ")
54 ec.set(iface1, 'xmppHost', "nitlab.inf.uth.gr")
55 ec.set(iface1, 'xmppPort', "5222")
56 ec.set(iface1, 'xmppPassword', "1234")
58 iface2 = ec.register_resource("OMFWifiInterface")
59 ec.set(iface2, 'alias', "w0")
60 ec.set(iface2, 'mode', "adhoc")
61 ec.set(iface2, 'type', 'g')
62 ec.set(iface2, 'essid', "vlcexp")
63 ec.set(iface2, 'ip', "192.168.0.YY")
64 ec.set(iface2, 'xmppSlice', "ZZZ")
65 ec.set(iface2, 'xmppHost', "nitlab.inf.uth.gr")
66 ec.set(iface2, 'xmppPort', "5222")
67 ec.set(iface2, 'xmppPassword', "1234")
69 # Create and Configure the Channel
70 channel = ec.register_resource("OMFChannel")
71 ec.set(channel, 'channel', "6")
72 ec.set(channel, 'xmppSlice', "ZZZ")
73 ec.set(channel, 'xmppHost', "nitlab.inf.uth.gr")
74 ec.set(channel, 'xmppPort', "5222")
75 ec.set(channel, 'xmppPassword', "1234")
77 # Create and Configure the Application
78 app1 = ec.register_resource("OMFApplication")
79 ec.set(app1, 'appid', 'Vlc#1')
80 ec.set(app1, 'path', "/root/vlc-1.1.13/cvlc")
81 ec.set(app1, 'args', "/root/10-by-p0d.avi --sout '#rtp{dst=192.168.0.YY,port=1234,mux=ts}'")
82 ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
83 ec.set(app1, 'xmppSlice', "ZZZ")
84 ec.set(app1, 'xmppHost', "nitlab.inf.uth.gr")
85 ec.set(app1, 'xmppPort', "5222")
86 ec.set(app1, 'xmppPassword', "1234")
88 app2 = ec.register_resource("OMFApplication")
89 ec.set(app2, 'appid', 'Vlc#2')
90 ec.set(app2, 'path', "/root/vlc-1.1.13/cvlc")
91 ec.set(app2, 'args', "rtp://192.168.0.YY:1234")
92 ec.set(app2, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
93 ec.set(app2, 'xmppSlice', "ZZZ")
94 ec.set(app2, 'xmppHost', "nitlab.inf.uth.gr")
95 ec.set(app2, 'xmppPort', "5222")
96 ec.set(app2, 'xmppPassword', "1234")
98 app3 = ec.register_resource("OMFApplication")
99 ec.set(app3, 'appid', 'Kill#2')
100 ec.set(app3, 'path', "/usr/bin/killall")
101 ec.set(app3, 'args', "vlc_app")
102 ec.set(app3, 'env', " ")
103 ec.set(app3, 'xmppSlice', "ZZZ")
104 ec.set(app3, 'xmppHost', "nitlab.inf.uth.gr")
105 ec.set(app3, 'xmppPort', "5222")
106 ec.set(app3, 'xmppPassword', "1234")
108 app4 = ec.register_resource("OMFApplication")
109 ec.set(app4, 'appid', 'Kill#1')
110 ec.set(app4, 'path', "/usr/bin/killall")
111 ec.set(app4, 'args', "vlc_app")
112 ec.set(app4, 'env', " ")
113 ec.set(app4, 'xmppSlice', "ZZZ")
114 ec.set(app4, 'xmppHost', "nitlab.inf.uth.gr")
115 ec.set(app4, 'xmppPort', "5222")
116 ec.set(app4, 'xmppPassword', "1234")
119 ec.register_connection(app3, node1)
120 ec.register_connection(app1, node1)
121 ec.register_connection(node1, iface1)
122 ec.register_connection(iface1, channel)
123 ec.register_connection(iface2, channel)
124 ec.register_connection(node2, iface2)
125 ec.register_connection(app2, node2)
126 ec.register_connection(app4, node2)
129 ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "4s")
130 ec.register_condition([app1, app2], ResourceAction.STOP, app2, ResourceState.STARTED , "22s")
131 ec.register_condition([app3, app4], ResourceAction.START, app2, ResourceState.STARTED , "25s")
132 ec.register_condition([app3, app4], ResourceAction.STOP, app3, ResourceState.STARTED , "1s")
137 ec.wait_finished([app1, app2, app3, app4])