from nepi.execution.ec import ExperimentController
+from optparse import OptionParser, SUPPRESS_HELP
import os
-ssh_key = ####### <<< ASSING the absolute path to the private SSH key to login into the remote host >>>
-ssh_user = ####### <<< ASSING the SSH username >>>
-
-results_dir = "/tmp/demo_CCN_results"
+usage = ("usage: %prog -a <hostanme1> -b <hostname2> -u <username> -i <ssh-key>")
+
+parser = OptionParser(usage = usage)
+parser.add_option("-a", "--hostname1", dest="hostname1",
+ help="Remote host 1", type="str")
+parser.add_option("-b", "--hostname2", dest="hostname2",
+ help="Remote host 2", 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()
+
+hostname1 = options.hostname1
+hostname2 = options.hostname2
+username = options.username
+ssh_key = options.ssh_key
## Create the experiment controller
-ec = ExperimentController(exp_id = "demo_CCN", local_dir = results_dir)
+ec = ExperimentController(exp_id = "ccn_simple_transfer")
## Register node 1
node1 = ec.register_resource("LinuxNode")
# Set the hostname of the first node to use for the experiment
-hostname1 = "peeramidion.irisa.fr" ##### <<< ASSIGN the hostname of a host you have SSSH access to >>>
ec.set(node1, "hostname", hostname1)
# username should be your SSH user
-ec.set(node1, "username", ssh_user)
+ec.set(node1, "username", username)
# Absolute path to the SSH private key
ec.set(node1, "identity", ssh_key)
# Clean all files, results, etc, from previous experiments wit the same exp_id
## Register node 2
node2 = ec.register_resource("LinuxNode")
# Set the hostname of the first node to use for the experiment
-hostname2 = "planetlab2.upc.es" ##### <<< ASSIGN the hostname of a host you have SSSH access to >>>
ec.set(node2, "hostname", hostname2)
# username should be your SSH user
-ec.set(node2, "username", ssh_user)
+ec.set(node2, "username", username)
# Absolute path to the SSH private key
ec.set(node2, "identity", ssh_key)
# Clean all files, results, etc, from previous experiments wit the same exp_id
ec.set(col2, "subDir", hostname2)
ec.register_connection(col2, ccnd2)
+print "Results stored at", ec.exp_dir
+
## Deploy all resources
ec.deploy()
# Wait until the ccncat is finished
ec.wait_finished([app])
-## CCND logs will be collected to the results_dir upon shutdown.
-## We can aldo get the content of the logs now:
-#print "LOG2", ec.trace(ccnd1, "stderr")
-#print "LOG 1", ec.trace(ccnd2, "stderr")
-
ec.shutdown()