Fixing wrong license
[nepi.git] / examples / omf / testing / nepi_omf6_plexus_hostname.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: Alina Quereilhac <alina.quereilhac@inria.fr>
19 #         Julien Tribino <julien.tribino@inria.fr>
20
21 from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
22 from nepi.execution.ec import ExperimentController
23
24 # Create the EC
25 ec = ExperimentController()
26
27 # Create and Configure the Nodes
28
29 node1 = ec.register_resource("omf::Node")
30 ec.set(node1, 'hostname', 'wlab12')
31 ec.set(node1, 'xmppServer', "xmpp-plexus.onelab.eu")
32 ec.set(node1, 'xmppUser', "nepi")
33 ec.set(node1, 'xmppPort', "5222")
34 ec.set(node1, 'xmppPassword', "1234")
35
36 # Create and Configure the Application
37 app1 = ec.register_resource("omf::Application")
38 ec.set(app1, 'command', '/bin/hostname -f')
39 ec.set(app1, 'env', "")
40
41 app2 = ec.register_resource("omf::Application")
42 ec.set(app2, 'command', '/bin/date')
43 ec.set(app2, 'env', "")
44
45 app3 = ec.register_resource("omf::Application")
46 ec.set(app3, 'command', '/bin/hostname -f')
47 ec.set(app3, 'env', "")
48
49 # Connection
50 ec.register_connection(app1, node1)
51 ec.register_connection(app2, node1)
52 ec.register_connection(app3, node1)
53
54 ec.register_condition([app2,app3], ResourceAction.START, app1, ResourceState.STARTED , "3s")
55 ec.register_condition([app1,app2,app3], ResourceAction.STOP, app2, ResourceState.STARTED , "5s")
56
57
58 # Deploy
59 ec.deploy()
60
61 ec.wait_finished([app1,app2,app3])
62
63 # Stop Experiment
64 ec.shutdown()
65