4 # NEPI, a framework to manage network experiments
5 # Copyright (C) 2013 INRIA
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
22 from nepi.execution.ec import ExperimentController, ECState
23 from nepi.execution.resource import ResourceState, ResourceAction, \
25 from nepi.resources.linux.node import OSType
27 from optparse import OptionParser, SUPPRESS_HELP
32 def add_node(ec, host, user, ssh_key = None):
33 node = ec.register_resource("LinuxNode")
34 ec.set(node, "hostname", host)
35 ec.set(node, "username", user)
36 ec.set(node, "identity", ssh_key)
37 ec.set(node, "cleanHome", True)
38 ec.set(node, "cleanProcesses", True)
41 def add_ccnd(ec, node):
42 ccnd = ec.register_resource("LinuxCCND")
43 ec.register_connection(ccnd, node)
46 def add_ccnr(ec, ccnd, node):
47 ccnr = ec.register_resource("LinuxCCNR")
48 ec.register_connection(ccnr, node)
49 ec.register_connection(ccnr, ccnd)
53 if __name__ == '__main__':
54 # Search for available RMs
57 ec = ExperimentController(exp_id = "olahh")
60 host1 = 'planetlab2.u-strasbg.fr'
61 host2 = 'roseval.pl.sophia.inria.fr'
67 # Register a ResourceManagers (RMs)
69 node1 = add_node(ec, host1, user1)
70 ccnd1 = add_ccnd(ec, node1)
71 ccnr1 = add_ccnr(ec, ccnd1, node1)
73 node2 = add_node(ec, host2, user2)
74 ccnd2 = add_ccnd(ec, node2)
75 ccnr2 = add_ccnr(ec, ccnd2, node2)
77 # Deploy all ResourceManagers
80 ec.wait_started([ccnd1, ccnr1, ccnd2, ccnr2])
82 # Shutdown the experiment controller