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