11890bb5b03e2c9514c47dafa9f47c14690a8914
[nepi.git] / examples / omf / testing / nepi_omf6_nitos_vlc.py
1 """
2     NEPI, a framework to manage network experiments
3     Copyright (C) 2013 INRIA
4
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.
9
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.
14
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/>.
17
18     Author: Alina Quereilhac <alina.quereilhac@inria.fr>
19             Julien Tribino <julien.tribino@inria.fr>
20
21
22 """
23
24 #!/usr/bin/env python
25 from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
26 from nepi.execution.ec import ExperimentController
27
28 # Create the EC
29 ec = ExperimentController()
30
31 # Create and Configure the Nodes
32
33 node1 = ec.register_resource("omf::Node")
34 ec.set(node1, 'hostname', 'node025')
35 ec.set(node1, 'xmppServer', "nitlab.inf.uth.gr")
36 ec.set(node1, 'xmppUser', "nepi")
37 ec.set(node1, 'xmppPort', "5222")
38 ec.set(node1, 'xmppPassword', "1234")
39
40 iface1 = ec.register_resource("omf::WifiInterface")
41 ec.set(iface1, 'name', 'wlan0')
42 ec.set(iface1, 'mode', "adhoc")
43 ec.set(iface1, 'hw_mode', "g")
44 ec.set(iface1, 'essid', "vlc")
45 ec.set(iface1, 'ip', "192.168.0.25/24")
46
47 node2 = ec.register_resource("omf::Node")
48 ec.set(node2, 'hostname', 'node027')
49 ec.set(node2, 'xmppServer', "nitlab.inf.uth.gr")
50 ec.set(node2, 'xmppUser', "nepi")
51 ec.set(node2, 'xmppPort', "5222")
52 ec.set(node2, 'xmppPassword', "1234")
53
54 iface2 = ec.register_resource("omf::WifiInterface")
55 ec.set(iface2, 'name', 'wlan0')
56 ec.set(iface2, 'mode', "adhoc")
57 ec.set(iface2, 'hw_mode', "g")
58 ec.set(iface2, 'essid', "vlc")
59 ec.set(iface2, 'ip', "192.168.0.27/24")
60
61 chan = ec.register_resource("omf::Channel")
62 ec.set(chan, 'channel', "6")
63
64 # Create and Configure the Application
65 app1 = ec.register_resource("omf::Application")
66 ec.set(app1, 'command', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc /root/10-by-p0d.avi --sout '#rtp{dst=192.168.0.27,port=1234,mux=ts}'")
67
68 app2 = ec.register_resource("omf::Application")
69 ec.set(app2, 'command', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc rtp://192.168.0.27:1234")
70
71
72 # Connection
73 ec.register_connection(iface1, node1)
74 ec.register_connection(iface2, node2)
75 ec.register_connection(iface1, chan)
76 ec.register_connection(iface2, chan)
77 ec.register_connection(app1, node1)
78 ec.register_connection(app2, node2)
79
80 ec.register_condition([app2], ResourceAction.START, app1, ResourceState.STARTED , "4s")
81 ec.register_condition([app1,app2], ResourceAction.STOP, app2, ResourceState.STARTED , "30s")
82
83
84 # Deploy
85 ec.deploy()
86
87 ec.wait_finished([app1,app2])
88
89 # Stop Experiment
90 ec.shutdown()
91