X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=examples%2Flinux%2Fping.py;h=3e9f03a8082308956c46bd1b65312d1b544d42e1;hb=e7eb6ef8873e1e197b3db8842f67a483c004a77a;hp=aa8036420415bf99d315aaeeb0d33b65df2e159d;hpb=2efd5eabeba8a6577ace9132d6336d44be0510e8;p=nepi.git diff --git a/examples/linux/ping.py b/examples/linux/ping.py index aa803642..3e9f03a8 100644 --- a/examples/linux/ping.py +++ b/examples/linux/ping.py @@ -18,18 +18,44 @@ # # Author: Alina Quereilhac +# Example of how to run this experiment (replace with your information): +# +# $ cd +# python examples/linux/ping.py -a -u -i + + from nepi.execution.ec import ExperimentController +from optparse import OptionParser, SUPPRESS_HELP +import os + +usage = ("usage: %prog -a -u -i ") + +parser = OptionParser(usage = usage) +parser.add_option("-a", "--hostname", dest="hostname", + help="Remote host", type="str") +parser.add_option("-u", "--username", dest="username", + help="Username to SSH to remote host", type="str") +parser.add_option("-i", "--ssh-key", dest="ssh_key", + help="Path to private SSH key to be used for connection", + type="str") +(options, args) = parser.parse_args() + +hostname = options.hostname +username = options.username +ssh_key = options.ssh_key + ec = ExperimentController(exp_id = "ping-exp") node = ec.register_resource("LinuxNode") -ec.set(node, "hostname", "planetlab2.cs.aueb.gr") -ec.set(node, "username", "inria_pres") +ec.set(node, "hostname", hostname) +ec.set(node, "username", username) +ec.set(node, "identity", ssh_key) ec.set(node, "cleanHome", True) ec.set(node, "cleanProcesses", True) app = ec.register_resource("LinuxApplication") -ec.set(app, "command", "ping -c3 www.google.com") +ec.set(app, "command", "ping -c3 nepi.inria.fr") ec.register_connection(app, node) ec.deploy() @@ -38,5 +64,5 @@ ec.wait_finished(app) print ec.trace(app, "stdout") - ec.shutdown() +