Fixing wrong license
[nepi.git] / examples / omf / testing / nepi_omf5_plexus_stdin.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 version 2 as
8 #    published by the Free Software Foundation;
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: Julien Tribino <julien.tribino@inria.fr>
19
20
21 """
22
23     Example :
24       - Testbed : Plexus
25       - Explanation :
26
27        Test the STDIN Message
28                    
29      Node 
30      wlab17
31      0 
32      |
33      |
34      0
35      Application CTRL_test.rb
36    
37       - Experiment:
38         * t0 : Deployment
39         * t1 : After the application started, one stdin message is sent
40         * t2 (t1 + 5s) : An other message is send
41
42 """
43
44 from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
45 from nepi.execution.ec import ExperimentController
46
47 import time
48
49 # Create the EC
50 ec = ExperimentController()
51
52 # Create and Configure the Nodes
53 node1 = ec.register_resource("omf::Node")
54 ec.set(node1, 'hostname', 'omf.plexus.wlab17')
55 ec.set(node1, 'xmppServer', "nepi")
56 ec.set(node1, 'xmppUser', "xmpp-plexus.onelab.eu")
57 ec.set(node1, 'xmppPort', "5222")
58 ec.set(node1, 'xmppPassword', "1234")
59 ec.set(node1, 'version', "5")
60
61 # Create and Configure the Application
62 app1 = ec.register_resource("omf::Application")
63 ec.set(app1, 'appid', "robot")
64 ec.set(app1, 'command', "/root/CTRL_test.rb coord.csv")
65 ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
66 ec.set(app1, 'version', "5")
67
68 # Connection
69 ec.register_connection(app1, node1)
70
71 ec.register_condition(app1, ResourceAction.STOP, app1, ResourceState.STARTED , "20s")
72
73 # Deploy
74 ec.deploy()
75
76 ec.wait_started([app1])
77 ec.set(app1, 'stdin', "xxxxxxxxxxxxxxxxx")
78
79 time.sleep(5)
80 ec.set(app1, 'stdin', "xxxxxxxxxxxxxxxxx")
81
82 ec.wait_finished([app1])
83
84 # Stop Experiment
85 ec.shutdown()