3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
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.
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.
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/>.
19 # Author: Lucia Guevgeozian <lucia.guevgeozian_odizzio@inria.fr>
21 from nepi.execution.ec import ExperimentController
22 from nepi.execution.resource import ResourceAction, ResourceState
27 def create_node(ec, username, pl_user, pl_password, critical=True, hostname=None,
28 country=None, operatingSystem=None, minBandwidth=None, minCpu=None):
30 node = ec.register_resource("planetlab::Node")
33 ec.set(node, "username", username)
35 ec.set(node, "pluser", pl_user)
37 ec.set(node, "plpassword", pl_password)
40 ec.set(node, "hostname", hostname)
42 ec.set(node, "country", country)
44 ec.set(node, "operatingSystem", operatingSystem)
46 ec.set(node, "minBandwidth", minBandwidth)
48 ec.set(node, "minCpu", minCpu)
49 ec.set(node, "critical", critical)
51 #ec.set(node, "cleanExperiment", True)
52 #ec.set(node, "cleanProcesses", True)
56 exp_id = "scalability_exp"
58 # Create the entity Experiment Controller:
59 ec = ExperimentController(exp_id)
61 # Register the nodes resources:
63 # The username in this case is the slice name, the one to use for login in
64 # via ssh into PlanetLab nodes. Replace with your own slice name.
65 username = os.environ.get("PL_SLICE")
67 # The pluser and plpassword are the ones used to login in the PlanetLab web
68 # site. Replace with your own user and password account information.
69 pl_user = os.environ.get("PL_USER")
70 pl_password = os.environ.get("PL_PASS")
72 # Choose the PlanetLab nodes for the experiment, in this example 5 nodes are
73 # used, and they are picked according to different criterias.
79 # First set of nodes will be defined by its hostname.
80 hostnames = ['planetlab2.utt.fr',
81 'planetlab-2.man.poznan.pl',
82 'planetlab-1.ing.unimo.it',
83 'gschembra3.diit.unict.it',
84 'planetlab2.ionio.gr',
85 'planetlab-1.imag.fr',
86 'node2pl.planet-lab.telecom-lille1.eu',
87 'planetlab1.xeno.cl.cam.ac.uk',
89 'planetlab2.fri.uni-lj.si',
90 'planetlab1.informatik.uni-erlangen.de',
91 'node1pl.planet-lab.telecom-lille1.eu',
92 'planet2.servers.ua.pt',
93 'iraplab1.iralab.uni-karlsruhe.de',
94 'planetlab-node3.it-sudparis.eu',
96 'planet1.l3s.uni-hannover.de',
97 'planetlab1.fct.ualg.pt',
98 'host1.planetlab.informatik.tu-darmstadt.de',
99 'vicky.planetlab.ntua.gr',
100 'planetlab1.rutgers.edu']
102 for hostname in hostnames:
103 node = create_node(ec, username, pl_user, pl_password, hostname=hostname,
105 first_set_nodes.append(node)
107 # Second set of nodes will be U.S.A. nodes.
108 country = "United States"
110 node = create_node(ec, username, pl_user, pl_password, country=country,
112 second_set_nodes.append(node)
114 # Third set of nodes can be any node in Planetlab testbed.
116 node = create_node(ec, username, pl_user, pl_password, critical=False)
117 third_set_nodes.append(node)
119 # Register conditions
121 # The nodes that are completely identified by their hostnames have to be provisioned
122 # before the rest of the nodes. This assures that no other resource will use the
123 # identified node even if the constraints matchs.
124 # In this example the nodes from the first need to be provisioned before the ones in
125 # the second and third group. Using the same logic, is convenient that nodes from the
126 # second group are provisioned before nodes from the third group.
128 ec.register_condition(second_set_nodes, ResourceAction.DEPLOY, first_set_nodes, ResourceState.PROVISIONED)
129 ec.register_condition(third_set_nodes, ResourceAction.DEPLOY, second_set_nodes, ResourceState.PROVISIONED)
131 # Deploy the experiment:
134 # Wait until all nodes are provisioned:
135 ec.wait_deployed(first_set_nodes)
136 ec.wait_deployed(second_set_nodes)
137 ec.wait_deployed(third_set_nodes)
139 # Do the experiment controller shutdown: