Cleaning up examples folder
[nepi.git] / examples / linux / testing / scalability.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 as published by
8 #    the Free Software Foundation, either version 3 of the License, or
9 #    (at your option) any later version.
10 #
11 #    This program is distributed in the hope that it will be useful,
12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #    GNU General Public License for more details.
15 #
16 #    You should have received a copy of the GNU General Public License
17 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20
21 from nepi.execution.ec import ExperimentController, ECState 
22 from nepi.execution.resource import ResourceState, ResourceAction
23
24 from optparse import OptionParser, SUPPRESS_HELP
25
26 import os
27 import time
28
29 def add_node(ec, host, user):
30     node = ec.register_resource("LinuxNode")
31     ec.set(node, "hostname", host)
32     ec.set(node, "username", user)
33     ec.set(node, "cleanHome", True)
34     ec.set(node, "cleanProcesses", True)
35     return node
36
37 def add_app(ec):
38     app = ec.register_resource("LinuxApplication")
39     ec.set(app, "command", "sleep 30; echo 'HOLA'")
40     return app
41
42 def get_options():
43     slicename = os.environ.get("PL_SLICE")
44
45     usage = "usage: %prog -s <pl-slice>"
46
47     parser = OptionParser(usage=usage)
48     parser.add_option("-s", "--pl-slice", dest="pl_slice", 
49             help="PlanetLab slicename", default=slicename, type="str")
50     parser.add_option("-l", "--exp-id", dest="exp_id", 
51             help="Label to identify experiment", type="str")
52
53     (options, args) = parser.parse_args()
54
55     return (options.pl_slice, options.exp_id)
56
57 if __name__ == '__main__':
58     ( pl_slice, exp_id ) = get_options()
59
60     apps = []
61   
62     hostnames = [
63              #"planetlab-2.research.netlab.hut.fi",
64              "planetlab2.willab.fi",
65              "planetlab3.hiit.fi",
66              "planetlab4.hiit.fi",
67              "planetlab1.willab.fi",
68              "planetlab1.s3.kth.se",
69              "itchy.comlab.bth.se",
70              "planetlab-1.ida.liu.se",
71              "planetlab2.s3.kth.se",
72              "planetlab1.sics.se",
73              #"planetlab1.tlm.unavarra.es",
74              #"planetlab2.uc3m.es",
75              #"planetlab1.uc3m.es",
76              #"planetlab2.um.es",
77              "planet1.servers.ua.pt",
78              #"planetlab2.fct.ualg.pt",
79              "planetlab-1.tagus.ist.utl.pt",
80              "planetlab-2.tagus.ist.utl.pt",
81              "planetlab-um00.di.uminho.pt",
82              "planet2.servers.ua.pt",
83              "planetlab1.mini.pw.edu.pl",
84              "roti.mimuw.edu.pl",
85              "planetlab1.ci.pwr.wroc.pl",
86              "planetlab1.pjwstk.edu.pl",
87              "ple2.tu.koszalin.pl",
88              "planetlab2.ci.pwr.wroc.pl",
89              #"planetlab2.cyfronet.pl",
90              "plab2.ple.silweb.pl",
91              #"planetlab1.cyfronet.pl",
92              "plab4.ple.silweb.pl",
93              "ple2.dmcs.p.lodz.pl",
94              "planetlab2.pjwstk.edu.pl",
95              "ple1.dmcs.p.lodz.pl",
96              "gschembra3.diit.unict.it",
97              "planetlab1.science.unitn.it",
98              "planetlab-1.ing.unimo.it",
99              "gschembra4.diit.unict.it",
100              "iraplab1.iralab.uni-karlsruhe.de",
101              #"planetlab-1.fokus.fraunhofer.de",
102              "iraplab2.iralab.uni-karlsruhe.de",
103              "planet2.zib.de",
104              #"pl2.uni-rostock.de",
105              "onelab-1.fhi-fokus.de",
106              "planet2.l3s.uni-hannover.de",
107              "planetlab1.exp-math.uni-essen.de",
108              #"planetlab-2.fokus.fraunhofer.de",
109              "planetlab02.tkn.tu-berlin.de",
110              "planetlab1.informatik.uni-goettingen.de",
111              "planetlab1.informatik.uni-erlangen.de",
112              "planetlab2.lkn.ei.tum.de",
113              "planetlab1.wiwi.hu-berlin.de",
114              "planet1.l3s.uni-hannover.de",
115              "planetlab1.informatik.uni-wuerzburg.de",
116              "host3-plb.loria.fr",
117              "inriarennes1.irisa.fr",
118              "inriarennes2.irisa.fr",
119              "peeramide.irisa.fr",
120              "planetlab-1.imag.fr",
121              "planetlab-2.imag.fr",
122              "ple2.ipv6.lip6.fr",
123              "planetlab1.u-strasbg.fr",
124              "planetlab1.ionio.gr",
125              "planetlab2.ionio.gr",
126              "stella.planetlab.ntua.gr",
127              "vicky.planetlab.ntua.gr",
128              "planetlab1.cs.uoi.gr",
129              "pl002.ece.upatras.gr",
130              "planetlab04.cnds.unibe.ch",
131              "lsirextpc01.epfl.ch",
132              "planetlab2.csg.uzh.ch",
133              "planetlab1.csg.uzh.ch",
134              "planetlab-2.cs.unibas.ch",
135              "planetlab-1.cs.unibas.ch",
136              "planetlab4.cs.st-andrews.ac.uk",
137              "planetlab3.xeno.cl.cam.ac.uk",
138              "planetlab1.xeno.cl.cam.ac.uk",
139              "planetlab2.xeno.cl.cam.ac.uk",
140              "planetlab3.cs.st-andrews.ac.uk",
141              "planetlab1.aston.ac.uk",
142              "planetlab1.nrl.eecs.qmul.ac.uk",
143              "chimay.infonet.fundp.ac.be",
144              "orval.infonet.fundp.ac.be",
145              "rochefort.infonet.fundp.ac.be",
146             ]
147
148     ec = ExperimentController(exp_id = exp_id)
149
150     for host in hostnames:
151         node = add_node(ec, host, pl_slice)
152         for i in xrange(20):
153             app = add_app(ec)
154             ec.register_connection(app, node)
155             apps.append(app)
156
157     ec.deploy()
158
159     ec.wait_finished(apps)
160
161     ec.shutdown()