4 # NEPI, a framework to manage network experiments
5 # Copyright (C) 2013 INRIA
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
33 from nepi.execution.ec import ExperimentController, ECState
34 from nepi.execution.resource import ResourceState, ResourceAction, \
36 from nepi.resources.linux.node import OSType
38 from optparse import OptionParser, SUPPRESS_HELP
43 def add_node(ec, host, user, ssh_key = None):
44 node = ec.register_resource("LinuxNode")
45 ec.set(node, "hostname", host)
46 ec.set(node, "username", user)
47 ec.set(node, "identity", ssh_key)
48 ec.set(node, "cleanHome", True)
49 ec.set(node, "cleanProcesses", True)
52 def add_ccnd(ec, node):
53 ccnd = ec.register_resource("LinuxCCND")
54 ec.set(ccnd, "debug", 7)
55 ec.register_connection(ccnd, node)
58 def add_ccnr(ec, ccnd):
59 ccnr = ec.register_resource("LinuxCCNR")
60 ec.register_connection(ccnr, ccnd)
63 def add_fib_entry(ec, ccnd, peer_host):
64 entry = ec.register_resource("LinuxFIBEntry")
65 ec.set(entry, "host", peer_host)
66 ec.register_connection(entry, ccnd)
69 def add_content(ec, ccnr, content_name, content):
70 co = ec.register_resource("LinuxCCNContent")
71 ec.set(co, "contentName", content_name)
72 ec.set(co, "content", content)
73 ec.register_connection(co, ccnr)
76 def add_stream(ec, ccnd, content_name):
77 command = "sudo -S dbus-uuidgen --ensure ; ( ccncat %s | vlc - ) " % \
80 app = ec.register_resource("LinuxCCNDApplication")
81 ec.set(app, "depends", "vlc")
82 ec.set(app, "forwardX11", True)
83 ec.set(app, "command", command)
84 ec.register_connection(app, ccnd)
88 if __name__ == '__main__':
89 # Search for available RMs
92 ec = ExperimentController(exp_id = "olahh")
95 host1 = 'planetlab2.u-strasbg.fr'
96 host2 = 'roseval.pl.sophia.inria.fr'
102 content_name = "ccnx:/VIDEO"
103 video = "/home/alina/repos/nepi/examples/big_buck_bunny_240p_mpeg4_lq.ts"
105 # Register a ResourceManagers (RMs)
107 node1 = add_node(ec, host1, user1)
108 ccnd1 = add_ccnd(ec, node1)
109 ccnr1 = add_ccnr(ec, ccnd1)
110 fibentry1 = add_fib_entry(ec, ccnd1, host2)
111 co = add_content(ec, ccnr1, content_name, video)
113 node2 = add_node(ec, host2, user2)
114 ccnd2 = add_ccnd(ec, node2)
115 ccnr2 = add_ccnr(ec, ccnd2)
116 fibentry2 = add_fib_entry(ec, ccnd2, host1)
117 app = add_stream(ec, ccnd2, content_name)
119 # Deploy all ResourceManagers
122 ec.wait_finished([app])
124 # Shutdown the experiment controller