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
28 # Create the entity Experiment Controller:
29 ec = ExperimentController(exp_id)
31 # Register the nodes resources:
33 # The username in this case is the slice name, the one to use for login in
34 # via ssh into PlanetLab nodes. Replace with your own slice name.
35 username = "inria_sfatest"
37 # The pluser and plpassword are the ones used to login in the PlanetLab web
38 # site. Replace with your own user and password account information.
39 pl_user = "lucia.guevgeozian_odizzio@inria.fr"
40 pl_password = os.environ.get("PL_PASS")
42 # Define a Planetlab Node with no restriction, it can be any node
43 node = ec.register_resource('PlanetlabNode')
44 ec.set(node, "username", username)
45 ec.set(node, "pluser", pl_user)
46 ec.set(node, "plpassword", pl_password)
47 ec.set(node, "cleanHome", True)
48 ec.set(node, "cleanProcesses", True)
50 # Define a ping application
51 app = ec.register_resource('LinuxApplication')
52 ec.set(app, 'command', 'ping -c5 google.com > ping_google.txt')
54 # Connect the application to the node
55 ec.register_connection(node, app)
57 # Deploy the experiment:
60 # Wait until the application is finish to retrive the trace:
63 trace = ec.trace(app, 'ping_google.txt')
65 # Choose a directory to store the traces locally, change to a convenient path for you:
66 directory = "examples/planetlab/"
67 trace_file = directory + "ping_google.txt"
68 f = open(trace_file, "w")
72 # Do the experiment controller shutdown: