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/>.
21 from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
22 from nepi.execution.ec import ExperimentController
24 from nepi.resources.omf.node import OMFNode
25 from nepi.resources.omf.application import OMFApplication
26 from nepi.resources.omf.interface import OMFWifiInterface
27 from nepi.resources.omf.channel import OMFChannel
35 ec = ExperimentController()
37 # Register the different RM that will be used
38 ResourceFactory.register_type(OMFNode)
39 ResourceFactory.register_type(OMFWifiInterface)
40 ResourceFactory.register_type(OMFChannel)
41 ResourceFactory.register_type(OMFApplication)
43 # Create and Configure the Nodes
44 node1 = ec.register_resource("OMFNode")
45 ec.set(node1, 'hostname', 'omf.plexus.wlab17')
46 ec.set(node1, 'xmppSlice', "nepi")
47 ec.set(node1, 'xmppHost', "xmpp-plexus.onelab.eu")
48 ec.set(node1, 'xmppPort', "5222")
49 ec.set(node1, 'xmppPassword', "1234")
51 node2 = ec.register_resource("OMFNode")
52 ec.set(node2, 'hostname', "omf.plexus.wlab37")
53 ec.set(node2, 'xmppSlice', "nepi")
54 ec.set(node2, 'xmppHost', "xmpp-plexus.onelab.eu")
55 ec.set(node2, 'xmppPort', "5222")
56 ec.set(node2, 'xmppPassword', "1234")
58 # Create and Configure the Interfaces
59 iface1 = ec.register_resource("OMFWifiInterface")
60 ec.set(iface1, 'alias', "w0")
61 ec.set(iface1, 'mode', "adhoc")
62 ec.set(iface1, 'type', "g")
63 ec.set(iface1, 'essid', "vlcexp")
64 #ec.set(iface1, 'ap', "11:22:33:44:55:66")
65 ec.set(iface1, 'ip', "10.0.0.17")
66 ec.set(iface1, 'xmppSlice', "nepi")
67 ec.set(iface1, 'xmppHost', "xmpp-plexus.onelab.eu")
68 ec.set(iface1, 'xmppPort', "5222")
69 ec.set(iface1, 'xmppPassword', "1234")
71 iface2 = ec.register_resource("OMFWifiInterface")
72 ec.set(iface2, 'alias', "w0")
73 ec.set(iface2, 'mode', "adhoc")
74 ec.set(iface2, 'type', 'g')
75 ec.set(iface2, 'essid', "vlcexp")
76 #ec.set(iface2, 'ap', "11:22:33:44:55:66")
77 ec.set(iface2, 'ip', "10.0.0.37")
78 ec.set(iface2, 'xmppSlice', "nepi")
79 ec.set(iface2, 'xmppHost', "xmpp-plexus.onelab.eu")
80 ec.set(iface2, 'xmppPort', "5222")
81 ec.set(iface2, 'xmppPassword', "1234")
83 # Create and Configure the Channel
84 channel = ec.register_resource("OMFChannel")
85 ec.set(channel, 'channel', "6")
86 ec.set(channel, 'xmppSlice', "nepi")
87 ec.set(channel, 'xmppHost', "xmpp-plexus.onelab.eu")
88 ec.set(channel, 'xmppPort', "5222")
89 ec.set(channel, 'xmppPassword', "1234")
91 # Create and Configure the Application
92 app1 = ec.register_resource("OMFApplication")
93 ec.set(app1, 'appid', 'Vlc#1')
94 ec.set(app1, 'path', "/opt/vlc-1.1.13/cvlc")
95 ec.set(app1, 'args', "/opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
96 ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
97 ec.set(app1, 'xmppSlice', "nepi")
98 ec.set(app1, 'xmppHost', "xmpp-plexus.onelab.eu")
99 ec.set(app1, 'xmppPort', "5222")
100 ec.set(app1, 'xmppPassword', "1234")
102 app2 = ec.register_resource("OMFApplication")
103 ec.set(app2, 'appid', 'Vlc#2')
104 ec.set(app2, 'path', "/opt/vlc-1.1.13/cvlc")
105 ec.set(app2, 'args', "rtp://10.0.0.37:1234")
106 ec.set(app2, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
107 ec.set(app2, 'xmppSlice', "nepi")
108 ec.set(app2, 'xmppHost', "xmpp-plexus.onelab.eu")
109 ec.set(app2, 'xmppPort', "5222")
110 ec.set(app2, 'xmppPassword', "1234")
112 app3 = ec.register_resource("OMFApplication")
113 ec.set(app3, 'appid', 'Kill#2')
114 ec.set(app3, 'path', "/usr/bin/killall")
115 ec.set(app3, 'args', "vlc")
116 ec.set(app3, 'env', " ")
117 ec.set(app3, 'xmppSlice', "nepi")
118 ec.set(app3, 'xmppHost', "xmpp-plexus.onelab.eu")
119 ec.set(app3, 'xmppPort', "5222")
120 ec.set(app3, 'xmppPassword', "1234")
123 ec.register_connection(app3, node1)
124 ec.register_connection(app1, node1)
125 ec.register_connection(node1, iface1)
126 ec.register_connection(iface1, channel)
127 ec.register_connection(iface2, channel)
128 ec.register_connection(node2, iface2)
129 ec.register_connection(app2, node2)
132 # Topology behaviour : It should not be done by the user, but ....
133 #ec.register_condition([iface1, iface2, channel], ResourceAction.START, [node1, node2], ResourceState.STARTED , 2)
134 #ec.register_condition(channel, ResourceAction.START, [iface1, iface2], ResourceState.STARTED , 1)
135 #ec.register_condition(app1, ResourceAction.START, channel, ResourceState.STARTED , 1)
138 ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "4s")
139 ec.register_condition([app1, app2], ResourceAction.STOP, app2, ResourceState.STARTED , "20s")
140 ec.register_condition(app3, ResourceAction.START, app2, ResourceState.STARTED , "25s")