4c896c270c6a8c008886ba3c94c8338831882d22
[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 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
20 from nepi.execution.ec import ExperimentController, ECState 
21 from nepi.execution.resource import ResourceState, ResourceAction
22
23 from optparse import OptionParser, SUPPRESS_HELP
24
25 import os
26 import time
27
28 def add_node(ec, host, user):
29     node = ec.register_resource("linux::Node")
30     ec.set(node, "hostname", host)
31     ec.set(node, "username", user)
32     ec.set(node, "cleanExperiment", True)
33     ec.set(node, "cleanProcesses", True)
34     return node
35
36 def add_app(ec):
37     app = ec.register_resource("linux::Application")
38     ec.set(app, "command", "sleep 30; echo 'HOLA'")
39     return app
40
41 def get_options():
42     slicename = os.environ.get("PL_SLICE")
43
44     usage = "usage: %prog -s <pl-slice>"
45
46     parser = OptionParser(usage=usage)
47     parser.add_option("-s", "--pl-slice", dest="pl_slice", 
48             help="PlanetLab slicename", default=slicename, type="str")
49     parser.add_option("-l", "--exp-id", dest="exp_id", 
50             help="Label to identify experiment", type="str")
51
52     (options, args) = parser.parse_args()
53
54     return (options.pl_slice, options.exp_id)
55
56 if __name__ == '__main__':
57     ( pl_slice, exp_id ) = get_options()
58
59     apps = []
60   
61     hostnames = [
62              #"planetlab-2.research.netlab.hut.fi",
63              "planetlab2.willab.fi",
64              "planetlab3.hiit.fi",
65              "planetlab4.hiit.fi",
66              "planetlab1.willab.fi",
67              "planetlab1.s3.kth.se",
68              "itchy.comlab.bth.se",
69              "planetlab-1.ida.liu.se",
70              "planetlab2.s3.kth.se",
71              "planetlab1.sics.se",
72              #"planetlab1.tlm.unavarra.es",
73              #"planetlab2.uc3m.es",
74              #"planetlab1.uc3m.es",
75              #"planetlab2.um.es",
76              "planet1.servers.ua.pt",
77              #"planetlab2.fct.ualg.pt",
78              "planetlab-1.tagus.ist.utl.pt",
79              "planetlab-2.tagus.ist.utl.pt",
80              "planetlab-um00.di.uminho.pt",
81              "planet2.servers.ua.pt",
82              "planetlab1.mini.pw.edu.pl",
83              "roti.mimuw.edu.pl",
84              "planetlab1.ci.pwr.wroc.pl",
85              "planetlab1.pjwstk.edu.pl",
86              "ple2.tu.koszalin.pl",
87              "planetlab2.ci.pwr.wroc.pl",
88              #"planetlab2.cyfronet.pl",
89              "plab2.ple.silweb.pl",
90              #"planetlab1.cyfronet.pl",
91              "plab4.ple.silweb.pl",
92              "ple2.dmcs.p.lodz.pl",
93              "planetlab2.pjwstk.edu.pl",
94              "ple1.dmcs.p.lodz.pl",
95              "gschembra3.diit.unict.it",
96              "planetlab1.science.unitn.it",
97              "planetlab-1.ing.unimo.it",
98              "gschembra4.diit.unict.it",
99              "iraplab1.iralab.uni-karlsruhe.de",
100              #"planetlab-1.fokus.fraunhofer.de",
101              "iraplab2.iralab.uni-karlsruhe.de",
102              "planet2.zib.de",
103              #"pl2.uni-rostock.de",
104              "onelab-1.fhi-fokus.de",
105              "planet2.l3s.uni-hannover.de",
106              "planetlab1.exp-math.uni-essen.de",
107              #"planetlab-2.fokus.fraunhofer.de",
108              "planetlab02.tkn.tu-berlin.de",
109              "planetlab1.informatik.uni-goettingen.de",
110              "planetlab1.informatik.uni-erlangen.de",
111              "planetlab2.lkn.ei.tum.de",
112              "planetlab1.wiwi.hu-berlin.de",
113              "planet1.l3s.uni-hannover.de",
114              "planetlab1.informatik.uni-wuerzburg.de",
115              "host3-plb.loria.fr",
116              "inriarennes1.irisa.fr",
117              "inriarennes2.irisa.fr",
118              "peeramide.irisa.fr",
119              "planetlab-1.imag.fr",
120              "planetlab-2.imag.fr",
121              "ple2.ipv6.lip6.fr",
122              "planetlab1.u-strasbg.fr",
123              "planetlab1.ionio.gr",
124              "planetlab2.ionio.gr",
125              "stella.planetlab.ntua.gr",
126              "vicky.planetlab.ntua.gr",
127              "planetlab1.cs.uoi.gr",
128              "pl002.ece.upatras.gr",
129              "planetlab04.cnds.unibe.ch",
130              "lsirextpc01.epfl.ch",
131              "planetlab2.csg.uzh.ch",
132              "planetlab1.csg.uzh.ch",
133              "planetlab-2.cs.unibas.ch",
134              "planetlab-1.cs.unibas.ch",
135              "planetlab4.cs.st-andrews.ac.uk",
136              "planetlab3.xeno.cl.cam.ac.uk",
137              "planetlab1.xeno.cl.cam.ac.uk",
138              "planetlab2.xeno.cl.cam.ac.uk",
139              "planetlab3.cs.st-andrews.ac.uk",
140              "planetlab1.aston.ac.uk",
141              "planetlab1.nrl.eecs.qmul.ac.uk",
142              "chimay.infonet.fundp.ac.be",
143              "orval.infonet.fundp.ac.be",
144              "rochefort.infonet.fundp.ac.be",
145             ]
146
147     ec = ExperimentController(exp_id = exp_id)
148
149     for host in hostnames:
150         node = add_node(ec, host, pl_slice)
151         for i in xrange(20):
152             app = add_app(ec)
153             ec.register_connection(app, node)
154             apps.append(app)
155
156     ec.deploy()
157
158     ec.wait_finished(apps)
159
160     ec.shutdown()