#
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
#
-# Instructions to run this example:
-#
-# 1. First edit the script file where required (See ASSING messages)
-#
-# 2. Then, run the script:
+# Example of how to run this experiment (replace with your information):
#
# $ cd <path-to-nepi>
-# $ PYTHONPATH=$PYTHONPATH:~/repos/nepi/src python examples/linux/vlc_streaming.py -u inria_nepi -i ~/.ssh/id_rsa_planetlab -a planetlab1.u-strasbg.fr -b planetlab1.utt.fr | vlc -
-
+# python examples/linux/vlc_streaming.py -a <hostname1> -b <hostname2> -u <username> -i <ssh-key>
from nepi.execution.ec import ExperimentController
from nepi.execution.resource import ResourceState, ResourceAction
from optparse import OptionParser, SUPPRESS_HELP
import os
-
usage = ("usage: %prog -a <hostanme1> -b <hostname2> -u <username> -i <ssh-key>")
parser = OptionParser(usage = usage)
ssh_key = options.ssh_key
## Create the experiment controller
-ec = ExperimentController(exp_id = "demo_CCN")
+ec = ExperimentController(exp_id = "vlc_streamming")
## Register node 1
-node1 = ec.register_resource("LinuxNode")
+node1 = ec.register_resource("linux::Node")
# Set the hostname of the first node to use for the experiment
ec.set(node1, "hostname", hostname1)
# username should be your SSH user
ec.set(node1, "cleanProcesses", True)
## Register node 2
-node2 = ec.register_resource("LinuxNode")
+node2 = ec.register_resource("linux::Node")
# Set the hostname of the first node to use for the experiment
ec.set(node2, "hostname", hostname2)
# username should be your SSH user
"--sout '#rtp{dst=%s,port=5004,mux=ts}' vlc://quit") % \
(video, hostname2)
-server = ec.register_resource("LinuxApplication")
+server = ec.register_resource("linux::Application")
ec.set(server, "depends", "vlc")
ec.set(server, "files", local_path_to_video)
ec.set(server, "command", command)
ec.register_connection(server, node1)
+# Register VLC client
command = ("sudo -S dbus-uuidgen --ensure; sleep 3; "
"vlc -I dummy rtp://%s:5004/%s "
"--sout '#std{access=file,mux=ts,dst=VIDEO}'") % \
(hostname2, video)
-client = ec.register_resource("LinuxApplication")
+client = ec.register_resource("linux::Application")
ec.set(client, "depends", "vlc")
ec.set(client, "command", command)
ec.register_connection(client, node2)
# Wait until the ccncat is finished
ec.wait_finished([server])
-print ec.trace(client, "VIDEO")
+video = ec.trace(client, "VIDEO")
+f = open("video.ts", "w")
+f.write(video)
+f.close()
ec.shutdown()
+print "Streamed VIDEO stored localy at video.ts"