Cleaning up examples folder
[nepi.git] / examples / linux / ccn / ccncat_2_nodes.py
old mode 100755 (executable)
new mode 100644 (file)
index 55133da..7efe118
 #                
 #                 
 #  content                ccncat
-#  PL host               Linux host
+#  Linux host               Linux host
 #  0 ------- Internet ------ 0
 #           
 
 from nepi.execution.ec import ExperimentController, ECState 
-from nepi.execution.resource import ResourceState, ResourceAction, \
-        populate_factory
+from nepi.execution.resource import ResourceState, ResourceAction 
 from nepi.resources.linux.node import OSType
 
 from optparse import OptionParser, SUPPRESS_HELP
 
+import getpass
 import os
 import time
 
@@ -71,14 +71,14 @@ def add_ccnd(ec, os_type, peers):
     build = (
         # Evaluate if ccnx binaries are already installed
         " ( "
-            "  test -f ${EXP_HOME}/ccnx/bin/ccnd"
+            "  test -f ${BIN}/ccnx-0.7.1/bin/ccnd"
         " ) || ( "
         # If not, untar and build
             " ( "
-                " mkdir -p ${SOURCES}/ccnx && "
-                " tar xf ${SOURCES}/ccnx-0.7.1.tar.gz --strip-components=1 -C ${SOURCES}/ccnx "
+                " mkdir -p ${SRC}/ccnx-0.7.1 && "
+                " tar xf ${SRC}/ccnx-0.7.1.tar.gz --strip-components=1 -C ${SRC}/ccnx-0.7.1 "
              " ) && "
-                "cd ${SOURCES}/ccnx && "
+                "cd ${SRC}/ccnx-0.7.1 && "
                 # Just execute and silence warnings...
                 "( ./configure && make ) "
          " )") 
@@ -86,14 +86,14 @@ def add_ccnd(ec, os_type, peers):
     install = (
         # Evaluate if ccnx binaries are already installed
         " ( "
-            "  test -f ${EXP_HOME}/ccnx/bin/ccnd"
+            "  test -f ${BIN}/ccnx-0.7.1/bin/ccnd"
         " ) || ( "
-            "  mkdir -p ${EXP_HOME}/ccnx/bin && "
-            "  cp -r ${SOURCES}/ccnx ${EXP_HOME}"
+            "  mkdir -p ${BIN}/ccnx-0.7.1/bin && "
+            "  cp -r ${SRC}/ccnx-0.7.1/bin ${BIN}/ccnx-0.7.1"
         " )"
     )
 
-    env = "PATH=$PATH:${EXP_HOME}/ccnx/bin"
+    env = "PATH=$PATH:${BIN}/ccnx-0.7.1/bin"
 
     # BASH command -> ' ccndstart ; ccndc add ccnx:/ udp  host ;  ccnr '
     command = "ccndstart && "
@@ -112,7 +112,7 @@ def add_ccnd(ec, os_type, peers):
     return app
 
 def add_publish(ec, movie):
-    env = "PATH=$PATH:${EXP_HOME}/ccnx/bin"
+    env = "PATH=$PATH:${BIN}/ccnx-0.7.1/bin"
     command = "ccnseqwriter -r ccnx:/VIDEO"
 
     app = ec.register_resource("LinuxApplication")
@@ -123,7 +123,7 @@ def add_publish(ec, movie):
     return app
 
 def add_stream(ec):
-    env = "PATH=$PATH:${EXP_HOME}/ccnx/bin"
+    env = "PATH=$PATH:${BIN}/ccnx-0.7.1/bin"
     command = "sudo -S dbus-uuidgen --ensure ; ( ccncat ccnx:/VIDEO | vlc - ) "
 
     app = ec.register_resource("LinuxApplication")
@@ -152,7 +152,8 @@ def get_options():
     #       the host can be accessed through SSH without prompting
     #       for a password. The host must allow X forwarding using SSH.
     linux_host = 'roseval.pl.sophia.inria.fr'
-
+    linux_user = getpass.getuser()
+    
     usage = "usage: %prog -p <pl-host> -s <pl-slice> -l <linux-host> -u <linux-user> -m <movie> -e <exp-id> -i <ssh_key>"
 
     parser = OptionParser(usage=usage)
@@ -165,8 +166,8 @@ def get_options():
             help="Hostname of second Linux host (non PlanetLab)",
             default = linux_host, type="str")
     parser.add_option("-u", "--linux-user", dest="linux_user", 
-            help="User for extra Linux host (non PlanetLab)", default = linux_host,
-            type="str")
+            help="User for extra Linux host (non PlanetLab)", 
+            default = linux_user, type="str")
     parser.add_option("-m", "--movie", dest="movie", 
             help="Stream movie", type="str")
     parser.add_option("-e", "--exp-id", dest="exp_id", 
@@ -188,9 +189,6 @@ if __name__ == '__main__':
     ( pl_host, pl_user, linux_host, linux_user, movie, exp_id, pl_ssh_key 
             ) = get_options()
 
-    # Search for available RMs
-    populate_factory()
-    
     # Create the ExperimentController instance
     ec = ExperimentController(exp_id = exp_id)