From 19e3969ca3da5eb9da00d2a0cc256eee2eb70533 Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Thu, 11 Sep 2014 15:02:54 +0200 Subject: [PATCH] Cleaning up examples folder --- examples/{linux => }/dce/custom_dce_ccn.py | 0 examples/{linux => }/dce/custom_dce_ping.py | 0 .../{linux => }/dce/dce_ccn_application.py | 0 .../dce/dce_ccnpeek_application.py | 0 .../{linux => }/dce/dce_ping_application.py | 0 ...le_retrieval.py => ccn_simple_transfer.py} | 38 +++++---- examples/linux/ccn/ccncat_2_nodes.py | 2 +- ...le_transfer.py => netcat_file_transfer.py} | 5 +- examples/linux/ping.py | 26 ++++++- examples/linux/{ => testing}/multihop_ssh.py | 0 examples/linux/{ => testing}/scalability.py | 0 examples/{linux => }/ns3/csma_p2p_star.py | 0 examples/{linux => }/ns3/local_ping.py | 0 examples/{linux => }/ns3/remote_ping.py | 0 examples/{linux => }/ns3/wifi_ping.py | 0 examples/planetlab/select_nodes.py | 77 +++++++++++++++++++ 16 files changed, 126 insertions(+), 22 deletions(-) rename examples/{linux => }/dce/custom_dce_ccn.py (100%) rename examples/{linux => }/dce/custom_dce_ping.py (100%) rename examples/{linux => }/dce/dce_ccn_application.py (100%) rename examples/{linux => }/dce/dce_ccnpeek_application.py (100%) rename examples/{linux => }/dce/dce_ping_application.py (100%) rename examples/linux/ccn/{two_nodes_file_retrieval.py => ccn_simple_transfer.py} (81%) rename examples/linux/{file_transfer.py => netcat_file_transfer.py} (95%) rename examples/linux/{ => testing}/multihop_ssh.py (100%) rename examples/linux/{ => testing}/scalability.py (100%) rename examples/{linux => }/ns3/csma_p2p_star.py (100%) rename examples/{linux => }/ns3/local_ping.py (100%) rename examples/{linux => }/ns3/remote_ping.py (100%) rename examples/{linux => }/ns3/wifi_ping.py (100%) create mode 100644 examples/planetlab/select_nodes.py diff --git a/examples/linux/dce/custom_dce_ccn.py b/examples/dce/custom_dce_ccn.py similarity index 100% rename from examples/linux/dce/custom_dce_ccn.py rename to examples/dce/custom_dce_ccn.py diff --git a/examples/linux/dce/custom_dce_ping.py b/examples/dce/custom_dce_ping.py similarity index 100% rename from examples/linux/dce/custom_dce_ping.py rename to examples/dce/custom_dce_ping.py diff --git a/examples/linux/dce/dce_ccn_application.py b/examples/dce/dce_ccn_application.py similarity index 100% rename from examples/linux/dce/dce_ccn_application.py rename to examples/dce/dce_ccn_application.py diff --git a/examples/linux/dce/dce_ccnpeek_application.py b/examples/dce/dce_ccnpeek_application.py similarity index 100% rename from examples/linux/dce/dce_ccnpeek_application.py rename to examples/dce/dce_ccnpeek_application.py diff --git a/examples/linux/dce/dce_ping_application.py b/examples/dce/dce_ping_application.py similarity index 100% rename from examples/linux/dce/dce_ping_application.py rename to examples/dce/dce_ping_application.py diff --git a/examples/linux/ccn/two_nodes_file_retrieval.py b/examples/linux/ccn/ccn_simple_transfer.py similarity index 81% rename from examples/linux/ccn/two_nodes_file_retrieval.py rename to examples/linux/ccn/ccn_simple_transfer.py index 10814ae7..19c78417 100644 --- a/examples/linux/ccn/two_nodes_file_retrieval.py +++ b/examples/linux/ccn/ccn_simple_transfer.py @@ -29,23 +29,37 @@ 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 -b -u -i ") + +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 @@ -56,10 +70,9 @@ ec.set(node1, "cleanProcesses", True) ## 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 @@ -125,15 +138,12 @@ ec.set(col2, "traceName", "stderr") 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() diff --git a/examples/linux/ccn/ccncat_2_nodes.py b/examples/linux/ccn/ccncat_2_nodes.py index 34d3350a..7efe1187 100644 --- a/examples/linux/ccn/ccncat_2_nodes.py +++ b/examples/linux/ccn/ccncat_2_nodes.py @@ -33,7 +33,7 @@ # # # content ccncat -# PL host Linux host +# Linux host Linux host # 0 ------- Internet ------ 0 # diff --git a/examples/linux/file_transfer.py b/examples/linux/netcat_file_transfer.py similarity index 95% rename from examples/linux/file_transfer.py rename to examples/linux/netcat_file_transfer.py index 7d07ed6d..69091b49 100644 --- a/examples/linux/file_transfer.py +++ b/examples/linux/netcat_file_transfer.py @@ -23,8 +23,7 @@ # Example of how to run this experiment (replace with your credentials): # # $ cd -# $ PYTHONPATH=$PYTHONPATH:~/repos/nepi/src python examples/linux/file_transfer.py -u inria_nepi -i ~/.ssh/id_rsa_planetlab -a planetlab1.u-strasbg.fr -b planetlab1.utt.fr - +# python examples/linux/netcat_file_transfer.py -a -b -u -i from nepi.execution.ec import ExperimentController from nepi.execution.resource import ResourceAction, ResourceState @@ -52,7 +51,7 @@ username = options.username ssh_key = options.ssh_key ## Create the experiment controller -ec = ExperimentController(exp_id = "file_transfer") +ec = ExperimentController(exp_id = "nc_file_transfer") ## Register node 1 node1 = ec.register_resource("LinuxNode") diff --git a/examples/linux/ping.py b/examples/linux/ping.py index 6b5a249b..9e67f580 100644 --- a/examples/linux/ping.py +++ b/examples/linux/ping.py @@ -20,19 +20,36 @@ 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") -hostname = ## Add a string with the target hostname -username = ## Add a string with the username to SSH hostname - node = ec.register_resource("LinuxNode") 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() @@ -42,3 +59,4 @@ ec.wait_finished(app) print ec.trace(app, "stdout") ec.shutdown() + diff --git a/examples/linux/multihop_ssh.py b/examples/linux/testing/multihop_ssh.py similarity index 100% rename from examples/linux/multihop_ssh.py rename to examples/linux/testing/multihop_ssh.py diff --git a/examples/linux/scalability.py b/examples/linux/testing/scalability.py similarity index 100% rename from examples/linux/scalability.py rename to examples/linux/testing/scalability.py diff --git a/examples/linux/ns3/csma_p2p_star.py b/examples/ns3/csma_p2p_star.py similarity index 100% rename from examples/linux/ns3/csma_p2p_star.py rename to examples/ns3/csma_p2p_star.py diff --git a/examples/linux/ns3/local_ping.py b/examples/ns3/local_ping.py similarity index 100% rename from examples/linux/ns3/local_ping.py rename to examples/ns3/local_ping.py diff --git a/examples/linux/ns3/remote_ping.py b/examples/ns3/remote_ping.py similarity index 100% rename from examples/linux/ns3/remote_ping.py rename to examples/ns3/remote_ping.py diff --git a/examples/linux/ns3/wifi_ping.py b/examples/ns3/wifi_ping.py similarity index 100% rename from examples/linux/ns3/wifi_ping.py rename to examples/ns3/wifi_ping.py diff --git a/examples/planetlab/select_nodes.py b/examples/planetlab/select_nodes.py new file mode 100644 index 00000000..41519328 --- /dev/null +++ b/examples/planetlab/select_nodes.py @@ -0,0 +1,77 @@ +from nepi.execution.ec import ExperimentController + +from optparse import OptionParser, SUPPRESS_HELP +import os + +usage = ("usage: %prog -s -u -p " + "-k -c -o -n ") + +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") +parser.add_option("-c", "--country", dest="country", + help="Country for the PL hosts", + type="str") +parser.add_option("-o", "--os", dest="os", + help="Operating system for the PL hosts", + type="str") +parser.add_option("-n", "--node-count", dest="node_count", + help="Number of PL hosts to provision", + default = 2, + type="int") + +(options, args) = parser.parse_args() + +pl_slice = options.pl_slice +pl_ssh_key = options.pl_ssh_key +pl_user = options.pl_user +pl_password = options.pl_password +country = options.country +os = options.os +node_count = options.node_count + +def add_node(ec, pl_slice, pl_ssh_key, pl_user, pl_password, country, os): + node = ec.register_resource("PlanetlabNode") + ec.set(node, "username", pl_slice) + ec.set(node, "identity", pl_ssh_key) + ec.set(node, "pluser", pl_user) + ec.set(node, "plpassword", pl_password) + + if country: + ec.set(node, "country", country) + if os: + ec.set(node, "operatingSystem", os) + + ec.set(node, "cleanHome", True) + ec.set(node, "cleanProcesses", True) + + return node + +## Create the experiment controller +ec = ExperimentController(exp_id="host_select") + +nodes = [] + +for i in xrange(node_count): + node = add_node(ec, pl_slice, pl_ssh_key, pl_user, pl_password, country, os) + nodes.append(node) + +ec.deploy() + +ec.wait_deployed(nodes) + +print "SELECTED HOSTS" + +for node in nodes: + print ec.get(node, "hostname") + +ec.shutdown() + + -- 2.43.0