From 73e280a3141f47a795d46b4cc23b290bd2b4c68a Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Tue, 16 Sep 2014 18:00:15 +0200 Subject: [PATCH] Planetlab examples --- ...le_retrieval.py => ccn_simple_transfer.py} | 0 .../planetlab/{ping_experiment.py => ping.py} | 62 ++++++++++++------- examples/planetlab/select_nodes.py | 28 ++++++++- examples/planetlab/{ => testing}/blacklist.py | 0 .../planetlab/{ => testing}/scalability.py | 0 5 files changed, 68 insertions(+), 22 deletions(-) rename examples/planetlab/{ccn/two_nodes_file_retrieval.py => ccn_simple_transfer.py} (100%) rename examples/planetlab/{ping_experiment.py => ping.py} (52%) rename examples/planetlab/{ => testing}/blacklist.py (100%) rename examples/planetlab/{ => testing}/scalability.py (100%) diff --git a/examples/planetlab/ccn/two_nodes_file_retrieval.py b/examples/planetlab/ccn_simple_transfer.py similarity index 100% rename from examples/planetlab/ccn/two_nodes_file_retrieval.py rename to examples/planetlab/ccn_simple_transfer.py diff --git a/examples/planetlab/ping_experiment.py b/examples/planetlab/ping.py similarity index 52% rename from examples/planetlab/ping_experiment.py rename to examples/planetlab/ping.py index 4a693fde..e36ba61f 100644 --- a/examples/planetlab/ping_experiment.py +++ b/examples/planetlab/ping.py @@ -17,39 +17,64 @@ # along with this program. If not, see . # # Author: Lucia Guevgeozian +# Alina Quereilhac +# + +# Example of how to run this experiment (replace with your information): +# +# $ cd +# python examples/planetlab/ping.py -s -u -p -k + from nepi.execution.ec import ExperimentController -from nepi.execution.resource import ResourceAction, ResourceState +from optparse import OptionParser import os -exp_id = "ping_exp" +usage = ("usage: %prog -s -u -p " + "-k ") + +parser = OptionParser(usage = usage) +parser.add_option("-s", "--pl-slice", dest="pl_slice", + help="PlanetLab slicename", type="str") +parser.add_option("-u", "--pl-user", dest="pl_user", + help="PlanetLab web username", type="str") +parser.add_option("-p", "--pl-password", dest="pl_password", + help="PlanetLab web password", type="str") +parser.add_option("-k", "--pl-ssh-key", dest="pl_ssh_key", + help="Path to private SSH key associated with the PL account", + type="str") -# Create the entity Experiment Controller: -ec = ExperimentController(exp_id) +(options, args) = parser.parse_args() -# Register the nodes resources: +pl_slice = options.pl_slice +pl_ssh_key = options.pl_ssh_key +pl_user = options.pl_user +pl_password = options.pl_password + +## Create the experiment controller +ec = ExperimentController(exp_id = "pl_ping") + +# Register a Planetlab Node with no restrictions, it can be any node +node = ec.register_resource("PlanetlabNode") # The username in this case is the slice name, the one to use for login in # via ssh into PlanetLab nodes. Replace with your own slice name. -username = "inria_sfatest" +ec.set(node, "username", pl_slice) +ec.set(node, "identity", pl_ssh_key) # The pluser and plpassword are the ones used to login in the PlanetLab web # site. Replace with your own user and password account information. -pl_user = "lucia.guevgeozian_odizzio@inria.fr" -pl_password = os.environ.get("PL_PASS") - -# Define a Planetlab Node with no restriction, it can be any node -node = ec.register_resource('PlanetlabNode') -ec.set(node, "username", username) ec.set(node, "pluser", pl_user) ec.set(node, "plpassword", pl_password) + +# Remove previous results ec.set(node, "cleanHome", True) ec.set(node, "cleanProcesses", True) # Define a ping application -app = ec.register_resource('LinuxApplication') -ec.set(app, 'command', 'ping -c5 google.com > ping_google.txt') +app = ec.register_resource("LinuxApplication") +ec.set(app, "command", "ping -c3 nepi.inria.fr") # Connect the application to the node ec.register_connection(node, app) @@ -60,14 +85,9 @@ ec.deploy() # Wait until the application is finish to retrive the trace: ec.wait_finished(app) -trace = ec.trace(app, 'ping_google.txt') +trace = ec.trace(app, "stdout") -# Choose a directory to store the traces locally, change to a convenient path for you: -directory = "examples/planetlab/" -trace_file = directory + "ping_google.txt" -f = open(trace_file, "w") -f.write(trace) -f.close() +print "PING outout ", trace # Do the experiment controller shutdown: ec.shutdown() diff --git a/examples/planetlab/select_nodes.py b/examples/planetlab/select_nodes.py index 41519328..c95ef06d 100644 --- a/examples/planetlab/select_nodes.py +++ b/examples/planetlab/select_nodes.py @@ -1,6 +1,32 @@ +# +# NEPI, a framework to manage network experiments +# Copyright (C) 2014 INRIA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Author: Alina Quereilhac +# + +# Example of how to run this experiment (replace with your information): +# +# $ cd +# python examples/planetlab/select_nodes.py -s -u -p -k -c -o -n + + from nepi.execution.ec import ExperimentController -from optparse import OptionParser, SUPPRESS_HELP +from optparse import OptionParser import os usage = ("usage: %prog -s -u -p " diff --git a/examples/planetlab/blacklist.py b/examples/planetlab/testing/blacklist.py similarity index 100% rename from examples/planetlab/blacklist.py rename to examples/planetlab/testing/blacklist.py diff --git a/examples/planetlab/scalability.py b/examples/planetlab/testing/scalability.py similarity index 100% rename from examples/planetlab/scalability.py rename to examples/planetlab/testing/scalability.py -- 2.43.0