Cleaning up examples folder
authorAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 11 Sep 2014 13:02:54 +0000 (15:02 +0200)
committerAlina Quereilhac <alina.quereilhac@inria.fr>
Thu, 11 Sep 2014 13:02:54 +0000 (15:02 +0200)
16 files changed:
examples/dce/custom_dce_ccn.py [moved from examples/linux/dce/custom_dce_ccn.py with 100% similarity]
examples/dce/custom_dce_ping.py [moved from examples/linux/dce/custom_dce_ping.py with 100% similarity]
examples/dce/dce_ccn_application.py [moved from examples/linux/dce/dce_ccn_application.py with 100% similarity]
examples/dce/dce_ccnpeek_application.py [moved from examples/linux/dce/dce_ccnpeek_application.py with 100% similarity]
examples/dce/dce_ping_application.py [moved from examples/linux/dce/dce_ping_application.py with 100% similarity]
examples/linux/ccn/ccn_simple_transfer.py [moved from examples/linux/ccn/two_nodes_file_retrieval.py with 81% similarity]
examples/linux/ccn/ccncat_2_nodes.py
examples/linux/netcat_file_transfer.py [moved from examples/linux/file_transfer.py with 95% similarity]
examples/linux/ping.py
examples/linux/testing/multihop_ssh.py [moved from examples/linux/multihop_ssh.py with 100% similarity]
examples/linux/testing/scalability.py [moved from examples/linux/scalability.py with 100% similarity]
examples/ns3/csma_p2p_star.py [moved from examples/linux/ns3/csma_p2p_star.py with 100% similarity]
examples/ns3/local_ping.py [moved from examples/linux/ns3/local_ping.py with 100% similarity]
examples/ns3/remote_ping.py [moved from examples/linux/ns3/remote_ping.py with 100% similarity]
examples/ns3/wifi_ping.py [moved from examples/linux/ns3/wifi_ping.py with 100% similarity]
examples/planetlab/select_nodes.py [new file with mode: 0644]

similarity index 81%
rename from examples/linux/ccn/two_nodes_file_retrieval.py
rename to examples/linux/ccn/ccn_simple_transfer.py
index 10814ae..19c7841 100644 (file)
 
 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
@@ -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()
index 34d3350..7efe118 100644 (file)
@@ -33,7 +33,7 @@
 #                
 #                 
 #  content                ccncat
-#  PL host               Linux host
+#  Linux host               Linux host
 #  0 ------- Internet ------ 0
 #           
 
similarity index 95%
rename from examples/linux/file_transfer.py
rename to examples/linux/netcat_file_transfer.py
index 7d07ed6..69091b4 100644 (file)
@@ -23,8 +23,7 @@
 # Example of how to run this experiment (replace with your credentials):
 #
 # $ cd <path-to-nepi>
-# $ 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 <hostanme1> -b <hostname2> -u <username> -i <ssh-key>
 
 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")
index 6b5a249..9e67f58 100644 (file)
 
 from nepi.execution.ec import ExperimentController 
 
+from optparse import OptionParser, SUPPRESS_HELP
+import os
+
+usage = ("usage: %prog -a <hostanme> -u <username> -i <ssh-key>")
+
+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/planetlab/select_nodes.py b/examples/planetlab/select_nodes.py
new file mode 100644 (file)
index 0000000..4151932
--- /dev/null
@@ -0,0 +1,77 @@
+from nepi.execution.ec import ExperimentController
+
+from optparse import OptionParser, SUPPRESS_HELP
+import os
+
+usage = ("usage: %prog -s <pl-slice> -u <pl-user> -p <pl-password> "
+    "-k <pl-ssh-key> -c <country> -o <operating-system> -n <node-count> ")
+
+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()
+
+