# If the hostname is not declared, Nepi will take SFA to provision one.
ec.set(node1, 'hostname', 'node0.nepi-robot.nepi.wilab2.ilabt.iminds.be')
# XMPP credentials
-ec.set(node1, 'xmppSlice', "default_slice_iminds")
-ec.set(node1, 'xmppHost', "am.wilab2.ilabt.iminds.be")
+ec.set(node1, 'xmppServer', "default_slice_iminds")
+ec.set(node1, 'xmppUser', "am.wilab2.ilabt.iminds.be")
ec.set(node1, 'xmppPort', "5222")
ec.set(node1, 'xmppPassword', "1234")
+ec.set(node1, 'version', "5")
# Create and Configure the Application
app1 = ec.register_resource("OMFRobotApplication")
ec.set(app1, 'appid', "robot")
-ec.set(app1, 'path', "/users/jtribino/RobotCTRLComm.rb") # /users/username/RobotCTRLComm.rb
-ec.set(app1, 'args', "/users/jtribino/coordinate.csv") #/users/username/coordinate.csv
+ec.set(app1, 'version', "5")
+ec.set(app1, 'command', "/users/jtribino/RobotCTRLComm.rb /users/jtribino/coordinate.csv")
+ # /users/username/RobotCTRLComm.rb /users/username/coordinate.csv
ec.set(app1, 'env', " ")
ec.set(app1, 'sources', "/home/wlab18/Desktop/coordinate.csv") # local path
ec.set(app1, 'sshUser', "jtribino") # username
from optparse import OptionParser, SUPPRESS_HELP
### Define OMF Method to simplify definition of resources ###
-def add_node(ec, hostname, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_node(ec, hostname, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
node = ec.register_resource("OMFNode")
ec.set(node, 'hostname', hostname)
- ec.set(node, 'xmppSlice', xmppSlice)
- ec.set(node, 'xmppHost', xmppHost)
+ ec.set(node, 'xmppServer', xmppServer)
+ ec.set(node, 'xmppUser', xmppUser)
ec.set(node, 'xmppPort', xmppPort)
ec.set(node, 'xmppPassword', xmppPassword)
+ ec.set(node, 'version', "5")
return node
-def add_interface(ec, ip, xmppSlice, xmppHost, essid = "ccn", alias = "w0", mode = "adhoc",
+def add_interface(ec, ip, xmppServer, xmppUser, essid = "ccn", name = "wlan0", mode = "adhoc",
typ = "g", xmppPort = "5222", xmppPassword = "1234"):
iface = ec.register_resource("OMFWifiInterface")
- ec.set(iface, 'alias', alias)
+ ec.set(iface, 'name', name)
ec.set(iface, 'mode', mode)
- ec.set(iface, 'type', typ)
+ ec.set(iface, 'hw_mode', typ)
ec.set(iface, 'essid', essid)
ec.set(iface, 'ip', ip)
+ ec.set(iface, 'version', "5")
return iface
-def add_channel(ec, channel, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_channel(ec, channel, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
chan = ec.register_resource("OMFChannel")
ec.set(chan, 'channel', channel)
- ec.set(chan, 'xmppSlice', xmppSlice)
- ec.set(chan, 'xmppHost', xmppHost)
+ ec.set(chan, 'xmppServer', xmppServer)
+ ec.set(chan, 'xmppUser', xmppUser)
ec.set(chan, 'xmppPort', xmppPort)
ec.set(chan, 'xmppPassword', xmppPassword)
+ ec.set(chan, 'version', "5")
return chan
-def add_app(ec, appid, command, args, env, xmppSlice, xmppHost,
+def add_app(ec, appid, command, env, xmppServer, xmppUser,
xmppPort = "5222", xmppPassword = "1234"):
app = ec.register_resource("OMFApplication")
ec.set(app, 'appid', appid)
- ec.set(app, 'path', command)
- ec.set(app, 'args', args)
+ ec.set(app, 'command', command)
ec.set(app, 'env', env)
+ ec.set(app, 'version', "5")
return app
### Define a CCND application ###
-def add_ccnd(ec, peers, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_ccnd(ec, peers, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root \
CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
#command += " ; ".join(peers) + " && "
command = peers[0]
- app = add_app(ec, "#ccnd", command, "", env, xmppSlice, xmppHost,
+ app = add_app(ec, "#ccnd", command, env, xmppServer, xmppUser,
xmppPort = xmppPort, xmppPassword = xmppPassword)
return app
### Define a CCN SeqWriter application ###
-def add_publish(ec, movie, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_publish(ec, movie, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
# BASH command -> 'ccnseqwriter -r ccnx:/VIDEO < movie'
command = "ccnseqwriter -r ccnx:/VIDEO"
command += " < " + movie
- app = add_app(ec, "#ccn_write", command, "", env, xmppSlice, xmppHost,
+ app = add_app(ec, "#ccn_write", command, env, xmppServer, xmppUser,
xmppPort = xmppPort, xmppPassword = xmppPassword)
return app
### Define a streaming application ###
-def add_stream(ec, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_stream(ec, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
command = " ddbus-uuidgen --ensure ; ( /root/ccnx-0.7.2/bin/ccncat ccnx:/VIDEO | /root/vlc-1.1.13/cvlc - ) "
#command = "ccncat ccnx:/VIDEO | /root/vlc-1.1.13/cvlc - "
- app = add_app(ec, "#ccn_stream", command, "", env, xmppSlice, xmppHost,
+ app = add_app(ec, "#ccn_stream", command, env, xmppServer, xmppUser,
xmppPort = xmppPort, xmppPassword = xmppPassword)
return app
ec.register_connection(iface2, chann)
# CCN setup for the sender
- ccndstart1 = add_app(ec, "#ccndstart", "ccndstart &", "", env,xmpp_slice, xmpp_host)
+ ccndstart1 = add_app(ec, "#ccndstart", "ccndstart &", env,xmpp_slice, xmpp_host)
ec.register_connection(ccndstart1, node1)
peers = [receiver_ip]
ccnd1 = add_ccnd(ec, peers, xmpp_slice, xmpp_host)
ec.register_connection(ccnd1, node1)
- ccnr1 = add_app(ec, "#ccnr", "ccnr &", "", env, xmpp_slice, xmpp_host)
+ ccnr1 = add_app(ec, "#ccnr", "ccnr &", env, xmpp_slice, xmpp_host)
ec.register_connection(ccnr1, node1)
# Register content producer application (ccnseqwriter)
ec.register_condition(pub, ResourceAction.START, ccnr1, ResourceState.STARTED, "2s")
# CCN setup for the receiver
- ccndstart2 = add_app(ec, "#ccndstart", "ccndstart &", "", env,xmpp_slice, xmpp_host)
+ ccndstart2 = add_app(ec, "#ccndstart", "ccndstart &", env,xmpp_slice, xmpp_host)
ec.register_connection(ccndstart2, node2)
peers = [sender_ip]
ccnd2 = add_ccnd(ec, peers, xmpp_slice, xmpp_host)
ec.register_connection(ccnd2, node2)
- ccnr2 = add_app(ec, "#ccnr", "ccnr &", "", env,xmpp_slice, xmpp_host)
+ ccnr2 = add_app(ec, "#ccnr", "ccnr &", env,xmpp_slice, xmpp_host)
ec.register_connection(ccnr2, node2)
# Register consumer application (ccncat)
# Cleaning when the experiment stop
- ccndstop1 = add_app(ec, "#ccndstop", "ccndstop", "", env, xmpp_slice, xmpp_host)
+ ccndstop1 = add_app(ec, "#ccndstop", "ccndstop", env, xmpp_slice, xmpp_host)
ec.register_connection(ccndstop1, node1)
- ccndstop2 = add_app(ec, "#ccndstop", "ccndstop", "", env, xmpp_slice, xmpp_host)
+ ccndstop2 = add_app(ec, "#ccndstop", "ccndstop", env, xmpp_slice, xmpp_host)
ec.register_connection(ccndstop2, node2)
ccndstops = [ccndstop1,ccndstop2]
- killall = add_app(ec, "#kill", "killall sh", "", "", xmpp_slice, xmpp_host)
+ killall = add_app(ec, "#kill", "killall sh", "", xmpp_slice, xmpp_host)
ec.register_connection(killall, node2)
apps = [ccndstart1, ccnd1, ccnr1, pub, ccndstart2, ccnd2, ccnr2, stream]
from optparse import OptionParser, SUPPRESS_HELP
### Define OMF Method to simplify definition of resources ###
-def add_node(ec, hostname, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_node(ec, hostname, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
node = ec.register_resource("OMFNode")
ec.set(node, 'hostname', hostname)
- ec.set(node, 'xmppSlice', xmppSlice)
- ec.set(node, 'xmppHost', xmppHost)
+ ec.set(node, 'xmppServer', xmppServer)
+ ec.set(node, 'xmppUser', xmppUser)
ec.set(node, 'xmppPort', xmppPort)
ec.set(node, 'xmppPassword', xmppPassword)
+ ec.set(node, 'version', "5")
return node
-def add_interface(ec, ip, xmppSlice, xmppHost, essid = "ccn", alias = "w0", mode = "adhoc",
+def add_interface(ec, ip, xmppServer, xmppUser, essid = "ccn", name = "wlan0", mode = "adhoc",
typ = "g", xmppPort = "5222", xmppPassword = "1234"):
iface = ec.register_resource("OMFWifiInterface")
- ec.set(iface, 'alias', alias)
+ ec.set(iface, 'name', name)
ec.set(iface, 'mode', mode)
- ec.set(iface, 'type', typ)
+ ec.set(iface, 'hw_mode', typ)
ec.set(iface, 'essid', essid)
ec.set(iface, 'ip', ip)
+ ec.set(iface, 'version', "5")
return iface
-def add_channel(ec, channel, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_channel(ec, channel, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
chan = ec.register_resource("OMFChannel")
ec.set(chan, 'channel', channel)
- ec.set(chan, 'xmppSlice', xmppSlice)
- ec.set(chan, 'xmppHost', xmppHost)
+ ec.set(chan, 'xmppServer', xmppServer)
+ ec.set(chan, 'xmppUser', xmppUser)
ec.set(chan, 'xmppPort', xmppPort)
ec.set(chan, 'xmppPassword', xmppPassword)
+ ec.set(chan, 'version', "5")
return chan
-def add_app(ec, host, appid, command, args, env, xmppSlice, xmppHost,
+def add_app(ec, host, appid, command, env, xmppServer, xmppUser,
xmppPort = "5222", xmppPassword = "1234"):
app = ec.register_resource("OMFApplication")
ec.set(app, 'appid', appid)
- ec.set(app, 'path', command)
- ec.set(app, 'args', args)
+ ec.set(app, 'command', command)
ec.set(app, 'env', env)
+ ec.set(app, 'version', "5")
ec.register_connection(app, host)
return app
### Define a CCND application ###
-def add_ccnd(ec, host, peers, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_ccnd(ec, host, peers, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root \
CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
# BASH command -> ' ccndstart ; ccndc add ccnx:/ udp host ; ccnr '
command = "ccndc add ccnx:/ udp " + peers
- app = add_app(ec, host, "#ccnd", command, "", env, xmppSlice, xmppHost,
+ app = add_app(ec, host, "#ccnd", command, env, xmppServer, xmppUser,
xmppPort = xmppPort, xmppPassword = xmppPassword)
return app
### Define a CCN SeqWriter application ###
-def add_publish(ec, host, movie, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_publish(ec, host, movie, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
# BASH command -> 'ccnseqwriter -r ccnx:/VIDEO < movie'
command = "ccnseqwriter -r ccnx:/VIDEO"
command += " < " + movie
- app = add_app(ec, host, "#ccn_write", command, "", env, xmppSlice, xmppHost,
+ app = add_app(ec, host, "#ccn_write", command, env, xmppServer, xmppUser,
xmppPort = xmppPort, xmppPassword = xmppPassword)
return app
### Define a streaming application ###
-def add_stream(ec, host, xmppSlice, xmppHost, xmppPort = "5222", xmppPassword = "1234"):
+def add_stream(ec, host, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
command = " ddbus-uuidgen --ensure ; ( /root/ccnx-0.7.2/bin/ccncat ccnx:/VIDEO | /root/vlc-1.1.13/cvlc - ) "
- app = add_app(ec, host, "#ccn_stream", command, "", env, xmppSlice, xmppHost,
+ app = add_app(ec, host, "#ccn_stream", command, env, xmppServer, xmppUser,
xmppPort = xmppPort, xmppPassword = xmppPassword)
return app
host5 = "omf.nitos.node026" # b1
host6 = "omf.nitos.node027" # b2
- ip1 = "192.168.0.22"
- ip2 = "192.168.0.28"
- ip3 = "192.168.0.24"
- ip4 = "192.168.0.25"
- ip5 = "192.168.0.26"
- ip6 = "192.168.0.27"
+ ip1 = "192.168.0.22/24"
+ ip2 = "192.168.0.28/24"
+ ip3 = "192.168.0.24/24"
+ ip4 = "192.168.0.25/24"
+ ip5 = "192.168.0.26/24"
+ ip6 = "192.168.0.27/24"
all_hosts = [host1, host2, host3, host4, host5, host6]
all_ip = [ip1, ip2, ip3, ip4, ip5, ip6]
ccnrs = dict()
for i in xrange(len(all_hosts)):
ccndstart = add_app(ec, nodes[all_hosts[i]], "#ccndstart", "ccndstart &",
- "", env, xmpp_slice, xmpp_host)
+ env, xmpp_slice, xmpp_host)
ccnr = add_app(ec, nodes[all_hosts[i]], "#ccnr", "ccnr &",
- "", env, xmpp_slice, xmpp_host)
+ env, xmpp_slice, xmpp_host)
ccnds[all_hosts[i]] = ccndstart
ccnrs[all_hosts[i]] = ccnr
ec.register_condition(ccnr, ResourceAction.START, ccndstart, ResourceState.STARTED, "1s")
ec.register_condition(stream, ResourceAction.START, pub, ResourceState.STARTED, "2s")
# break the lin
- ccndcstop1 = add_app(ec,nodes[host1], "#ccndc", "ccndc del ccnx:/ udp " + ip3, "", env, xmpp_slice, xmpp_host)
- ccndcstop2 = add_app(ec,nodes[host3], "#ccndc", "ccndc del ccnx:/ udp " + ip1, "", env, xmpp_slice, xmpp_host)
+ ccndcstop1 = add_app(ec,nodes[host1], "#ccndc", "ccndc del ccnx:/ udp " + ip3, env, xmpp_slice, xmpp_host)
+ ccndcstop2 = add_app(ec,nodes[host3], "#ccndc", "ccndc del ccnx:/ udp " + ip1, env, xmpp_slice, xmpp_host)
# Change the behaviour
# Cleaning when the experiment stop
ccndstops = []
for i in xrange(len(all_hosts)):
- ccndstop = add_app(ec, nodes[all_hosts[i]], "#ccndstop", "ccndstop", "", env, xmpp_slice, xmpp_host)
+ ccndstop = add_app(ec, nodes[all_hosts[i]], "#ccndstop", "ccndstop", env, xmpp_slice, xmpp_host)
ccndstops.append(ccndstop)
- killall = add_app(ec, nodes[host6], "#kill", "killall sh", "", "", xmpp_slice, xmpp_host)
+ killall = add_app(ec, nodes[host6], "#kill", "killall sh", "", xmpp_slice, xmpp_host)
# Condition to stop and clean the experiment
apps = []
# Create and Configure the Nodes
node1 = ec.register_resource("OMFNode")
ec.set(node1, 'hostname', 'omf.nitos.node0XX')
-ec.set(node1, 'xmppSlice', "ZZZ")
-ec.set(node1, 'xmppHost', "nitlab.inf.uth.gr")
+ec.set(node1, 'xmppServer', "ZZZ")
+ec.set(node1, 'xmppUser', "nitlab.inf.uth.gr")
ec.set(node1, 'xmppPort', "5222")
ec.set(node1, 'xmppPassword', "1234")
+ec.set(node1, 'version', "5")
node2 = ec.register_resource("OMFNode")
ec.set(node2, 'hostname', "omf.nitos.node0YY")
-ec.set(node2, 'xmppSlice', "ZZZ")
-ec.set(node2, 'xmppHost', "nitlab.inf.uth.gr")
+ec.set(node2, 'xmppServer', "ZZZ")
+ec.set(node2, 'xmppUser', "nitlab.inf.uth.gr")
ec.set(node2, 'xmppPort', "5222")
ec.set(node2, 'xmppPassword', "1234")
+ec.set(node2, 'version', "5")
# Create and Configure the Interfaces
iface1 = ec.register_resource("OMFWifiInterface")
-ec.set(iface1, 'alias', "w0")
+ec.set(iface1, 'name', "wlan0")
ec.set(iface1, 'mode', "adhoc")
-ec.set(iface1, 'type', "g")
+ec.set(iface1, 'hw_mode', "g")
ec.set(iface1, 'essid', "vlcexp")
-ec.set(iface1, 'ip', "192.168.0.XX")
+ec.set(iface1, 'ip', "192.168.0.XX/24")
+ec.set(iface1, 'version', "5")
iface2 = ec.register_resource("OMFWifiInterface")
-ec.set(iface2, 'alias', "w0")
+ec.set(iface2, 'name', "wlan0")
ec.set(iface2, 'mode', "adhoc")
-ec.set(iface2, 'type', 'g')
+ec.set(iface2, 'hw_mode', 'g')
ec.set(iface2, 'essid', "vlcexp")
-ec.set(iface2, 'ip', "192.168.0.YY")
+ec.set(iface2, 'ip', "192.168.0.YY/24")
+ec.set(iface2, 'version', "5")
# Create and Configure the Channel
channel = ec.register_resource("OMFChannel")
ec.set(channel, 'channel', "6")
-ec.set(channel, 'xmppSlice', "ZZZ")
-ec.set(channel, 'xmppHost', "nitlab.inf.uth.gr")
+ec.set(channel, 'xmppServer', "ZZZ")
+ec.set(channel, 'xmppUser', "nitlab.inf.uth.gr")
ec.set(channel, 'xmppPort', "5222")
ec.set(channel, 'xmppPassword', "1234")
+ec.set(channel, 'version', "5")
# Create and Configure the Application
app1 = ec.register_resource("OMFApplication")
ec.set(app1, 'appid', 'Vlc#1')
-ec.set(app1, 'path', "/root/vlc-1.1.13/cvlc")
-ec.set(app1, 'args', "/root/10-by-p0d.avi --sout '#rtp{dst=192.168.0.YY,port=1234,mux=ts}'")
+ec.set(app1, 'command', "/root/vlc/vlc-1.1.13/cvlc /root/10-by-p0d.avi --sout '#rtp{dst=192.168.0.YY,port=1234,mux=ts}'")
ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ec.set(app1, 'version', "5")
app2 = ec.register_resource("OMFApplication")
ec.set(app2, 'appid', 'Vlc#2')
-ec.set(app2, 'path', "/root/vlc-1.1.13/cvlc")
-ec.set(app2, 'args', "rtp://192.168.0.YY:1234")
+ec.set(app2, 'command', "/root/vlc/vlc-1.1.13/cvlc rtp://192.168.0.YY:1234")
ec.set(app2, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ec.set(app2, 'version', "5")
app3 = ec.register_resource("OMFApplication")
ec.set(app3, 'appid', 'Kill#2')
-ec.set(app3, 'path', "/usr/bin/killall")
-ec.set(app3, 'args', "vlc_app")
+ec.set(app3, 'command', "/usr/bin/killall vlc_app")
ec.set(app3, 'env', " ")
+ec.set(app3, 'version', "5")
app4 = ec.register_resource("OMFApplication")
ec.set(app4, 'appid', 'Kill#1')
-ec.set(app4, 'path', "/usr/bin/killall")
-ec.set(app4, 'args', "vlc_app")
+ec.set(app4, 'command', "/usr/bin/killall vlc_app")
ec.set(app4, 'env', " ")
+ec.set(app4, 'version', "5")
# Connection
ec.register_connection(app3, node1)
--- /dev/null
+"""
+ NEPI, a framework to manage network experiments
+ Copyright (C) 2013 INRIA
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+ Julien Tribino <julien.tribino@inria.fr>
+
+ Example :
+ - Testbed : Nitos
+ - Explanation :
+
+ VLC Streaming on VLC
+
+ Node Node
+ omf.nitos.node0xx omf.nitos.node0xx
+ 0--------------------------------------------------0
+ | |
+ | |
+ 0 0
+ VLC Server VLC Client
+
+ - Experiment:
+ - t0 : Deployment
+ - t1 : VLC Server start
+ - t2 (t1 + 4s) : VLC Client start
+ - t3 (t2 + 22s) : Client and Server Stop
+ - t4 (t3 + 3s): Kill all the applications
+
+"""
+
+#!/usr/bin/env python
+from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
+from nepi.execution.ec import ExperimentController
+
+# Create the EC
+ec = ExperimentController()
+
+# Create and Configure the Nodes
+node1 = ec.register_resource("OMFNode")
+ec.set(node1, 'hostname', 'omf.nitos.node025')
+ec.set(node1, 'xmppServer', "tribino")
+ec.set(node1, 'xmppUser', "nitlab.inf.uth.gr")
+ec.set(node1, 'xmppPort', "5222")
+ec.set(node1, 'xmppPassword', "1234")
+ec.set(node1, 'version', "5")
+
+node2 = ec.register_resource("OMFNode")
+ec.set(node2, 'hostname', "omf.nitos.node028")
+ec.set(node2, 'xmppServer', "tribino")
+ec.set(node2, 'xmppUser', "nitlab.inf.uth.gr")
+ec.set(node2, 'xmppPort', "5222")
+ec.set(node2, 'xmppPassword', "1234")
+ec.set(node2, 'version', "5")
+
+# Create and Configure the Interfaces
+iface1 = ec.register_resource("OMFWifiInterface")
+ec.set(iface1, 'name', "wlan0")
+ec.set(iface1, 'mode', "adhoc")
+ec.set(iface1, 'hw_mode', "g")
+ec.set(iface1, 'essid', "vlcexp")
+ec.set(iface1, 'ip', "192.168.0.25/24")
+ec.set(iface1, 'version', "5")
+
+iface2 = ec.register_resource("OMFWifiInterface")
+ec.set(iface2, 'name', "wlan0")
+ec.set(iface2, 'mode', "adhoc")
+ec.set(iface2, 'hw_mode', 'g')
+ec.set(iface2, 'essid', "vlcexp")
+ec.set(iface2, 'ip', "192.168.0.28/24")
+ec.set(iface2, 'version', "5")
+
+# Create and Configure the Channel
+channel = ec.register_resource("OMFChannel")
+ec.set(channel, 'channel', "6")
+ec.set(channel, 'xmppServer', "tribino")
+ec.set(channel, 'xmppUser', "nitlab.inf.uth.gr")
+ec.set(channel, 'xmppPort', "5222")
+ec.set(channel, 'xmppPassword', "1234")
+ec.set(channel, 'version', "5")
+
+# Create and Configure the Application
+app1 = ec.register_resource("OMFApplication")
+ec.set(app1, 'appid', 'Vlc#1')
+ec.set(app1, 'command', "/root/vlc/vlc-1.1.13/cvlc /root/10-by-p0d.avi --sout '#rtp{dst=192.168.0.28,port=1234,mux=ts}'")
+ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ec.set(app1, 'version', "5")
+
+app2 = ec.register_resource("OMFApplication")
+ec.set(app2, 'appid', 'Vlc#2')
+ec.set(app2, 'command', "/root/vlc/vlc-1.1.13/cvlc rtp://192.168.0.28:1234")
+ec.set(app2, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ec.set(app2, 'version', "5")
+
+app3 = ec.register_resource("OMFApplication")
+ec.set(app3, 'appid', 'Kill#2')
+ec.set(app3, 'command', "/usr/bin/killall vlc_app")
+ec.set(app3, 'env', " ")
+ec.set(app3, 'version', "5")
+
+app4 = ec.register_resource("OMFApplication")
+ec.set(app4, 'appid', 'Kill#1')
+ec.set(app4, 'command', "/usr/bin/killall vlc_app")
+ec.set(app4, 'env', " ")
+ec.set(app4, 'version', "5")
+
+# Connection
+ec.register_connection(app3, node1)
+ec.register_connection(app1, node1)
+ec.register_connection(node1, iface1)
+ec.register_connection(iface1, channel)
+ec.register_connection(iface2, channel)
+ec.register_connection(node2, iface2)
+ec.register_connection(app2, node2)
+ec.register_connection(app4, node2)
+
+# User Behaviour
+ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "4s")
+ec.register_condition([app1, app2], ResourceAction.STOP, app2, ResourceState.STARTED , "22s")
+ec.register_condition([app3, app4], ResourceAction.START, app2, ResourceState.STARTED , "25s")
+ec.register_condition([app3, app4], ResourceAction.STOP, app3, ResourceState.STARTED , "1s")
+
+# Deploy
+ec.deploy()
+
+ec.wait_finished([app1, app2, app3, app4])
+
+# Stop Experiment
+ec.shutdown()
# Create and Configure the Nodes
node1 = ec.register_resource("OMFNode")
ec.set(node1, 'hostname', 'omf.nitos.node0XX')
-ec.set(node1, 'xmppSlice', "ZZZ")
-ec.set(node1, 'xmppHost', "nitlab.inf.uth.gr")
+ec.set(node1, 'xmppServer', "ZZZ")
+ec.set(node1, 'xmppUser', "nitlab.inf.uth.gr")
ec.set(node1, 'xmppPort', "5222")
ec.set(node1, 'xmppPassword', "1234")
+ec.set(node1, 'version', "5")
# Create and Configure the Interfaces
iface1 = ec.register_resource("OMFWifiInterface")
-ec.set(iface1, 'alias', "w0")
+ec.set(iface1, 'name', "wlan0")
ec.set(iface1, 'mode', "adhoc")
-ec.set(iface1, 'type', "g")
+ec.set(iface1, 'hw_mode', "g")
ec.set(iface1, 'essid', "xeyes")
-ec.set(iface1, 'ip', "192.168.0.XX")
-ec.set(iface1, 'xmppSlice', "ZZZ")
-ec.set(iface1, 'xmppHost', "nitlab.inf.uth.gr")
-ec.set(iface1, 'xmppPort', "5222")
-ec.set(iface1, 'xmppPassword', "1234")
+ec.set(iface1, 'ip', "192.168.0.XX/24")
+ec.set(iface1, 'version', "5")
# Create and Configure the Channel
channel = ec.register_resource("OMFChannel")
ec.set(channel, 'channel', "6")
-ec.set(channel, 'xmppSlice', "ZZZ")
-ec.set(channel, 'xmppHost', "nitlab.inf.uth.gr")
+ec.set(channel, 'xmppServer', "ZZZ")
+ec.set(channel, 'xmppUser', "nitlab.inf.uth.gr")
ec.set(channel, 'xmppPort', "5222")
ec.set(channel, 'xmppPassword', "1234")
+ec.set(channel, 'version', "5")
# Create and Configure the Application
app1 = ec.register_resource("OMFApplication")
ec.set(app1, 'appid', 'XEyes#1')
-ec.set(app1, 'path', "/usr/bin/xeyes")
-ec.set(app1, 'args', " ")
+ec.set(app1, 'command', "/usr/bin/xeyes")
ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ec.set(app1, 'version', "5")
app2 = ec.register_resource("OMFApplication")
ec.set(app2, 'appid', 'Kill#1')
ec.set(app2, 'path', "/usr/bin/kill")
ec.set(app2, 'args', "xeyes")
ec.set(app2, 'env', " ")
+ec.set(app2, 'version', "5")
# Connection
ec.register_connection(app2, node1)
--- /dev/null
+"""
+ NEPI, a framework to manage network experiments
+ Copyright (C) 2013 INRIA
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+ Julien Tribino <julien.tribino@inria.fr>
+
+ Example :
+ - Testbed : Nitos
+ - Explanation :
+
+ CCN topology:
+
+
+
+ content ccncat ccncat
+ h1 h2 h3 h4 h5
+ 0 ----- 0 ----- 0 ------ 0 ------------0
+
+
+ - Experiment:
+ * t0 : h4 retrieves the content and we measure the time
+ * t1 : h5 retrieve the content and should go faster than h4
+
+"""
+
+#!/usr/bin/env python
+from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
+from nepi.execution.ec import ExperimentController
+
+from optparse import OptionParser, SUPPRESS_HELP
+
+### Define OMF Method to simplify definition of resources ###
+def add_node(ec, hostname, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
+ node = ec.register_resource("OMFNode")
+ ec.set(node, 'hostname', hostname)
+ ec.set(node, 'xmppServer', xmppServer)
+ ec.set(node, 'xmppUser', xmppUser)
+ ec.set(node, 'xmppPort', xmppPort)
+ ec.set(node, 'xmppPassword', xmppPassword)
+ ec.set(node, 'version', "5")
+ return node
+
+def add_interface(ec, ip, xmppServer, xmppUser, essid = "ccn", name = "wlan0", mode = "adhoc",
+ typ = "g", xmppPort = "5222", xmppPassword = "1234"):
+ iface = ec.register_resource("OMFWifiInterface")
+ ec.set(iface, 'name', name)
+ ec.set(iface, 'mode', mode)
+ ec.set(iface, 'hw_mode', typ)
+ ec.set(iface, 'essid', essid)
+ ec.set(iface, 'ip', ip)
+ ec.set(iface, 'version', "5")
+ return iface
+
+def add_channel(ec, channel, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
+ chan = ec.register_resource("OMFChannel")
+ ec.set(chan, 'channel', channel)
+ ec.set(chan, 'xmppServer', xmppServer)
+ ec.set(chan, 'xmppUser', xmppUser)
+ ec.set(chan, 'xmppPort', xmppPort)
+ ec.set(chan, 'xmppPassword', xmppPassword)
+ ec.set(chan, 'version', "5")
+ return chan
+
+def add_app(ec, host, appid, command, env, xmppServer, xmppUser,
+ xmppPort = "5222", xmppPassword = "1234"):
+ app = ec.register_resource("OMFApplication")
+ ec.set(app, 'appid', appid)
+ ec.set(app, 'command', command)
+ ec.set(app, 'env', env)
+ ec.set(app, 'version', "5")
+ ec.register_connection(app, host)
+ return app
+
+
+### Define a CCND application ###
+def add_ccnd(ec, host, peers, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
+ env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root \
+CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
+
+ # BASH command -> ' ccndstart ; ccndc add ccnx:/ udp host ; ccnr '
+ command = "ccndc add ccnx:/ udp " + peers
+ app = add_app(ec, host, "#ccnd", command, env, xmppServer, xmppUser,
+ xmppPort = xmppPort, xmppPassword = xmppPassword)
+ return app
+
+### Define a CCN SeqWriter application ###
+def add_publish(ec, host, movie, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
+ env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
+
+ # BASH command -> 'ccnseqwriter -r ccnx:/VIDEO < movie'
+ command = "ccnseqwriter -r ccnx:/VIDEO"
+ command += " < " + movie
+
+ app = add_app(ec, host, "#ccn_write", command, env, xmppServer, xmppUser,
+ xmppPort = xmppPort, xmppPassword = xmppPassword)
+ return app
+
+### Define a streaming application ###
+def add_stream(ec, host, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
+ env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
+ command = " ddbus-uuidgen --ensure ; ( /root/ccnx-0.7.2/bin/ccncat ccnx:/VIDEO | /root/vlc-1.1.13/cvlc - ) "
+ app = add_app(ec, host, "#ccn_stream", command, env, xmppServer, xmppUser,
+ xmppPort = xmppPort, xmppPassword = xmppPassword)
+ return app
+
+### Many options to easily addapt the script ####
+def get_options():
+ usage = "usage: %prog -c <channel> -s <xmpp_slice> -x <xmpp_host> -m <movie>"
+
+ parser = OptionParser(usage=usage)
+ parser.add_option("-c", "--channel", dest="channel",
+ help="Channel of the communication", type="str")
+ parser.add_option("-s", "--xmpp-slice", dest="xmpp_slice",
+ help="Name of the slice XMPP", type="str")
+ parser.add_option("-x", "--xmpp-host", dest="xmpp_host",
+ help="Name of the host XMPP", type="str")
+ #parser.add_option("-e", "--exp-id", dest="exp_id",
+ # help="Label to identify experiment", type="str")
+
+ (options, args) = parser.parse_args()
+
+ return (options.channel, options.xmpp_slice,
+ options.xmpp_host)
+
+### Script itself ###
+if __name__ == '__main__':
+ (channel, xmpp_slice, xmpp_host) = get_options()
+
+ env = 'PATH=$PATH:/root/ccnx-0.7.2/bin HOME=/root CCNR_DIRECTORY="/root" CCNR_STATUS_PORT="8080"'
+
+# Create the EC
+ ec = ExperimentController()
+
+# Create the topology
+ host1 = "omf.plexus.wlab5"
+ host2 = "omf.plexus.wlab9"
+ host3 = "omf.plexus.wlab10"
+ host4 = "omf.plexus.wlab24"
+ host5 = "omf.plexus.wlab29" # b1
+
+ ip1 = "10.0.0.5/24"
+ ip2 = "10.0.0.9/24"
+ ip3 = "10.0.0.10/24"
+ ip4 = "10.0.0.24/24"
+ ip5 = "10.0.0.29/24"
+
+ all_hosts = [host1, host2, host3, host4, host5]
+ all_ip = [ip1, ip2, ip3, ip4, ip5]
+
+ ring_hosts = [host1, host2, host3, host4]
+ nodes = dict()
+
+ chann = add_channel(ec, channel, xmpp_slice, xmpp_host)
+ for i in xrange(len(all_hosts)):
+ node = add_node(ec,all_hosts[i], xmpp_slice, xmpp_host)
+ iface = add_interface(ec, all_ip[i], xmpp_slice, xmpp_host)
+ ec.register_connection(node, iface)
+ ec.register_connection(iface, chann)
+ nodes[all_hosts[i]] = node
+
+#### CCN setup for the node
+### ccnds = dict()
+### ccnrs = dict()
+### for i in xrange(len(all_hosts)):
+### ccndstart = add_app(ec, nodes[all_hosts[i]], "#ccndstart", "ccndstart &",
+### env, xmpp_slice, xmpp_host)
+### ccnr = add_app(ec, nodes[all_hosts[i]], "#ccnr", "ccnr &",
+### env, xmpp_slice, xmpp_host)
+### ccnds[all_hosts[i]] = ccndstart
+### ccnrs[all_hosts[i]] = ccnr
+### ec.register_condition(ccnr, ResourceAction.START, ccndstart, ResourceState.STARTED, "1s")
+
+#### CCNDC setup
+### # l1 : h1 - h2 , h2 - h1
+### l1u = add_ccnd(ec, nodes[host1], ip2, xmpp_slice, xmpp_host)
+### l1d = add_ccnd(ec, nodes[host2], ip1, xmpp_slice, xmpp_host)
+
+### # l2 : h2 - h3 , h3 - h2
+### l2u = add_ccnd(ec, nodes[host2], ip3, xmpp_slice, xmpp_host)
+### l2d = add_ccnd(ec, nodes[host3], ip2, xmpp_slice, xmpp_host)
+
+### # l3 : h3 - h4 , h4 - h3
+### l3u = add_ccnd(ec, nodes[host3], ip4, xmpp_slice, xmpp_host)
+### l3d = add_ccnd(ec, nodes[host4], ip3, xmpp_slice, xmpp_host)
+
+### # l4 : h4 - h5 , h5 - h4
+### l4u = add_ccnd(ec, nodes[host4], ip5, xmpp_slice, xmpp_host)
+### l4d = add_ccnd(ec, nodes[host5], ip4, xmpp_slice, xmpp_host)
+
+### link = [l1u, l1d, l2u, l2d, l3u, l3d, l4u, l4d]
+
+#### List of condition
+### for i in xrange(len(all_hosts)):
+### ec.register_condition(ccnrs[all_hosts[i]], ResourceAction.START, ccnds[all_hosts[i]], ResourceState.STARTED, "1s")
+### ec.register_condition(link, ResourceAction.START, ccnrs[all_hosts[i]], ResourceState.STARTED, "1s")
+
+
+# Do the iperf
+ iperfserv = dict()
+ iperfclient = dict()
+ for i in xrange(len(all_hosts)):
+ perfserv = add_app(ec, nodes[all_hosts[i]], "#perfserv", "iperf -s > /opt/iperfserv.txt",
+ env, xmpp_slice, xmpp_host)
+ iperfclient[all_hosts[i]] = []
+ if i > 0:
+ cmd = "iperf -c " + all_ip[i-1] + " > /opt/iperclient1.txt"
+ perfclient1 = add_app(ec, nodes[all_hosts[i]], "#perfclient1", cmd,
+ env, xmpp_slice, xmpp_host)
+ iperfclient[all_hosts[i]].append(perfclient1)
+
+ if i < (len(all_hosts)-1):
+ cmd = "iperf -c " + all_ip[i+1] + " > /opt/iperclient2.txt"
+ perfclient2 = add_app(ec, nodes[all_hosts[i]], "#perfclient2", cmd,
+ env, xmpp_slice, xmpp_host)
+ iperfclient[all_hosts[i]].append(perfclient2)
+
+ iperfserv[all_hosts[i]] = perfserv
+
+ for i in xrange(len(all_hosts)):
+ #ec.register_condition(iperfserv[all_hosts[i]], ResourceAction.START, link, ResourceState.STARTED, "2s")
+ for elt in iperfclient[all_hosts[i]]:
+ ec.register_condition(elt, ResourceAction.START, iperfserv[all_hosts[i]], ResourceState.STARTED, "3s")
+
+
+## Streaming Server
+# pub = add_publish(ec, nodes[host5], movie, xmpp_slice, xmpp_host)
+
+## Streaming client
+# stream = add_stream(ec, nodes[host6], xmpp_slice, xmpp_host)
+
+## Streaming conditions
+# ec.register_condition(pub, ResourceAction.START, link, ResourceState.STARTED, "2s")
+# ec.register_condition(stream, ResourceAction.START, link, ResourceState.STARTED, "2s")
+# ec.register_condition(stream, ResourceAction.START, pub, ResourceState.STARTED, "2s")
+
+
+
+### Cleanning ###
+# Cleaning when the experiment stop
+## ccndstops = []
+## for i in xrange(len(all_hosts)):
+## ccndstop = add_app(ec, nodes[all_hosts[i]], "#ccndstop", "ccndstop", env, xmpp_slice, xmpp_host)
+## ccndstops.append(ccndstop)
+ perfkill = dict()
+ for i in xrange(len(all_hosts)):
+ kill = add_app(ec, nodes[all_hosts[i]], "#kill", "killall iperf", "", xmpp_slice, xmpp_host)
+ perfkill[all_hosts[i]] = kill
+
+
+# Condition to stop and clean the experiment
+ apps = []
+ for i in xrange(len(all_hosts)):
+# apps.append(ccnds[all_hosts[i]])
+# apps.append(ccnrs[all_hosts[i]])
+ apps.append(iperfserv[all_hosts[i]])
+ for elt in iperfclient[all_hosts[i]]:
+ apps.append(elt)
+# apps += link
+ #apps.append(pub)
+ #apps.append(stream)
+
+ ec.register_condition(apps, ResourceAction.STOP, apps, ResourceState.STARTED, "20s")
+
+# ec.register_condition(ccndstops + [killall], ResourceAction.START, apps, ResourceState.STOPPED, "1s")
+# ec.register_condition(ccndstops + [killall], ResourceAction.STOP, ccndstops, ResourceState.STARTED, "1s")
+
+ killall = []
+ for i in xrange(len(all_hosts)):
+ killall.append(perfkill[all_hosts[i]])
+
+ ec.register_condition(killall, ResourceAction.START, apps, ResourceState.STOPPED, "1s")
+ ec.register_condition(killall, ResourceAction.STOP, killall, ResourceState.STARTED, "1s")
+
+### Deploy and Wait ###
+# Deploy all ResourceManagers
+ ec.deploy()
+
+# Wait until the applications are finished
+ ec.wait_finished(killall)
+
+# Shutdown the experiment controller
+ ec.shutdown()
+
+
# Create and Configure the Nodes
node1 = ec.register_resource("OMFNode")
ec.set(node1, 'hostname', 'omf.plexus.wlab17')
-ec.set(node1, 'xmppSlice', "nepi")
-ec.set(node1, 'xmppHost', "xmpp-plexus.onelab.eu")
+ec.set(node1, 'xmppServer', "nepi")
+ec.set(node1, 'xmppUser', "xmpp-plexus.onelab.eu")
ec.set(node1, 'xmppPort', "5222")
ec.set(node1, 'xmppPassword', "1234")
+ec.set(node1, 'version', "5")
# Create and Configure the Application
app1 = ec.register_resource("OMFApplication")
ec.set(app1, 'appid', "robot")
-ec.set(app1, 'path', "/root/CTRL_test.rb")
-ec.set(app1, 'args', "coord.csv")
+ec.set(app1, 'command', "/root/CTRL_test.rb coord.csv")
ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ec.set(app1, 'version', "5")
# Connection
ec.register_connection(app1, node1)
# Create and Configure the Nodes
node1 = ec.register_resource("OMFNode")
ec.set(node1, 'hostname', 'omf.plexus.wlab17')
-ec.set(node1, 'xmppSlice', "nepi")
-ec.set(node1, 'xmppHost', "xmpp-plexus.onelab.eu")
+ec.set(node1, 'xmppUser', "nepi")
+ec.set(node1, 'xmppServer', "xmpp-plexus.onelab.eu")
ec.set(node1, 'xmppPort', "5222")
ec.set(node1, 'xmppPassword', "1234")
+ec.set(node1, 'version', "5")
node2 = ec.register_resource("OMFNode")
ec.set(node2, 'hostname', "omf.plexus.wlab37")
-ec.set(node2, 'xmppSlice', "nepi")
-ec.set(node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ec.set(node2, 'xmppUser', "nepi")
+ec.set(node2, 'xmppServer', "xmpp-plexus.onelab.eu")
ec.set(node2, 'xmppPort', "5222")
ec.set(node2, 'xmppPassword', "1234")
+ec.set(node2, 'version', "5")
# Create and Configure the Interfaces
iface1 = ec.register_resource("OMFWifiInterface")
-ec.set(iface1, 'alias', "w0")
+ec.set(iface1, 'name', "wlan0")
ec.set(iface1, 'mode', "adhoc")
-ec.set(iface1, 'type', "g")
+ec.set(iface1, 'hw_mode', "g")
ec.set(iface1, 'essid', "vlcexp")
ec.set(iface1, 'ip', "10.0.0.17")
+ec.set(iface1, 'version', "5")
iface2 = ec.register_resource("OMFWifiInterface")
-ec.set(iface2, 'alias', "w0")
+ec.set(iface2, 'name', "wlan0")
ec.set(iface2, 'mode', "adhoc")
-ec.set(iface2, 'type', 'g')
+ec.set(iface2, 'hw_mode', 'g')
ec.set(iface2, 'essid', "vlcexp")
-ec.set(iface2, 'ip', "10.0.0.37")
+ec.set(iface2, 'ip', "10.0.0.37/24")
+ec.set(iface2, 'version', "5")
# Create and Configure the Channel
channel = ec.register_resource("OMFChannel")
ec.set(channel, 'channel', "6")
-ec.set(channel, 'xmppSlice', "nepi")
-ec.set(channel, 'xmppHost', "xmpp-plexus.onelab.eu")
+ec.set(channel, 'xmppUser', "nepi")
+ec.set(channel, 'xmppServer', "xmpp-plexus.onelab.eu")
ec.set(channel, 'xmppPort', "5222")
ec.set(channel, 'xmppPassword', "1234")
+ec.set(channel, 'version', "5")
# Create and Configure the Application
app1 = ec.register_resource("OMFApplication")
ec.set(app1, 'appid', 'Vlc#1')
-ec.set(app1, 'path', "/opt/vlc-1.1.13/cvlc")
-ec.set(app1, 'args', "--quiet /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
-#ec.set(app1, 'args', "--quiet /opt/big_buck_bunny_240p_mpeg4.ts --sout '#rtp{dst=10.0.0.XX,port=1234,mux=ts} '")
-#ec.set(app1, 'args', "--quiet /opt/big_buck_bunny_240p_mpeg4_lq.ts --sout '#rtp{dst=10.0.0.XX,port=1234,mux=ts} '")
+ec.set(app1, 'command', "/opt/vlc-1.1.13/cvlc --quiet /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
+#ec.set(app1, 'command', "/opt/vlc-1.1.13/cvlc --quiet /opt/big_buck_bunny_240p_mpeg4.ts --sout '#rtp{dst=10.0.0.XX,port=1234,mux=ts} '")
+#ec.set(app1, 'command', "/opt/vlc-1.1.13/cvlc --quiet /opt/big_buck_bunny_240p_mpeg4_lq.ts --sout '#rtp{dst=10.0.0.XX,port=1234,mux=ts} '")
ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ec.set(app1, 'version', "5")
app2 = ec.register_resource("OMFApplication")
ec.set(app2, 'appid', 'Vlc#2')
-ec.set(app2, 'path', "/opt/vlc-1.1.13/cvlc")
-ec.set(app2, 'args', "--quiet rtp://10.0.0.37:1234")
+ec.set(app2, 'command', "/opt/vlc-1.1.13/cvlc --quiet rtp://10.0.0.37:1234")
ec.set(app2, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ec.set(app2, 'version', "5")
app3 = ec.register_resource("OMFApplication")
-ec.set(app3, 'appid', 'Kill#2')
-ec.set(app3, 'path', "/usr/bin/killall")
-ec.set(app3, 'args', "vlc")
+ec.set(app3, 'appid', 'Kill#1')
+ec.set(app3, 'command', "/usr/bin/killall vlc")
ec.set(app3, 'env', " ")
+ec.set(app3, 'version', "5")
+
+app4 = ec.register_resource("OMFApplication")
+ec.set(app4, 'appid', 'Kill#2')
+ec.set(app4, 'command', "/usr/bin/killall vlc")
+ec.set(app4, 'env', " ")
+ec.set(app4, 'version', "5")
# Connection
ec.register_connection(app3, node1)
ec.register_connection(iface2, channel)
ec.register_connection(node2, iface2)
ec.register_connection(app2, node2)
+ec.register_connection(app4, node2)
# User Behaviour
ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "4s")
ec.register_condition([app1, app2], ResourceAction.STOP, app2, ResourceState.STARTED , "22s")
-ec.register_condition(app3, ResourceAction.START, app2, ResourceState.STARTED , "25s")
-ec.register_condition(app3, ResourceAction.STOP, app3, ResourceState.STARTED , "1s")
+ec.register_condition([app3, app4], ResourceAction.START, app2, ResourceState.STOPPED , "1s")
+ec.register_condition([app3, app4], ResourceAction.STOP, app3, ResourceState.STARTED , "1s")
# Deploy
ec.deploy()
--- /dev/null
+"""
+ NEPI, a framework to manage network experiments
+ Copyright (C) 2013 INRIA
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+ Julien Tribino <julien.tribino@inria.fr>
+
+
+"""
+
+#!/usr/bin/env python
+from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
+from nepi.execution.ec import ExperimentController
+
+# Create the EC
+ec = ExperimentController()
+
+# Create and Configure the Nodes
+
+node1 = ec.register_resource("OMFNode")
+ec.set(node1, 'hostname', 'servernode.vlc.nepi.wilab2.ilabt.iminds.be')
+ec.set(node1, 'xmppServer', "xmpp.ilabt.iminds.be")
+ec.set(node1, 'xmppUser', "nepi")
+ec.set(node1, 'xmppPort', "5222")
+ec.set(node1, 'xmppPassword', "1234")
+
+iface1 = ec.register_resource("OMFWifiInterface")
+ec.set(iface1, 'name', 'wlan0')
+ec.set(iface1, 'mode', "adhoc")
+ec.set(iface1, 'hw_mode', "g")
+ec.set(iface1, 'essid', "vlc")
+ec.set(iface1, 'ip', "192.168.0.1/24")
+
+node2 = ec.register_resource("OMFNode")
+ec.set(node2, 'hostname', 'clientnode.vlc.nepi.wilab2.ilabt.iminds.be')
+ec.set(node2, 'xmppServer', "xmpp.ilabt.iminds.be")
+ec.set(node2, 'xmppUser', "nepi")
+ec.set(node2, 'xmppPort', "5222")
+ec.set(node2, 'xmppPassword', "1234")
+
+iface2 = ec.register_resource("OMFWifiInterface")
+ec.set(iface2, 'name', 'wlan0')
+ec.set(iface2, 'mode', "adhoc")
+ec.set(iface2, 'hw_mode', "g")
+ec.set(iface2, 'essid', "vlc")
+ec.set(iface2, 'ip', "192.168.0.2/24")
+
+chan = ec.register_resource("OMFChannel")
+ec.set(chan, 'channel', "6")
+
+# Create and Configure the Application
+app1 = ec.register_resource("OMFApplication")
+ec.set(app1, 'command', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc /root/10-by-p0d.avi --sout '#rtp{dst=192.168.0.2,port=1234,mux=ts}'")
+
+app2 = ec.register_resource("OMFApplication")
+ec.set(app2, 'command', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc rtp://192.168.0.2:1234")
+
+
+# Connection
+ec.register_connection(iface1, node1)
+ec.register_connection(iface2, node2)
+ec.register_connection(iface1, chan)
+ec.register_connection(iface2, chan)
+ec.register_connection(app1, node1)
+ec.register_connection(app2, node2)
+
+ec.register_condition([app2], ResourceAction.START, app1, ResourceState.STARTED , "4s")
+ec.register_condition([app1,app2], ResourceAction.STOP, app2, ResourceState.STARTED , "30s")
+
+
+# Deploy
+ec.deploy()
+
+ec.wait_finished([app1,app2])
+
+# Stop Experiment
+ec.shutdown()
+
--- /dev/null
+"""
+ NEPI, a framework to manage network experiments
+ Copyright (C) 2013 INRIA
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+ Julien Tribino <julien.tribino@inria.fr>
+
+
+"""
+
+#!/usr/bin/env python
+from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
+from nepi.execution.ec import ExperimentController
+
+# Create the EC
+ec = ExperimentController()
+
+# Create and Configure the Nodes
+
+node1 = ec.register_resource("OMFNode")
+ec.set(node1, 'hostname', 'node025')
+ec.set(node1, 'xmppServer', "nitlab.inf.uth.gr")
+ec.set(node1, 'xmppUser', "nepi")
+ec.set(node1, 'xmppPort', "5222")
+ec.set(node1, 'xmppPassword', "1234")
+
+iface1 = ec.register_resource("OMFWifiInterface")
+ec.set(iface1, 'name', 'wlan0')
+ec.set(iface1, 'mode', "adhoc")
+ec.set(iface1, 'hw_mode', "g")
+ec.set(iface1, 'essid', "vlc")
+ec.set(iface1, 'ip', "192.168.0.25/24")
+
+node2 = ec.register_resource("OMFNode")
+ec.set(node2, 'hostname', 'node027')
+ec.set(node2, 'xmppServer', "nitlab.inf.uth.gr")
+ec.set(node2, 'xmppUser', "nepi")
+ec.set(node2, 'xmppPort', "5222")
+ec.set(node2, 'xmppPassword', "1234")
+
+iface2 = ec.register_resource("OMFWifiInterface")
+ec.set(iface2, 'name', 'wlan0')
+ec.set(iface2, 'mode', "adhoc")
+ec.set(iface2, 'hw_mode', "g")
+ec.set(iface2, 'essid', "vlc")
+ec.set(iface2, 'ip', "192.168.0.27/24")
+
+chan = ec.register_resource("OMFChannel")
+ec.set(chan, 'channel', "6")
+
+# Create and Configure the Application
+app1 = ec.register_resource("OMFApplication")
+ec.set(app1, 'command', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc /root/10-by-p0d.avi --sout '#rtp{dst=192.168.0.27,port=1234,mux=ts}'")
+
+app2 = ec.register_resource("OMFApplication")
+ec.set(app2, 'command', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority /root/vlc/vlc-1.1.13/cvlc rtp://192.168.0.27:1234")
+
+
+# Connection
+ec.register_connection(iface1, node1)
+ec.register_connection(iface2, node2)
+ec.register_connection(iface1, chan)
+ec.register_connection(iface2, chan)
+ec.register_connection(app1, node1)
+ec.register_connection(app2, node2)
+
+ec.register_condition([app2], ResourceAction.START, app1, ResourceState.STARTED , "4s")
+ec.register_condition([app1,app2], ResourceAction.STOP, app2, ResourceState.STARTED , "30s")
+
+
+# Deploy
+ec.deploy()
+
+ec.wait_finished([app1,app2])
+
+# Stop Experiment
+ec.shutdown()
+
--- /dev/null
+"""
+ NEPI, a framework to manage network experiments
+ Copyright (C) 2013 INRIA
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+ Julien Tribino <julien.tribino@inria.fr>
+
+
+"""
+
+#!/usr/bin/env python
+from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
+from nepi.execution.ec import ExperimentController
+
+# Create the EC
+ec = ExperimentController()
+
+# Create and Configure the Nodes
+
+node1 = ec.register_resource("OMFNode")
+ec.set(node1, 'hostname', 'wlab12')
+ec.set(node1, 'xmppServer', "xmpp-plexus.onelab.eu")
+ec.set(node1, 'xmppUser', "nepi")
+ec.set(node1, 'xmppPort', "5222")
+ec.set(node1, 'xmppPassword', "1234")
+
+# Create and Configure the Application
+app1 = ec.register_resource("OMFApplication")
+ec.set(app1, 'command', '/bin/hostname -f')
+ec.set(app1, 'env', "")
+
+app2 = ec.register_resource("OMFApplication")
+ec.set(app2, 'command', '/bin/date')
+ec.set(app2, 'env', "")
+
+app3 = ec.register_resource("OMFApplication")
+ec.set(app3, 'command', '/bin/hostname -f')
+ec.set(app3, 'env', "")
+
+# Connection
+ec.register_connection(app1, node1)
+ec.register_connection(app2, node1)
+ec.register_connection(app3, node1)
+
+ec.register_condition([app2,app3], ResourceAction.START, app1, ResourceState.STARTED , "3s")
+ec.register_condition([app1,app2,app3], ResourceAction.STOP, app2, ResourceState.STARTED , "5s")
+
+
+# Deploy
+ec.deploy()
+
+ec.wait_finished([app1,app2,app3])
+
+# Stop Experiment
+ec.shutdown()
+
--- /dev/null
+"""
+ NEPI, a framework to manage network experiments
+ Copyright (C) 2013 INRIA
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+ Julien Tribino <julien.tribino@inria.fr>
+
+
+"""
+
+#!/usr/bin/env python
+from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
+from nepi.execution.ec import ExperimentController
+
+# Create the EC
+ec = ExperimentController()
+
+# Create and Configure the Nodes
+
+node1 = ec.register_resource("OMFNode")
+ec.set(node1, 'hostname', 'wlab12')
+ec.set(node1, 'xmppServer', "xmpp-plexus.onelab.eu")
+ec.set(node1, 'xmppUser', "nepi")
+ec.set(node1, 'xmppPort', "5222")
+ec.set(node1, 'xmppPassword', "1234")
+
+iface1 = ec.register_resource("OMFWifiInterface")
+ec.set(iface1, 'name', 'wlan0')
+ec.set(iface1, 'mode', "adhoc")
+ec.set(iface1, 'hw_mode', "g")
+ec.set(iface1, 'essid', "ping")
+ec.set(iface1, 'ip', "192.168.0.12/24")
+
+node2 = ec.register_resource("OMFNode")
+ec.set(node2, 'hostname', 'wlab49')
+ec.set(node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ec.set(node2, 'xmppUser', "nepi")
+ec.set(node2, 'xmppPort', "5222")
+ec.set(node2, 'xmppPassword', "1234")
+
+iface2 = ec.register_resource("OMFWifiInterface")
+ec.set(iface2, 'name', 'wlan0')
+ec.set(iface2, 'mode', "adhoc")
+ec.set(iface2, 'hw_mode', "g")
+ec.set(iface2, 'essid', "ping")
+ec.set(iface2, 'ip', "192.168.0.49/24")
+
+chan = ec.register_resource("OMFChannel")
+ec.set(chan, 'channel', "6")
+
+# Create and Configure the Application
+app1 = ec.register_resource("OMFApplication")
+ec.set(app1, 'command', '/bin/ping 192.168.0.49')
+ec.set(app1, 'env', "")
+
+app2 = ec.register_resource("OMFApplication")
+ec.set(app2, 'command', '/bin/ping 192.168.0.12')
+ec.set(app2, 'env', "")
+
+
+# Connection
+ec.register_connection(iface1, node1)
+ec.register_connection(iface2, node2)
+ec.register_connection(iface1, chan)
+ec.register_connection(iface2, chan)
+ec.register_connection(app1, node1)
+ec.register_connection(app2, node2)
+
+ec.register_condition([app2], ResourceAction.START, app1, ResourceState.STARTED , "2s")
+ec.register_condition([app1,app2], ResourceAction.STOP, app2, ResourceState.STARTED , "10s")
+
+
+# Deploy
+ec.deploy()
+
+ec.wait_finished([app1,app2])
+
+# Stop Experiment
+ec.shutdown()
+
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
# Julien Tribino <julien.tribino@inria.fr>
+import os
+
from nepi.execution.resource import ResourceManager, clsinit_copy, \
ResourceState, reschedule_delay
from nepi.execution.attribute import Attribute, Flags
from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
-from nepi.resources.omf.node import OMFNode
-from nepi.resources.omf.omf_api import OMFAPIFactory
+from nepi.resources.omf.node import OMFNode, confirmation_counter, reschedule_check
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
from nepi.util import sshfuncs
""" Register the attributes of an OMF application
"""
- appid = Attribute("appid", "Name of the application")
- path = Attribute("path", "Path of the application")
- args = Attribute("args", "Argument of the application")
+ command = Attribute("command", "Command to execute")
env = Attribute("env", "Environnement variable of the application")
+
+ # For OMF 5:
+ appid = Attribute("appid", "Name of the application")
stdin = Attribute("stdin", "Input of the application", default = "")
sources = Attribute("sources", "Sources of the application",
flags = Flags.Design)
flags = Flags.Design)
sshkey = Attribute("sshKey", "key to use for ssh",
flags = Flags.Design)
+
cls._register_attribute(appid)
- cls._register_attribute(path)
- cls._register_attribute(args)
+ cls._register_attribute(command)
cls._register_attribute(env)
cls._register_attribute(stdin)
cls._register_attribute(sources)
"""
super(OMFApplication, self).__init__(ec, guid)
+ self.set('command', "")
self.set('appid', "")
- self.set('path', "")
- self.set('args', "")
+ self._path= ""
+ self._args = ""
self.set('env', "")
self._node = None
self._omf_api = None
+ self._topic_app = None
+ self.create_id = None
+ self._create_cnt = 0
+ self._start_cnt = 0
+ self.release_id = None
+ self._release_cnt = 0
self.add_set_hook()
+ def _init_command(self):
+ comm = self.get('command').split(' ')
+ self._path= comm[0]
+ if len(comm)>1:
+ self._args = ' '.join(comm[1:])
+
@property
def exp_id(self):
return self.ec.exp_id
def stdin_hook(self, old_value, new_value):
""" Set a hook to the stdin attribute in order to send a message at each time
- the value of this parameter is changed
+ the value of this parameter is changed. Used ofr OMF 5.4 only
"""
self._omf_api.send_stdin(self.node.get('hostname'), new_value, self.get('appid'))
return new_value
def add_set_hook(self):
- """ Initialize the hooks
+ """ Initialize the hooks for OMF 5.4 only
"""
attr = self._attrs["stdin"]
def do_deploy(self):
""" Deploy the RM. It means nothing special for an application
for now (later it will be upload sources, ...)
- It becomes DEPLOYED after getting the xmpp client.
+ It becomes DEPLOYED after the topic for the application has been created
"""
+ if not self.node or self.node.state < ResourceState.READY:
+ self.debug("---- RESCHEDULING DEPLOY ---- node state %s "
+ % self.node.state )
+ self.ec.schedule(reschedule_delay, self.deploy)
+ return
- self.set('xmppSlice',self.node.get('xmppSlice'))
- self.set('xmppHost',self.node.get('xmppHost'))
+ self._init_command()
+
+ self.set('xmppUser',self.node.get('xmppUser'))
+ self.set('xmppServer',self.node.get('xmppServer'))
self.set('xmppPort',self.node.get('xmppPort'))
self.set('xmppPassword',self.node.get('xmppPassword'))
+ self.set('version',self.node.get('version'))
- if not (self.get('xmppSlice') and self.get('xmppHost')
- and self.get('xmppPort') and self.get('xmppPassword')):
- msg = "Credentials are not initialzed. XMPP Connections impossible"
+ if not self.get('xmppServer'):
+ msg = "XmppServer is not initialzed. XMPP Connections impossible"
self.error(msg)
raise RuntimeError, msg
- if not self._omf_api :
- self._omf_api = OMFAPIFactory.get_api(self.get('xmppSlice'),
- self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.exp_id)
+ if not (self.get('xmppUser') or self.get('xmppPort')
+ or self.get('xmppPassword')):
+ msg = "Credentials are not all initialzed. Default values will be used"
+ self.warn(msg)
- if self.get('sources'):
- gateway = ResourceGateway.AMtoGateway[self.get('xmppHost')]
- user = self.get('sshUser') or self.get('xmppSlice')
- dst = user + "@"+ gateway + ":"
- (out, err), proc = sshfuncs.rcopy(self.get('sources'), dst)
+ if not self.get('command') :
+ msg = "Application's Command is not initialized"
+ self.error(msg)
+ raise RuntimeError, msg
+
+ if not self._omf_api :
+ self._omf_api = OMFAPIFactory.get_api(self.get('version'),
+ self.get('xmppServer'), self.get('xmppUser'), self.get('xmppPort'),
+ self.get('xmppPassword'), exp_id = self.exp_id)
+
+ if self.get('version') == "5":
+ if self.get('sources'):
+ gateway = ResourceGateway.AMtoGateway[self.get('xmppServer')]
+ user = self.get('sshUser') or self.get('xmppUser')
+ dst = user + "@"+ gateway + ":"
+ (out, err), proc = sshfuncs.rcopy(self.get('sources'), dst)
+ else :
+ # For OMF 6 :
+ if not self.create_id:
+ props = {}
+ if self.get('command'):
+ props['application:binary_path'] = self.get('command')
+ props['application:hrn'] = self.get('command')
+ props['application:membership'] = self._topic_app
+ props['application:type'] = "application"
+
+ self.create_id = os.urandom(16).encode('hex')
+ self._omf_api.frcp_create( self.create_id, self.node.get('hostname'), "application", props = props)
+
+ if self._create_cnt > confirmation_counter:
+ msg = "Couldn't retrieve the confirmation of the creation"
+ self.error(msg)
+ raise RuntimeError, msg
+
+ uid = self.check_deploy(self.create_id)
+ if not uid:
+ self._create_cnt +=1
+ self.ec.schedule(reschedule_check, self.deploy)
+ return
+
+ self._topic_app = uid
+ self._omf_api.enroll_topic(self._topic_app)
super(OMFApplication, self).do_deploy()
+ def check_deploy(self, cid):
+ """ Check, through the mail box in the parser,
+ if the confirmation of the creation has been received
+
+ :param cid: the id of the original message
+ :type guid: string
+
+ """
+ uid = self._omf_api.check_mailbox("create", cid)
+ if uid :
+ return uid
+ return False
+
def do_start(self):
""" Start the RM. It means : Send Xmpp Message Using OMF protocol
to execute the application.
- It becomes STARTED before the messages are sent (for coordination)
"""
- if not (self.get('appid') and self.get('path')) :
- msg = "Application's information are not initialized"
- self.error(msg)
- raise RuntimeError, msg
- if not self.get('args'):
- self.set('args', " ")
if not self.get('env'):
self.set('env', " ")
- # Some information to check the information in parameter
- msg = " " + self.get_rtype() + " ( Guid : " + str(self._guid) +") : " + \
- self.get('appid') + " : " + self.get('path') + " : " + \
- self.get('args') + " : " + self.get('env')
- self.info(msg)
+ if self.get('version') == "5":
+ # Some information to check the command for OMF5
+ msg = " " + self.get_rtype() + " ( Guid : " + str(self._guid) +") : " + \
+ self.get('appid') + " : " + self._path + " : " + \
+ self._args + " : " + self.get('env')
+ self.debug(msg)
- self._omf_api.execute(self.node.get('hostname'),self.get('appid'), \
- self.get('args'), self.get('path'), self.get('env'))
+ self._omf_api.execute(self.node.get('hostname'),self.get('appid'), \
+ self._args, self._path, self.get('env'))
+ else:
+ #For OMF 6
+ if self._start_cnt == 0:
+ props = {}
+ props['state'] = "running"
+
+ guards = {}
+ guards['type'] = "application"
+ guards['name'] = self.get('command')
+
+ self._omf_api.frcp_configure(self._topic_app, props = props, guards = guards )
+
+ if self._start_cnt > confirmation_counter:
+ msg = "Couldn't retrieve the confirmation that the application started"
+ self.error(msg)
+ raise RuntimeError, msg
+
+ res = self.check_start(self._topic_app)
+ if not res:
+ self._start_cnt +=1
+ self.ec.schedule(reschedule_check, self.start)
+ return
super(OMFApplication, self).do_start()
+ def check_start(self, uid):
+ """ Check, through the mail box in the parser,
+ if the confirmation of the start has been received
+
+ :param uid: the id of the original message
+ :type guid: string
+
+ """
+ res = self._omf_api.check_mailbox("started", uid)
+ if res :
+ return True
+ return False
+
def do_stop(self):
""" Stop the RM. It means : Send Xmpp Message Using OMF protocol to
kill the application.
State is set to STOPPED after the message is sent.
"""
-
- self._omf_api.exit(self.node.get('hostname'),self.get('appid'))
+ if self.get('version') == 5:
+ self._omf_api.exit(self.node.get('hostname'),self.get('appid'))
super(OMFApplication, self).do_stop()
+ def check_release(self, cid):
+ """ Check, through the mail box in the parser,
+ if the confirmation of the release has been received
+
+ :param cid: the id of the original message
+ :type guid: string
+
+ """
+ res = self._omf_api.check_mailbox("release", cid)
+ if res :
+ return res
+ return False
+
def do_release(self):
""" Clean the RM at the end of the experiment and release the API.
"""
if self._omf_api:
- OMFAPIFactory.release_api(self.get('xmppSlice'),
- self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.exp_id)
+ if self.get('version') == "6":
+ if not self.release_id:
+ self.release_id = os.urandom(16).encode('hex')
+ self._omf_api.frcp_release( self.release_id, self.node.get('hostname'),self._topic_app, res_id=self._topic_app)
+
+ if self._release_cnt < confirmation_counter:
+ cid = self.check_release(self.release_id)
+ if not cid:
+ self._release_cnt +=1
+ self.ec.schedule(reschedule_check, self.release)
+ return
+ else:
+ msg = "Couldn't retrieve the confirmation of the release"
+ self.error(msg)
+
+
+ OMFAPIFactory.release_api(self.get('version'),
+ self.get('xmppServer'), self.get('xmppUser'), self.get('xmppPort'),
+ self.get('xmppPassword'), exp_id = self.exp_id)
super(OMFApplication, self).do_release()
from nepi.execution.attribute import Attribute, Flags
from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
-from nepi.resources.omf.omf_api import OMFAPIFactory
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
@clsinit_copy
_rtype = "OMFChannel"
_authorized_connections = ["OMFWifiInterface", "OMFNode"]
+ ChannelToFreq = dict({
+ "1" : "2412",
+ "2" : "2417",
+ "3" : "2422",
+ "4" : "2427",
+ "5" : "2432",
+ "6" : "2437",
+ "7" : "2442",
+ "8" : "2447",
+ "9" : "2452",
+ "10" : "2457",
+ "11" : "2462",
+ "12" : "2467",
+ "13" : "2472",
+ })
+
@classmethod
def _register_attributes(cls):
"""Register the attributes of an OMF channel
super(OMFChannel, self).__init__(ec, guid)
self._nodes_guid = list()
+ self.frequency = None
self._omf_api = None
"""
rm = self.ec.get_resource(guid)
-
if rm.get_rtype() in self._authorized_connections:
msg = "Connection between %s %s and %s %s accepted" % (
self.get_rtype(), self._guid, rm.get_rtype(), guid)
self.debug(msg)
return True
-
msg = "Connection between %s %s and %s %s refused" % (
self.get_rtype(), self._guid, rm.get_rtype(), guid)
self.debug(msg)
-
return False
def _get_target(self, conn_set):
if rm_iface.state < ResourceState.PROVISIONED or \
rm_node.state < ResourceState.READY:
return "reschedule"
- couple = [rm_node.get('hostname'), rm_iface.get('alias')]
- #print couple
+ couple = [rm_node.get('hostname'), rm_iface.alias]
res.append(couple)
return res
+ def get_frequency(self, channel):
+ """ Returns the frequency of a specific channel number
+
+ """
+ return OMFChannel.ChannelToFreq[channel]
+
def do_deploy(self):
""" Deploy the RM. It means : Get the xmpp client and send messages
- using OMF 5.4 protocol to configure the channel.
- It becomes DEPLOYED after sending messages to configure the channel
+ using OMF 5.4 or 6 protocol to configure the channel.
- """
- if not (self.get('xmppSlice') and self.get('xmppHost')
- and self.get('xmppPort') and self.get('xmppPassword')):
- msg = "Credentials are not initialzed. XMPP Connections impossible"
+ """
+ if not self.get('channel'):
+ msg = "Channel's value is not initialized"
self.error(msg)
raise RuntimeError, msg
- if not self._omf_api :
- self._omf_api = OMFAPIFactory.get_api(self.get('xmppSlice'),
- self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.exp_id)
+ if self.get('version') == "6":
+ self.frequency = self.get_frequency(self.get('channel'))
+ super(OMFChannel, self).do_deploy()
+ return
- if not self.get('channel'):
- msg = "Channel's value is not initialized"
+
+ if not self.get('xmppServer'):
+ msg = "XmppServer is not initialzed. XMPP Connections impossible"
self.error(msg)
raise RuntimeError, msg
+ if not (self.get('xmppUser') or self.get('xmppPort')
+ or self.get('xmppPassword')):
+ msg = "Credentials are not all initialzed. Default values will be used"
+ self.warn(msg)
+
+ if not self._omf_api :
+ self._omf_api = OMFAPIFactory.get_api(self.get('version'),
+ self.get('xmppServer'), self.get('xmppUser'), self.get('xmppPort'),
+ self.get('xmppPassword'), exp_id = self.exp_id)
+
self._nodes_guid = self._get_target(self._connections)
+
+
if self._nodes_guid == "reschedule" :
- self.ec.schedule("2s", self.deploy)
+ self.ec.schedule("1s", self.deploy)
else:
for couple in self._nodes_guid:
attrval = self.get('channel')
attrname = "net/%s/%s" % (couple[1], 'channel')
self._omf_api.configure(couple[0], attrname, attrval)
- super(OMFChannel, self).do_deploy()
+ super(OMFChannel, self).do_deploy()
def do_release(self):
""" Clean the RM at the end of the experiment and release the API
"""
if self._omf_api :
- OMFAPIFactory.release_api(self.get('xmppSlice'),
- self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.exp_id)
+ OMFAPIFactory.release_api(self.get('version'),
+ self.get('xmppServer'), self.get('xmppUser'), self.get('xmppPort'),
+ self.get('xmppPassword'), exp_id = self.exp_id)
super(OMFChannel, self).do_release()
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
# Julien Tribino <julien.tribino@inria.fr>
+import os, time
from nepi.execution.resource import ResourceManager, clsinit_copy, \
ResourceState, reschedule_delay
from nepi.execution.attribute import Attribute, Flags
-from nepi.resources.omf.node import OMFNode
+from nepi.resources.omf.node import OMFNode, confirmation_counter, reschedule_check
from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
from nepi.resources.omf.channel import OMFChannel
-from nepi.resources.omf.omf_api import OMFAPIFactory
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
@clsinit_copy
class OMFWifiInterface(OMFResource):
_rtype = "OMFWifiInterface"
_authorized_connections = ["OMFNode" , "OMFChannel"]
- #alias2name = dict({'w0':'wlan0', 'w1':'wlan1'})
-
@classmethod
def _register_attributes(cls):
"""Register the attributes of an OMF interface
"""
- alias = Attribute("alias","Alias of the interface", default = "w0")
+ name = Attribute("name","Alias of the interface : wlan0, wlan1, ..", default = "wlan0")
mode = Attribute("mode","Mode of the interface")
- type = Attribute("type","Type of the interface")
+ hw_mode = Attribute("hw_mode","Choose between : a, b, g, n")
essid = Attribute("essid","Essid of the interface")
ip = Attribute("ip","IP of the interface")
- cls._register_attribute(alias)
+ cls._register_attribute(name)
cls._register_attribute(mode)
- cls._register_attribute(type)
+ cls._register_attribute(hw_mode)
cls._register_attribute(essid)
cls._register_attribute(ip)
super(OMFWifiInterface, self).__init__(ec, guid)
self._conf = False
-
+ self.alias = None
+ self._type = None
+
+ self.create_id = None
+ self._create_cnt = 0
+ self.release_id = None
+ self._release_cnt = 0
+ self._topic_iface = None
self._omf_api = None
- self._alias = self.get('alias')
+ self._type = ""
+
def valid_connection(self, guid):
""" Check if the connection with the guid in parameter is possible.
msg = "Connection between %s %s and %s %s accepted" % \
(self.get_rtype(), self._guid, rm.get_rtype(), guid)
self.debug(msg)
-
return True
msg = "Connection between %s %s and %s %s refused" % \
(self.get_rtype(), self._guid, rm.get_rtype(), guid)
self.debug(msg)
-
return False
@property
return False
for attrname in ["mode", "type", "essid"]:
- attrval = self.get(attrname)
- attrname = "net/%s/%s" % (self._alias, attrname)
+ if attrname == "type" :
+ attrval = self._type
+ else :
+ attrval = self.get(attrname)
+ attrname = "net/%s/%s" % (self.alias, attrname)
self._omf_api.configure(self.node.get('hostname'), attrname,
attrval)
def configure_ip(self):
""" Configure the ip of the interface
+ .. note : The ip is separated from the others parameters to avoid
+ CELL ID shraing problem. By putting th ip at the end of the configuration,
+ each node use the same channel and can then share the same CELL ID.
+ In the second case, the channel is defined at the end and the node don't
+ share a common CELL ID and can not communicate.
+
"""
if self.channel.state < ResourceState.READY:
self.ec.schedule(reschedule_delay, self.deploy)
return False
attrval = self.get("ip")
- attrname = "net/%s/%s" % (self._alias, "ip")
+ if '/' in attrval:
+ attrval,mask = attrval.split('/')
+ attrname = "net/%s/%s" % (self.alias, "ip")
self._omf_api.configure(self.node.get('hostname'), attrname,
attrval)
-
return True
+
+ def configure_on_omf5(self):
+ """ Method to configure the wifi interface when OMF 5.4 is used.
+
+ """
+
+ self._type = self.get('hw_mode')
+ if self.get('name') == "wlan0" or "eth0":
+ self.alias = "w0"
+ else:
+ self.alias = "w1"
+ res = False
+ if self.state < ResourceState.PROVISIONED:
+ if self._conf == False:
+ self._conf = self.configure_iface()
+ if self._conf == True:
+ res = self.configure_ip()
+ return res
+
+ def check_deploy(self, cid):
+ """ Check, through the mail box in the parser,
+ if the confirmation of the creation has been received
+
+ :param cid: the id of the original message
+ :type guid: string
+
+ """
+ uid = self._omf_api.check_mailbox("create", cid)
+ if uid :
+ return uid
+ return False
+
def do_deploy(self):
""" Deploy the RM. It means : Get the xmpp client and send messages
- using OMF 5.4 protocol to configure the interface.
- It becomes DEPLOYED after sending messages to configure the interface
+ using OMF 5.4 or 6 protocol to configure the interface.
+
"""
- self.set('xmppSlice',self.node.get('xmppSlice'))
- self.set('xmppHost',self.node.get('xmppHost'))
+ if not self.node or self.node.state < ResourceState.READY:
+ self.debug("---- RESCHEDULING DEPLOY ---- node state %s "
+ % self.node.state )
+ self.ec.schedule(reschedule_delay, self.deploy)
+ return
+
+ if not self.channel or self.channel.state < ResourceState.READY:
+ self.debug("---- RESCHEDULING DEPLOY ---- channel state %s "
+ % self.channel.state )
+ self.ec.schedule(reschedule_delay, self.deploy)
+ return
+
+ self.set('xmppUser',self.node.get('xmppUser'))
+ self.set('xmppServer',self.node.get('xmppServer'))
self.set('xmppPort',self.node.get('xmppPort'))
self.set('xmppPassword',self.node.get('xmppPassword'))
+ self.set('version',self.node.get('version'))
- if not (self.get('xmppSlice') and self.get('xmppHost')
- and self.get('xmppPort') and self.get('xmppPassword')):
- msg = "Credentials are not initialzed. XMPP Connections impossible"
+ if not self.get('xmppServer'):
+ msg = "XmppServer is not initialzed. XMPP Connections impossible"
self.error(msg)
raise RuntimeError, msg
+ if not (self.get('xmppUser') or self.get('xmppPort')
+ or self.get('xmppPassword')):
+ msg = "Credentials are not all initialzed. Default values will be used"
+ self.warn(msg)
+
if not self._omf_api :
- self._omf_api = OMFAPIFactory.get_api(self.get('xmppSlice'),
- self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.exp_id)
+ self._omf_api = OMFAPIFactory.get_api(self.get('version'),
+ self.get('xmppServer'), self.get('xmppUser'), self.get('xmppPort'),
+ self.get('xmppPassword'), exp_id = self.exp_id)
- if not (self.get('mode') and self.get('type') and self.get('essid') \
- and self.get('ip')):
- msg = "Interface's variable are not initialized"
+ if not (self.get('name')):
+ msg = "Interface's name is not initialized"
self.error(msg)
raise RuntimeError, msg
- if not self.node.get('hostname') :
- msg = "The channel is connected with an undefined node"
+ if not (self.get('mode') and self.get('essid') \
+ and self.get('hw_mode') and self.get('ip')):
+ msg = "Interface's variable are not initialized"
self.error(msg)
raise RuntimeError, msg
- # Just for information
- self.info(" " + self.get_rtype() + " ( Guid : " + str(self._guid) +") : " + \
- self.get('mode') + " : " + self.get('type') + " : " + \
- self.get('essid') + " : " + self.get('ip') + " : " + str(self.state))
+ if self.get('version') == "5":
+ res = self.configure_on_omf5()
+
+ else :
+ res = self.configure_on_omf6()
+
+ if res:
+ super(OMFWifiInterface, self).do_deploy()
+
+ def configure_on_omf6(self):
+ """ Method to configure the wifi interface when OMF 6 is used.
+
+ """
+ if not self.create_id :
+ props = {}
+ props['wlan:if_name'] = self.get('name')
+ props['wlan:mode'] = {
+ "mode": self.get('mode'),
+ "hw_mode" : self.get('hw_mode'),
+ "channel" : self.channel.get('channel'),
+ "essid" : self.get('essid'),
+ "ip_addr" : self.get('ip'),
+ "frequency" : self.channel.frequency,
+ "phy" : "%0%"
+ }
+ props['wlan:hrn'] = self.get('name')
+ props['wlan:type'] = "wlan"
- # Check if the node is already deployed
- if self.state < ResourceState.PROVISIONED:
- if self._conf == False:
- self._conf = self.configure_iface()
- res = False
- if self._conf == True:
- res = self.configure_ip()
-
- if not (res and self._conf):
- return
+ self.create_id = os.urandom(16).encode('hex')
+ self._omf_api.frcp_create( self.create_id, self.node.get('hostname'), "wlan", props = props)
+
+ if self._create_cnt > confirmation_counter:
+ msg = "Couldn't retrieve the confirmation of the creation"
+ self.error(msg)
+ raise RuntimeError, msg
+
+ uid = self.check_deploy(self.create_id)
+ if not uid:
+ self._create_cnt +=1
+ self.ec.schedule(reschedule_check, self.deploy)
+ return False
+
+ self._topic_iface = uid
+ self._omf_api.enroll_topic(self._topic_iface)
+ return True
+
+ def check_release(self, cid):
+ """ Check, through the mail box in the parser,
+ if the confirmation of the release has been received
+
+ :param cid: the id of the original message
+ :type guid: string
- super(OMFWifiInterface, self).do_deploy()
+ """
+ res = self._omf_api.check_mailbox("release", cid)
+ if res :
+ return res
+ return False
def do_release(self):
""" Clean the RM at the end of the experiment and release the API
"""
if self._omf_api:
- OMFAPIFactory.release_api(self.get('xmppSlice'),
- self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.exp_id)
+ if self.get('version') == "6":
+ if not self.release_id:
+ self.release_id = os.urandom(16).encode('hex')
+ self._omf_api.frcp_release( self.release_id, self.node.get('hostname'),self._topic_iface, res_id=self._topic_iface)
+
+ if self._release_cnt < confirmation_counter:
+ cid = self.check_release(self.release_id)
+ if not cid:
+ self._release_cnt +=1
+ self.ec.schedule(reschedule_check, self.release)
+ return
+ else:
+ msg = "Couldn't retrieve the confirmation of the release"
+ self.error(msg)
+
+
+ OMFAPIFactory.release_api(self.get('version'),
+ self.get('xmppServer'), self.get('xmppUser'), self.get('xmppPort'),
+ self.get('xmppPassword'), exp_id = self.exp_id)
super(OMFWifiInterface, self).do_release()
--- /dev/null
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+# Julien Tribino <julien.tribino@inria.fr>
+
+from xml.etree import cElementTree as ET
+
+class MessageHandler():
+ """
+ .. class:: Class Args :
+
+ :param sliceid: Slice Name (= Xmpp Slice)
+ :type expid: str
+ :param expid: Experiment ID (= Xmpp User)
+ :type expid: str
+
+ .. note::
+
+ This class is used only for OMF 5.4 Protocol and is going to become unused
+
+ """
+
+ def __init__(self):
+ """
+
+ """
+ pass
+
+ def _type_element(self, type_elt, xmlns, msg_id):
+ """ Insert a markup element with an id
+
+ """
+ elt = ET.Element(type_elt)
+ elt.set("xmlns", xmlns)
+ elt.set("mid", msg_id)
+ return elt
+
+
+
+ def _attr_element(self, parent, markup, text, type_key=None, type_value = None):
+ """ Insert a markup element with a text (value)
+
+ :param parent: Parent element in an XML point of view
+ :type parent: ElementTree Element
+ :param markup: Name of the markup
+ :type markup: str
+ :param text: Value of the markup element
+ :type text: str
+
+ """
+ elt = ET.SubElement(parent, markup)
+ if type_key and type_value:
+ elt.set(type_key, type_value)
+ elt.text = text
+ return elt
+
+ def _id_element(self, parent, markup, key, value):
+ """ Insert a markup element with a text (value)
+
+ :param parent: Parent element in an XML point of view
+ :type parent: ElementTree Element
+ :param markup: Name of the markup
+ :type markup: str
+ :param text: Value of the markup element
+ :type text: str
+
+ """
+ elt = ET.SubElement(parent, markup)
+ elt.set(key, value)
+ return elt
+
+ def create_function(self, msg_id, src, rtype, timestamp, props = None, guards = None):
+ """ Build a create message
+
+ :param msg_id: Id of the message
+ :type msg_id: str
+ :param src: Src node that send the message (jabber source)
+ :type src: str
+ :param rtype: Type of the object
+ :type rtype: str
+ :param timestamp: Unix Timestamp
+ :type timestamp: str
+ :param props: List of properties
+ :type props: list
+ :param guards: list of guards (assertions for properties)
+ :type guards: list
+ """
+ payload = self._type_element("create", "http://schema.mytestbed.net/omf/6.0/protocol", msg_id )
+ self._attr_element(payload,"src",src)
+ self._attr_element(payload,"ts",timestamp)
+ self._attr_element(payload,"rtype",rtype)
+
+ if props :
+ if rtype == "application" :
+ properties = self._id_element(payload,"props","xmlns:application",
+ "http://schema.mytestbed.net/omf/6.0/protocol/application")
+ elif rtype == "wlan" :
+ properties = self._id_element(payload,"props","xmlns:wlan",
+ "http://schema.mytestbed.net/omf/6.0/protocol/wlan")
+ else:
+ properties = self._attr_element(payload,"props","")
+
+ for prop in props.keys():
+ if isinstance(props[prop],str):
+ self._attr_element(properties,prop,props[prop],type_key="type", type_value = "string")
+ elif isinstance(props[prop],dict):
+ key = self._attr_element(properties,prop,"",type_key="type", type_value = "hash")
+ for comp in props[prop].keys():
+ self._attr_element(key,comp,props[prop][comp],type_key="type", type_value = "string")
+
+ if guards :
+ guardians = self._attr_element(payload,"guard","")
+ for guard in guards.keys():
+ self._attr_element(guardians,guard,guards[guard],type_key="type", type_value = "string")
+
+ return payload
+
+ def configure_function(self, msg_id, src, timestamp, props = None, guards = None):
+ """ Build a configure message
+
+ :param msg_id: Id of the message
+ :type msg_id: str
+ :param src: Src node that send the message (jabber source)
+ :type src: str
+ :param timestamp: Unix Timestamp
+ :type timestamp: str
+ :param props: List of properties
+ :type props: list
+ :param guards: list of guards (assertions for properties)
+ :type guards: list
+ """
+ payload = self._type_element("configure", "http://schema.mytestbed.net/omf/6.0/protocol", msg_id )
+ self._attr_element(payload,"src",src)
+ self._attr_element(payload,"ts",timestamp)
+
+ if props :
+ properties = self._attr_element(payload,"props","")
+ for prop in props.keys():
+ self._attr_element(properties,prop,props[prop],type_key="type", type_value = "symbol")
+
+ if guards :
+ guardians = self._attr_element(payload,"guard","")
+ for guard in guards.keys():
+ self._attr_element(guardians,guard,guards[guard],type_key="type", type_value = "string")
+
+ return payload
+
+ def request_function(self, msg_id, src, timestamp, props = None, guards = None):
+ """ Build a request message
+
+ :param msg_id: Id of the message
+ :type msg_id: str
+ :param src: Src node that send the message (jabber source)
+ :type src: str
+ :param timestamp: Unix Timestamp
+ :type timestamp: str
+ :param props: List of properties
+ :type props: list
+ :param guards: list of guards (assertions for properties)
+ :type guards: list
+ """
+ payload = self._type_element("request", "http://schema.mytestbed.net/omf/6.0/protocol", msg_id )
+ self._attr_element(payload,"src",src)
+ self._attr_element(payload,"ts",timestamp)
+
+ if props :
+ properties = self._attr_element(payload,"props","")
+ for prop in props.keys():
+ self._attr_element(properties,prop,props[prop])
+
+ if guards :
+ guardians = self._attr_element(payload,"guard","")
+ for guard in guards.keys():
+ self._attr_element(guardians,guard,guards[guard])
+ return payload
+
+# For now, we don't need the inform message since it is ht RC that send them.
+
+# def inform_function(self, msg_id, src, timestamp, cid, itype):
+# """ Build an inform message
+
+# :param msg_id: Id of the message
+# :type msg_id: str
+# :param src: Src node that send the message (jabber source)
+# :type src: str
+# :param rtype: Type of the object
+# :type rtype: str
+# :param timestamp: Unix Timestamp
+# :type timestamp: str
+# :param cid: Id of the orignial message
+# :type cid: str
+# :param itype: type of the object created
+# :type itype: str
+# """
+
+# payload = self._type_element("inform", "http://schema.mytestbed.net/omf/6.0/protocol", msg_id )
+# sliceid = self._attr_element(payload,"src",src)
+# expid = self._attr_element(config,"ts",timestamp)
+# target = self._attr_element(config,"cid",cid)
+# value = self._attr_element(config,"itype",value)
+# path = self._attr_element(config,"properties",path)
+# return payload
+
+ def release_function(self, msg_id, src, timestamp, res_id = None, props = None, guards = None):
+ """ Build a release message
+
+ :param msg_id: Id of the message
+ :type msg_id: str
+ :param src: Src node that send the message (jabber source)
+ :type src: str
+ :param timestamp: Unix Timestamp
+ :type timestamp: str
+ :param res_id: Id of the release resource
+ :type res_id: str
+ :param props: List of properties
+ :type props: list
+ :param guards: list of guards (assertions for properties)
+ :type guards: list
+ """
+ payload = self._type_element("release", "http://schema.mytestbed.net/omf/6.0/protocol", msg_id )
+ self._attr_element(payload,"src",src)
+ self._attr_element(payload,"ts",timestamp)
+ if res_id :
+ self._attr_element(payload,"res_id",res_id)
+
+ if props :
+ properties = self._id_element(payload,"props","xmlns:frcp",
+ "http://schema.mytestbed.net/omf/6.0/protocol")
+ for prop in props.keys():
+ self._attr_element(properties,prop,props[prop])
+
+ if guards :
+ guardians = self._attr_element(payload,"guard","")
+ for guard in guards.keys():
+ self._attr_element(guardians,guard,guards[guard])
+
+ return payload
+
ResourceState, reschedule_delay
from nepi.execution.attribute import Attribute, Flags
from nepi.resources.omf.omf_resource import ResourceGateway, OMFResource
-from nepi.resources.omf.omf_api import OMFAPIFactory
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
import time
+reschedule_check = "0.3s"
+confirmation_counter = 300
+
@clsinit_copy
class OMFNode(OMFResource):
"""
msg = "Connection between %s %s and %s %s accepted" % (
self.get_rtype(), self._guid, rm.get_rtype(), guid)
self.debug(msg)
-
return True
msg = "Connection between %s %s and %s %s refused" % (
self.get_rtype(), self._guid, rm.get_rtype(), guid)
- self.debug(msg)
+ self.error(msg)
return False
def do_deploy(self):
""" Deploy the RM. It means : Send Xmpp Message Using OMF protocol
to enroll the node into the experiment.
- It becomes DEPLOYED after sending messages to enroll the node
"""
- if not (self.get('xmppSlice') and self.get('xmppHost')
- and self.get('xmppPort') and self.get('xmppPassword')):
- msg = "Credentials are not initialzed. XMPP Connections impossible"
+ if not self.get('xmppServer'):
+ msg = "XmppServer is not initialzed. XMPP Connections impossible"
+ self.error(msg)
+ raise RuntimeError, msg
+
+ if not self.get('version'):
+ msg = "Version of OMF is not indicated"
self.error(msg)
raise RuntimeError, msg
+ if not (self.get('xmppUser') or self.get('xmppPort')
+ or self.get('xmppPassword')):
+ msg = "Credentials are not all initialzed. Default values will be used"
+ self.warn(msg)
+
if not self._omf_api :
- self._omf_api = OMFAPIFactory.get_api(self.get('xmppSlice'),
- self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.exp_id)
+ self._omf_api = OMFAPIFactory.get_api(self.get('version'),
+ self.get('xmppServer'), self.get('xmppUser'), self.get('xmppPort'),
+ self.get('xmppPassword'), exp_id = self.exp_id)
if not self.get('hostname') :
msg = "Hostname's value is not initialized"
self.error(msg)
raise RuntimeError, msg
- self._omf_api.enroll_host(self.get('hostname'))
+ if self.get('version') == "5":
+ self._omf_api.enroll_host(self.get('hostname'))
+ else:
+ self._omf_api.enroll_topic(self.get('hostname'))
super(OMFNode, self).do_deploy()
def do_release(self):
- """ Clean the RM at the end of the experiment
+ """ Clean the RM at the end of the experiment by unenrolling
+ the node from the topic
"""
- if self._omf_api:
- self._omf_api.release(self.get('hostname'))
+ from nepi.resources.omf.application import OMFApplication
+ rm_list = self.get_connected(OMFApplication.get_rtype())
+ if rm_list:
+ for rm in rm_list:
+ if rm.state < ResourceState.RELEASED:
+ self.ec.schedule(reschedule_delay, self.release)
+ return
+
+ from nepi.resources.omf.interface import OMFWifiInterface
+ rm_list = self.get_connected(OMFWifiInterface.get_rtype())
+ if rm_list:
+ for rm in rm_list:
+ if rm.state < ResourceState.RELEASED:
+ self.ec.schedule(reschedule_delay, self.release)
+ return
- OMFAPIFactory.release_api(self.get('xmppSlice'),
- self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.exp_id)
+ if self._omf_api:
+ if self.get('version') == "5":
+ self._omf_api.release(self.get('hostname'))
+ else:
+ self._omf_api.unenroll_topic(self.get('hostname'))
+
+ OMFAPIFactory.release_api(self.get('version'),
+ self.get('xmppServer'), self.get('xmppUser'), self.get('xmppPort'),
+ self.get('xmppPassword'), exp_id = self.exp_id)
super(OMFNode, self).do_release()
import ssl
import sys
import time
-import hashlib
-import threading
from nepi.util.logger import Logger
from nepi.resources.omf.omf_client import OMFClient
from nepi.resources.omf.messages_5_4 import MessageHandler
-class OMFAPI(Logger):
+class OMF5API(Logger):
"""
.. class:: Class Args :
- :param slice: Xmpp Slice
- :type slice: str
:param host: Xmpp Server
:type host: str
+ :param slice: Xmpp Slice
+ :type slice: str
:param port: Xmpp Port
:type port: str
:param password: Xmpp password
instead of OMF used for OMF5.3
"""
- def __init__(self, slice, host, port, password, xmpp_root = None,
+ def __init__(self, host, slice, port, password, xmpp_root = None,
exp_id = None):
"""
-
- :param slice: Xmpp Slice
- :type slice: str
:param host: Xmpp Server
:type host: str
+ :param slice: Xmpp Slice
+ :type slice: str
:param port: Xmpp Port
:type port: str
:param password: Xmpp password
:type xmpp_root: str
"""
- super(OMFAPI, self).__init__("OMFAPI")
+ super(OMF5API, self).__init__("OMF5API")
self._exp_id = exp_id
self._user = "%s-%s" % (slice, self._exp_id)
self._slice = slice
:type value: str
"""
-
payload = self._message.configure_function(hostname, value, attribute)
xmpp_node = self._host_session_id(hostname)
self._client.publish(payload, xmpp_node)
msg = " Disconnected from XMPP Server"
self.debug(msg)
-
-class OMFAPIFactory(object):
- """
- .. note::
-
- It allows the different RM to use the same xmpp client if they use
- the same credentials. For the moment, it is focused on XMPP.
-
- """
- # use lock to avoid concurrent access to the Api list at the same times by 2
- # different threads
- lock = threading.Lock()
- _apis = dict()
-
- @classmethod
- def get_api(cls, slice, host, port, password, exp_id = None):
- """ Get an OMF Api
-
- :param slice: Xmpp Slice Name
- :type slice: str
- :param host: Xmpp Server Adress
- :type host: str
- :param port: Xmpp Port (Default : 5222)
- :type port: str
- :param password: Xmpp Password
- :type password: str
-
- """
- if slice and host and port and password:
- key = cls._make_key(slice, host, port, password, exp_id)
- cls.lock.acquire()
- if key in cls._apis:
- #print "Api Counter : " + str(cls._apis[key]['cnt'])
- cls._apis[key]['cnt'] += 1
- cls.lock.release()
- return cls._apis[key]['api']
- else :
- omf_api = cls.create_api(slice, host, port, password, exp_id)
- cls.lock.release()
- return omf_api
- return None
-
- @classmethod
- def create_api(cls, slice, host, port, password, exp_id):
- """ Create an OMF API if this one doesn't exist yet with this credentials
-
- :param slice: Xmpp Slice Name
- :type slice: str
- :param host: Xmpp Server Adress
- :type host: str
- :param port: Xmpp Port (Default : 5222)
- :type port: str
- :param password: Xmpp Password
- :type password: str
-
- """
- omf_api = OMFAPI(slice, host, port, password, exp_id = exp_id)
- key = cls._make_key(slice, host, port, password, exp_id)
- cls._apis[key] = {}
- cls._apis[key]['api'] = omf_api
- cls._apis[key]['cnt'] = 1
- return omf_api
-
- @classmethod
- def release_api(cls, slice, host, port, password, exp_id = None):
- """ Release an OMF API with this credentials
-
- :param slice: Xmpp Slice Name
- :type slice: str
- :param host: Xmpp Server Adress
- :type host: str
- :param port: Xmpp Port (Default : 5222)
- :type port: str
- :param password: Xmpp Password
- :type password: str
-
- """
- if slice and host and port and password:
- key = cls._make_key(slice, host, port, password, exp_id)
- if key in cls._apis:
- cls._apis[key]['cnt'] -= 1
- #print "Api Counter : " + str(cls._apis[key]['cnt'])
- if cls._apis[key]['cnt'] == 0:
- omf_api = cls._apis[key]['api']
- omf_api.disconnect()
-
-
- @classmethod
- def _make_key(cls, *args):
- """ Hash the credentials in order to create a key
-
- :param args: list of arguments used to create the hash (user, host, port, ...)
- :type args: list of args
-
- """
- skey = "".join(map(str, args))
- return hashlib.md5(skey).hexdigest()
-
-
-
--- /dev/null
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+# Julien Tribino <julien.tribino@inria.fr>
+
+import ssl
+import sys
+import time
+
+from nepi.util.timefuncs import tsformat
+import os
+
+from nepi.util.logger import Logger
+
+from nepi.resources.omf.omf_client import OMFClient
+from nepi.resources.omf.messages_6 import MessageHandler
+
+class OMF6API(Logger):
+ """
+ .. class:: Class Args :
+
+ :param server: Xmpp Server
+ :type server: str
+ :param user: Xmpp User
+ :type user: str
+ :param port: Xmpp Port
+ :type port: str
+ :param password: Xmpp password
+ :type password: str
+ :param xmpp_root: Root of the Xmpp Topic Architecture
+ :type xmpp_root: str
+
+ .. note::
+
+ This class is the implementation of an OMF 5.4 API.
+ Since the version 5.4.1, the Topic Architecture start with OMF_5.4
+ instead of OMF used for OMF5.3
+
+ """
+ def __init__(self, server, user = "nepi", port="5222", password="1234",
+ exp_id = None):
+ """
+ :param server: Xmpp Server
+ :type server: str
+ :param user: Xmpp User
+ :type user: str
+ :param port: Xmpp Port
+ :type port: str
+ :param password: Xmpp password
+ :type password: str
+ :param xmpp_root: Root of the Xmpp Topic Architecture
+ :type xmpp_root: str
+
+ """
+ super(OMF6API, self).__init__("OMF6API")
+ self._exp_id = exp_id
+ self._user = user # name of the machine that run Nepi
+ self._server = server # name of the xmpp server
+ self._port = port # port of the xmpp server
+ self._password = password # password to connect to xmpp
+ self._jid = "%s-%s@%s" % (self._user, self._exp_id, self._server)
+ self._src = "xmpp://" + self._jid
+
+ self._topics = []
+
+ # OMF xmpp client
+ self._client = None
+
+ # message handler
+ self._message = None
+
+ if sys.version_info < (3, 0):
+ reload(sys)
+ sys.setdefaultencoding('utf8')
+
+ # instantiate the xmpp client
+ self._init_client()
+
+ # register nepi topic
+ self._enroll_nepi()
+
+
+ def _init_client(self):
+ """ Initialize XMPP Client
+
+ """
+ xmpp = OMFClient(self._jid, self._password)
+ # PROTOCOL_SSLv3 required for compatibility with OpenFire
+ xmpp.ssl_version = ssl.PROTOCOL_SSLv3
+
+ if xmpp.connect((self._server, self._port)):
+ xmpp.process(block=False)
+ self.check_ready(xmpp)
+ self._client = xmpp
+ self._message = MessageHandler()
+ else:
+ msg = "Unable to connect to the XMPP server."
+ self.error(msg)
+ raise RuntimeError(msg)
+
+ def check_ready(self, xmpp):
+ delay = 1.0
+ for i in xrange(4):
+ if xmpp.ready:
+ break
+ else:
+ time.sleep(delay)
+ delay = delay * 1.5
+ else:
+ msg = "XMPP Client is not ready after long time"
+ self.error(msg, out, err)
+ raise RuntimeError, msg
+
+ @property
+ def _nepi_topic(self):
+ """ Return the name of the session topic
+
+ """
+ msg = "nepi-" + self._exp_id
+ self.debug(msg)
+ return msg
+
+ def _enroll_nepi(self):
+ """ Create and Subscribe to the session Topic
+
+ """
+ nepi_topic = self._nepi_topic
+ self._client.create(nepi_topic)
+ self._client.subscribe(nepi_topic)
+
+
+ def create_and_enroll_topic(self, topic):
+ """ Create and Subscribe to the session topic and the resources
+ corresponding to the hostname
+
+ :param hostname: Full hrn of the node
+ :type hostname: str
+
+ """
+ if topic in self._topics:
+ return
+
+ self._topics.append(topic)
+
+ self._client.create(topic)
+ self._client.subscribe(topic)
+
+
+ def enroll_topic(self, topic):
+ """ Create and Subscribe to the session topic and the resources
+ corresponding to the hostname
+
+ """
+ if topic in self._topics:
+ return
+
+ self._topics.append(topic)
+ self._client.subscribe(topic)
+
+
+ def frcp_inform(self, topic, cid, itype):
+ """ Publish an inform message
+
+ """
+ msg_id = os.urandom(16).encode('hex')
+ timestamp = tsformat()
+ payload = self._message.inform_function(msg_id, self._src, timestamp, props = props ,guards = guards)
+
+ self._client.publish(payload, xmpp_node)
+
+ def frcp_configure(self, topic, props = None, guards = None ):
+ """ Publish a configure message
+
+ """
+ msg_id = os.urandom(16).encode('hex')
+ timestamp = tsformat()
+ payload = self._message.configure_function(msg_id, self._src, timestamp ,props = props ,guards = guards)
+ self._client.publish(payload, topic)
+
+
+ def frcp_create(self, msg_id, topic, rtype, props = None, guards = None ):
+ """ Publish a create message
+
+ """
+ timestamp = tsformat()
+ payload = self._message.create_function(msg_id, self._src, rtype, timestamp , props = props ,guards = guards)
+ self._client.publish(payload, topic)
+
+
+ def frcp_request(self, topic, props = None, guards = None ):
+ """ Execute command on the node
+
+ """
+ msg_id = os.urandom(16).encode('hex')
+ timestamp = tsformat()
+ payload = self._message.request_function(msg_id, self._src, timestamp, props = props ,guards = guards)
+ self._client.publish(payload, xmpp_node)
+
+ def frcp_release(self, msg_id, parent, child, res_id = None, props = None, guards = None ):
+ """ Publish a release message
+
+ """
+ timestamp = tsformat()
+ payload = self._message.release_function(msg_id, self._src, timestamp, res_id = res_id, props = props ,guards = guards)
+ self._client.publish(payload, parent)
+
+ if child in self._topics:
+ self._topics.remove(child)
+
+ self._client.unsubscribe(child)
+ #self._client.delete(child)
+
+ def check_mailbox(self, itype, attr):
+ """ Check the mail box
+
+ :param itype: type of mail
+ :type itype: str
+ :param attr: value wanted
+ :type attr: str
+
+ """
+ return self._client.check_mailbox(itype, attr)
+
+ def unenroll_topic(self, topic):
+ """ Create and Subscribe to the session topic and the resources
+ corresponding to the hostname
+
+ """
+ if topic in self._topics:
+ self._topics.remove(topic)
+ self._client.unsubscribe(topic)
+
+ def disconnect(self) :
+ """ Delete the session and logger topics. Then disconnect
+
+ """
+ self._client.delete(self._nepi_topic)
+
+ # Wait the send queue to be empty before disconnect
+ self._client.disconnect(wait=True)
+ msg = " Disconnected from XMPP Server"
+ self.debug(msg)
+
--- /dev/null
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+# Julien Tribino <julien.tribino@inria.fr>
+
+from nepi.util.logger import Logger
+
+import traceback
+import xml.etree.ElementTree as ET
+
+# inherit from BaseXmpp and XMLstream classes
+class OMF6Parser(Logger):
+ """
+ .. class:: Class Args :
+
+ :param jid: Jabber Id (= Xmpp Slice + Date)
+ :type jid: str
+ :param password: Jabber Password (= Xmpp Password)
+ :type password: str
+
+ .. note::
+
+ This class is an XMPP Client with customized method
+
+ """
+
+ def __init__(self):
+ """
+
+ :param jid: Jabber Id (= Xmpp Slice + Date)
+ :type jid: str
+ :param password: Jabber Password (= Xmpp Password)
+ :type password: str
+
+
+ """
+ super(OMF6Parser, self).__init__("OMF6API")
+ self.mailbox={}
+
+ self.init_mailbox()
+
+ def init_mailbox(self):
+ self.mailbox['create'] = []
+ self.mailbox['started'] = []
+ self.mailbox['release'] = []
+
+ def _check_for_tag(self, root, namespaces, tag):
+ """ Check if an element markup is in the ElementTree
+
+ :param root: Root of the tree
+ :type root: ElementTree Element
+ :param namespaces: Namespaces of the element
+ :type namespaces: str
+ :param tag: Tag that will search in the tree
+ :type tag: str
+
+ """
+ for element in root.iter(namespaces+tag):
+ if element.text:
+ return element.text
+ else :
+ return None
+
+ def _check_for_props(self, root, namespaces):
+ """ Check if an element markup is in the ElementTree
+
+ :param root: Root of the tree
+ :type root: ElementTree Element
+ :param namespaces: Namespaces of the element
+ :type namespaces: str
+
+ """
+ props = {}
+ for properties in root.iter(namespaces+'props'):
+ for element in properties.iter():
+ if element.tag and element.text:
+ props[element.tag] = element.text
+ return props
+
+ def _check_for_membership(self, root, namespaces):
+ """ Check if an element markup is in the ElementTree
+
+ :param root: Root of the tree
+ :type root: ElementTree Element
+ :param namespaces: Namespaces of the element
+ :type namespaces: str
+
+ """
+ for element in root.iter(namespaces+'membership'):
+ for elt in element.iter(namespaces+'it'):
+ ##XXX : change
+ return elt.text
+
+
+ def _check_output(self, root, namespaces):
+ """ Check the significative element in the answer and display it
+
+ :param root: Root of the tree
+ :type root: ElementTree Element
+ :param namespaces: Namespaces of the tree
+ :type namespaces: str
+
+ """
+ fields = ["TARGET", "REASON", "PATH", "APPID", "VALUE"]
+ response = ""
+ for elt in fields:
+ msg = self._check_for_tag(root, namespaces, elt)
+ if msg is not None:
+ response = response + " " + msg.text + " :"
+ deb = self._check_for_tag(root, namespaces, "MESSAGE")
+ if deb is not None:
+ msg = response + " " + deb.text
+ self.debug(msg)
+ else :
+ self.info(response)
+
+
+ def _inform_creation_ok(self, root, namespaces):
+ """ Parse and Display CREATION OK message
+
+ """
+ #ET.dump(root)
+ uid = self._check_for_tag(root, namespaces, "uid")
+ cid = self._check_for_tag(root, namespaces, "cid")
+ member = self._check_for_membership(root, namespaces)
+ binary_path = self._check_for_tag(root, namespaces, "binary_path")
+ msg = "CREATION OK -- "
+ if binary_path :
+ msg = msg + "The resource : '"+binary_path
+ else :
+ msg = msg + "The interface"
+ if uid :
+ msg = msg + "' is listening to the topics : '"+ uid
+ if member :
+ msg = msg + "' and '"+ member +"'"
+ if cid:
+ self.info(msg)
+ self.mailbox['create'].append([cid, uid ])
+
+ def _inform_creation_failed(self, root, namespaces):
+ """ Parse and Display CREATION FAILED message
+
+ """
+ reason = self._check_for_tag(root, namespaces, "reason")
+ cid = self._check_for_tag(root, namespaces, "cid")
+ msg = "CREATION FAILED - The reason : "+reason
+ if cid:
+ self.error(msg)
+ self.mailbox['create'].append([cid, uid ])
+
+ def _inform_status(self, root, namespaces):
+ """ Parse and Display STATUS message
+
+ """
+ props = self._check_for_props(root, namespaces)
+ uid = self._check_for_tag(root, namespaces, "uid")
+ msg = "STATUS -- "
+ for elt in props.keys():
+ ns, tag = elt.split('}')
+ if tag == "it":
+ msg = msg + "membership : " + props[elt]+" -- "
+ elif tag == "event":
+ self.mailbox['started'].append(uid)
+ msg = msg + "event : " + props[elt]+" -- "
+ else:
+ msg = msg + tag +" : " + props[elt]+" -- "
+ msg = msg + " STATUS "
+ self.info(msg)
+
+ def _inform_released(self, root, namespaces):
+ """ Parse and Display RELEASED message
+
+ """
+ #ET.dump(root)
+ parent_id = self._check_for_tag(root, namespaces, "src")
+ child_id = self._check_for_tag(root, namespaces, "res_id")
+ cid = self._check_for_tag(root, namespaces, "cid")
+ if cid :
+ msg = "RELEASED - The resource : '"+child_id+ \
+ "' has been released by : '"+ parent_id
+ self.info(msg)
+ self.mailbox['release'].append(cid)
+
+ def _inform_error(self, root, namespaces):
+ """ Parse and Display ERROR message
+
+ """
+ reason = self._check_for_tag(root, namespaces, "reason")
+ msg = "The reason : "+reason
+ self.error(msg)
+
+ def _inform_warn(self, root, namespaces):
+ """ Parse and Display WARN message
+
+ """
+ reason = self._check_for_tag(root, namespaces, "reason")
+ msg = "The reason : "+reason
+ self.warn(msg)
+
+ def _parse_inform(self, root, namespaces):
+ """ Check the significative element in the answer
+ Then Parse it and display using specific method
+
+ :param root: Root of the tree
+ :type root: ElementTree Element
+ :param namespaces: Namespaces of the tree
+ :type namespaces: str
+
+ """
+ itype = self._check_for_tag(root, namespaces, "itype")
+ if itype :
+ method_name = '_inform_'+ itype.replace('.', '_').lower()
+ method = getattr(self, method_name)
+ if method :
+ method(root, namespaces)
+ else :
+ msg = "There is no method to parse the response of the type " + itype
+ self.info(msg)
+ return
+
+
+ def check_mailbox(self, itype, attr):
+ """ Check the mail box
+
+ :param itype: type of mail
+ :type itype: str
+ :param attr: value wanted
+ :type attr: str
+
+ """
+ if itype == "create":
+ for res in self.mailbox[itype]:
+ binary, uid = res
+ if binary == attr:
+ self.mailbox[itype].remove(res)
+ return uid
+ else :
+ for res in self.mailbox[itype]:
+ if attr == res:
+ self.mailbox[itype].remove(res)
+ return res
+
+
+ def handle(self, iq):
+ """ Check the mail box
+
+ :param iq: message received
+ :type itype: iq
+ """
+ namespaces = "{http://schema.mytestbed.net/omf/6.0/protocol}"
+ for i in iq['pubsub_event']['items']:
+ root = ET.fromstring(str(i))
+ #ET.dump(root)
+ self._parse_inform(root, namespaces)
+
--- /dev/null
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+# Julien Tribino <julien.tribino@inria.fr>
+
+
+import time
+import hashlib
+import threading
+
+from nepi.resources.omf.omf5_api import OMF5API
+from nepi.resources.omf.omf6_api import OMF6API
+
+class OMFAPIFactory(object):
+ """
+ .. note::
+
+ It allows the different RM to use the same xmpp client if they use
+ the same credentials. For the moment, it is focused on XMPP.
+
+ """
+ # use lock to avoid concurrent access to the Api list at the same times by 2
+ # different threads
+ lock = threading.Lock()
+ _apis = dict()
+
+ @classmethod
+ def get_api(cls, version, server, user, port, password, exp_id = None):
+ """ Get an OMF Api
+
+ :param version: OMF Version. Either 5 or 6
+ :type version: str
+ :param server: Xmpp Server Adress
+ :type server: str
+ :param user: Xmpp User
+ :type user: str
+ :param port: Xmpp Port (Default : 5222)
+ :type port: str
+ :param password: Xmpp Password
+ :type password: str
+ :param exp_id: Id of the experiment
+ :type exp_id: str
+
+ """
+ if version and user and server and port and password:
+ key = cls._make_key(version, server, user, port, password, exp_id)
+ cls.lock.acquire()
+ if key in cls._apis:
+ #print "Api Counter : " + str(cls._apis[key]['cnt'])
+ cls._apis[key]['cnt'] += 1
+ cls.lock.release()
+ return cls._apis[key]['api']
+ else :
+ omf_api = cls.create_api(version, server, user, port, password, exp_id)
+ cls.lock.release()
+ return omf_api
+ return None
+
+ @classmethod
+ def create_api(cls, version, server, user, port, password, exp_id):
+ """ Create an OMF API if this one doesn't exist yet with this credentials
+
+ :param version: OMF Version. Either 5 or 6
+ :type version: str
+ :param server: Xmpp Server Adress
+ :type server: str
+ :param user: Xmpp User
+ :type user: str
+ :param port: Xmpp Port (Default : 5222)
+ :type port: str
+ :param password: Xmpp Password
+ :type password: str
+ :param exp_id: Id of the experiment
+ :type exp_id: str
+
+ """
+ key = cls._make_key(version, server, user, port, password, exp_id)
+ if version == "5":
+ omf_api = OMF5API(server, user, port, password, exp_id = exp_id)
+ else :
+ omf_api = OMF6API(server, user = user, port = port, password = password, exp_id = exp_id)
+ cls._apis[key] = {}
+ cls._apis[key]['api'] = omf_api
+ cls._apis[key]['cnt'] = 1
+ return omf_api
+
+ @classmethod
+ def release_api(cls, version, server, user, port, password, exp_id = None):
+ """ Release an OMF API with this credentials
+
+ :param version: OMF Version. Either 5 or 6
+ :type version: str
+ :param server: Xmpp Server Adress
+ :type server: str
+ :param user: Xmpp User
+ :type user: str
+ :param port: Xmpp Port (Default : 5222)
+ :type port: str
+ :param password: Xmpp Password
+ :type password: str
+ :param exp_id: Id of the experiment
+ :type exp_id: str
+
+ """
+ if version and user and server and port and password:
+ key = cls._make_key(version, server, user, port, password, exp_id)
+ if key in cls._apis:
+ cls._apis[key]['cnt'] -= 1
+ #print "Api Counter : " + str(cls._apis[key]['cnt'])
+ if cls._apis[key]['cnt'] == 0:
+ omf_api = cls._apis[key]['api']
+ omf_api.disconnect()
+
+
+ @classmethod
+ def _make_key(cls, *args):
+ """ Hash the credentials in order to create a key
+
+ :param args: list of arguments used to create the hash (server, user, port, ...)
+ :type args: list
+
+ """
+ skey = "".join(map(str, args))
+ return hashlib.md5(skey).hexdigest()
+
+
+
# Julien Tribino <julien.tribino@inria.fr>
from nepi.util.logger import Logger
-
+from nepi.resources.omf.omf6_parser import OMF6Parser
try:
import sleekxmpp
from sleekxmpp.exceptions import IqError, IqTimeout
self._ready = False
self._registered = False
self._server = None
+ self._parser = None
self.register_plugin('xep_0077') # In-band registration
self.register_plugin('xep_0030')
self.add_event_handler("session_start", self.start)
self.add_event_handler("register", self.register)
self.add_event_handler("pubsub_publish", self.handle_omf_message)
+
+ #Init the parser
+ self._init_parser()
+ def _init_parser(self):
+ """ Init the parser depending on the OMF Version
+
+ """
+ self._parser = OMF6Parser()
+
@property
def ready(self):
""" Check if the client is ready
try:
self['xep_0060'].create_node(self._server, node, config = config)
except:
- error = traceback.format_exc()
- msg = ' Could not create topic: %s\ntraceback:\n%s' % (node, error)
+ #error = traceback.format_exc()
+ #msg = ' Could not create topic: %s\ntraceback:\n%s' % (node, error)
+ msg = 'Could not create the topic : '+node+' . Maybe the topic already exists'
self.error(msg)
def delete(self, node):
msg = ' Deleted node: %s' % node
self.info(msg)
except:
- error = traceback.format_exc()
- msg = ' Could not delete topic: %s\ntraceback:\n%s' % (node, error)
+ #error = traceback.format_exc()
+ #msg = ' Could not delete topic: %s\ntraceback:\n%s' % (node, error)
+ msg = 'Could not delete the topic : '+node+' . Maybe It is not the owner of the topic'
self.error(msg)
def publish(self, data, node):
% (self.boundjid.bare, node, error)
self.error(msg)
- def _check_for_tag(self, root, namespaces, tag):
- """ Check if an element markup is in the ElementTree
+ def check_mailbox(self, itype, attr):
+ """ Check the mail box
- :param root: Root of the tree
- :type root: ElementTree Element
- :param namespaces: Namespaces of the element
- :type namespaces: str
- :param tag: Tag that will search in the tree
- :type tag: str
+ :param itype: type of mail
+ :type itype: str
+ :param attr: value wanted
+ :type attr: str
"""
- for element in root.iter(namespaces+tag):
- if element.text:
- return element
- else :
- return None
-
- def _check_output(self, root, namespaces):
- """ Check the significative element in the answer and display it
-
- :param root: Root of the tree
- :type root: ElementTree Element
- :param namespaces: Namespaces of the tree
- :type namespaces: str
+ return self._parser.check_mailbox(itype, attr)
- """
- fields = ["TARGET", "REASON", "PATH", "APPID", "VALUE"]
- response = ""
- for elt in fields:
- msg = self._check_for_tag(root, namespaces, elt)
- if msg is not None:
- response = response + " " + msg.text + " :"
- deb = self._check_for_tag(root, namespaces, "MESSAGE")
- if deb is not None:
- msg = response + " " + deb.text
- self.debug(msg)
- else :
- self.info(response)
def handle_omf_message(self, iq):
""" Handle published/received message
:type iq: Iq Stanza
"""
- namespaces = "{http://jabber.org/protocol/pubsub}"
- for i in iq['pubsub_event']['items']:
- root = ET.fromstring(str(i))
- self._check_output(root, namespaces)
-
+ self._parser.handle(iq)
"wilabt" : "ops.wilab2.ilabt.iminds.be",
"nitos" : "nitlab.inf.uth.gr",
"nicta" : "??.??.??",
-
})
AMtoGateway = dict({
@classmethod
def _register_attributes(cls):
- xmppSlice = Attribute("xmppSlice","Name of the slice",
+ xmppServer = Attribute("xmppServer", "Xmpp Server",
flags = Flags.Credential)
- xmppHost = Attribute("xmppHost", "Xmpp Server",
+ xmppUser = Attribute("xmppUser","Name of the Xmpp User/Slice",
flags = Flags.Credential)
xmppPort = Attribute("xmppPort", "Xmpp Port",
flags = Flags.Credential)
xmppPassword = Attribute("xmppPassword", "Xmpp Password",
flags = Flags.Credential)
+ version = Attribute("version", "Version of OMF : Either 5 or 6",
+ default = "6", )
- cls._register_attribute(xmppSlice)
- cls._register_attribute(xmppHost)
+ cls._register_attribute(xmppUser)
+ cls._register_attribute(xmppServer)
cls._register_attribute(xmppPort)
cls._register_attribute(xmppPassword)
+ cls._register_attribute(version)
def __init__(self, ec, guid):
super(OMFResource, self).__init__(ec, guid)
--- /dev/null
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Julien Tribino <julien.tribino@inria.fr>
+
+
+from nepi.execution.resource import ResourceFactory, ResourceManager, ResourceAction, ResourceState
+from nepi.execution.ec import ExperimentController
+
+from nepi.resources.omf.node import OMFNode
+from nepi.resources.omf.application import OMFApplication
+from nepi.resources.omf.interface import OMFWifiInterface
+from nepi.resources.omf.channel import OMFChannel
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
+
+from nepi.util.timefuncs import *
+
+import time
+import unittest
+
+class OMFResourceFactoryTestCase(unittest.TestCase):
+ def test_creation_phase(self):
+
+ self.assertEquals(OMFNode.get_rtype(), "OMFNode")
+ self.assertEquals(len(OMFNode._attributes), 7)
+
+ self.assertEquals(OMFWifiInterface.get_rtype(), "OMFWifiInterface")
+ self.assertEquals(len(OMFWifiInterface._attributes), 11)
+
+ self.assertEquals(OMFChannel.get_rtype(), "OMFChannel")
+ self.assertEquals(len(OMFChannel._attributes), 7)
+
+ self.assertEquals(OMFApplication.get_rtype(), "OMFApplication")
+ self.assertEquals(len(OMFApplication._attributes), 13)
+
+class OMFEachTestCase(unittest.TestCase):
+ def setUp(self):
+ self.ec = ExperimentController(exp_id = "99999")
+
+ self.node1 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
+ self.ec.set(self.node1, 'xmppUser', "nepi")
+ self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node1, 'xmppPort', "5222")
+ self.ec.set(self.node1, 'xmppPassword', "1234")
+ self.ec.set(self.node1, 'version', "5")
+
+ self.iface1 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface1, 'name', "wlan0")
+ self.ec.set(self.iface1, 'mode', "adhoc")
+ self.ec.set(self.iface1, 'hw_mode', "g")
+ self.ec.set(self.iface1, 'essid', "vlcexp")
+ self.ec.set(self.iface1, 'ip', "10.0.0.17/24")
+ self.ec.set(self.iface1, 'version', "5")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppPort', "5222")
+ self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
+
+ self.app1 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app1, 'appid', 'Vlc#1')
+ self.ec.set(self.app1, 'command', "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
+ self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ self.ec.set(self.app1, 'version', "5")
+
+ self.app2 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app2, 'version', "5")
+
+ self.app3 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app3, 'version', "5")
+
+ self.app4 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app4, 'version', "5")
+
+ self.app5 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app5, 'version', "5")
+
+ self.ec.register_connection(self.app1, self.node1)
+ self.ec.register_connection(self.app2, self.node1)
+ self.ec.register_connection(self.app3, self.node1)
+ self.ec.register_connection(self.app4, self.node1)
+ self.ec.register_connection(self.app5, self.node1)
+ self.ec.register_connection(self.node1, self.iface1)
+ self.ec.register_connection(self.iface1, self.channel)
+
+ self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "3s")
+ self.ec.register_condition(self.app3, ResourceAction.START, self.app2, ResourceState.STARTED , "2s")
+ self.ec.register_condition(self.app4, ResourceAction.START, self.app3, ResourceState.STARTED , "3s")
+ self.ec.register_condition(self.app5, ResourceAction.START, [self.app3, self.app2], ResourceState.STARTED , "2s")
+ self.ec.register_condition(self.app5, ResourceAction.START, self.app1, ResourceState.STARTED , "25s")
+
+ self.ec.register_condition([self.app1, self.app2, self.app3,self.app4, self.app5], ResourceAction.STOP, self.app5, ResourceState.STARTED , "1s")
+
+ def tearDown(self):
+ self.ec.shutdown()
+
+ def test_creation_and_configuration_node(self):
+ self.assertEquals(self.ec.get(self.node1, 'hostname'), 'omf.plexus.wlab17')
+ self.assertEquals(self.ec.get(self.node1, 'xmppUser'), 'nepi')
+ self.assertEquals(self.ec.get(self.node1, 'xmppServer'), 'xmpp-plexus.onelab.eu')
+ self.assertEquals(self.ec.get(self.node1, 'xmppPort'), '5222')
+ self.assertEquals(self.ec.get(self.node1, 'xmppPassword'), '1234')
+ self.assertEquals(self.ec.get(self.node1, 'version'), '5')
+
+
+ def test_creation_and_configuration_interface(self):
+ self.assertEquals(self.ec.get(self.iface1, 'name'), 'wlan0')
+ self.assertEquals(self.ec.get(self.iface1, 'mode'), 'adhoc')
+ self.assertEquals(self.ec.get(self.iface1, 'hw_mode'), 'g')
+ self.assertEquals(self.ec.get(self.iface1, 'essid'), 'vlcexp')
+ self.assertEquals(self.ec.get(self.iface1, 'ip'), '10.0.0.17/24')
+ self.assertEquals(self.ec.get(self.iface1, 'version'), '5')
+
+ def test_creation_and_configuration_channel(self):
+ self.assertEquals(self.ec.get(self.channel, 'channel'), '6')
+ self.assertEquals(self.ec.get(self.channel, 'xmppUser'), 'nepi')
+ self.assertEquals(self.ec.get(self.channel, 'xmppServer'), 'xmpp-plexus.onelab.eu')
+ self.assertEquals(self.ec.get(self.channel, 'xmppPort'), '5222')
+ self.assertEquals(self.ec.get(self.channel, 'xmppPassword'), '1234')
+ self.assertEquals(self.ec.get(self.channel, 'version'), '5')
+
+
+ def test_creation_and_configuration_application(self):
+ self.assertEquals(self.ec.get(self.app1, 'appid'), 'Vlc#1')
+ self.assertEquals(self.ec.get(self.app1, 'command'), "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
+ self.assertEquals(self.ec.get(self.app1, 'env'), 'DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority')
+ self.assertEquals(self.ec.get(self.app1, 'version'), '5')
+
+ def test_connection(self):
+ self.assertEquals(len(self.ec.get_resource(self.node1).connections), 6)
+ self.assertEquals(len(self.ec.get_resource(self.iface1).connections), 2)
+ self.assertEquals(len(self.ec.get_resource(self.channel).connections), 1)
+ self.assertEquals(len(self.ec.get_resource(self.app1).connections), 1)
+ self.assertEquals(len(self.ec.get_resource(self.app2).connections), 1)
+
+ def test_condition(self):
+ self.assertEquals(len(self.ec.get_resource(self.app1).conditions[ResourceAction.STOP]), 1)
+ self.assertEquals(len(self.ec.get_resource(self.app2).conditions[ResourceAction.START]), 1)
+ self.assertEquals(len(self.ec.get_resource(self.app3).conditions[ResourceAction.START]), 1)
+ self.assertEquals(len(self.ec.get_resource(self.app4).conditions[ResourceAction.STOP]), 1)
+ self.assertEquals(len(self.ec.get_resource(self.app5).conditions[ResourceAction.START]), 2)
+
+class OMFVLCNormalCase(unittest.TestCase):
+ def test_deploy(self):
+ ec = ExperimentController(exp_id = "5421" )
+
+ self.node1 = ec.register_resource("OMFNode")
+ ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
+ ec.set(self.node1, 'xmppUser', "nepi")
+ ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
+ ec.set(self.node1, 'xmppPort', "5222")
+ ec.set(self.node1, 'xmppPassword', "1234")
+ ec.set(self.node1, 'version', "5")
+
+ self.iface1 = ec.register_resource("OMFWifiInterface")
+ ec.set(self.iface1, 'name', "wlan0")
+ ec.set(self.iface1, 'mode', "adhoc")
+ ec.set(self.iface1, 'hw_mode', "g")
+ ec.set(self.iface1, 'essid', "vlcexp")
+ ec.set(self.iface1, 'ip', "10.0.0.17/24")
+ ec.set(self.iface1, 'version', "5")
+
+ self.channel = ec.register_resource("OMFChannel")
+ ec.set(self.channel, 'channel', "6")
+ ec.set(self.channel, 'xmppUser', "nepi")
+ ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
+ ec.set(self.channel, 'xmppPort', "5222")
+ ec.set(self.channel, 'xmppPassword', "1234")
+ ec.set(self.channel, 'version', "5")
+
+ self.app1 = ec.register_resource("OMFApplication")
+ ec.set(self.app1, 'appid', 'Vlc#1')
+ ec.set(self.app1, 'command', "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
+ ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ ec.set(self.app1, 'version', "5")
+
+ self.app2 = ec.register_resource("OMFApplication")
+ ec.set(self.app2, 'appid', 'Test#1')
+ ec.set(self.app2, 'command', "/usr/bin/test -1")
+ ec.set(self.app2, 'env', " ")
+ ec.set(self.app2, 'version', "5")
+
+ self.app3 = ec.register_resource("OMFApplication")
+ ec.set(self.app3, 'appid', 'Test#2')
+ ec.set(self.app3, 'command', "/usr/bin/test -2")
+ ec.set(self.app3, 'env', " ")
+ ec.set(self.app3, 'version', "5")
+
+ self.app4 = ec.register_resource("OMFApplication")
+ ec.set(self.app4, 'appid', 'Test#3')
+ ec.set(self.app4, 'command', "/usr/bin/test -3")
+ ec.set(self.app4, 'env', " ")
+ ec.set(self.app4, 'version', "5")
+
+ self.app5 = ec.register_resource("OMFApplication")
+ ec.set(self.app5, 'appid', 'Kill#2')
+ ec.set(self.app5, 'command', "/usr/bin/killall vlc")
+ ec.set(self.app5, 'env', " ")
+ ec.set(self.app5, 'version', "5")
+
+ ec.register_connection(self.app1, self.node1)
+ ec.register_connection(self.app2, self.node1)
+ ec.register_connection(self.app3, self.node1)
+ ec.register_connection(self.app4, self.node1)
+ ec.register_connection(self.app5, self.node1)
+ ec.register_connection(self.node1, self.iface1)
+ ec.register_connection(self.iface1, self.channel)
+
+ ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "3s")
+ ec.register_condition(self.app3, ResourceAction.START, self.app2, ResourceState.STARTED , "2s")
+ ec.register_condition(self.app4, ResourceAction.START, self.app3, ResourceState.STARTED , "3s")
+ ec.register_condition(self.app5, ResourceAction.START, [self.app3, self.app2], ResourceState.STARTED , "2s")
+ ec.register_condition(self.app5, ResourceAction.START, self.app1, ResourceState.STARTED , "25s")
+
+ ec.register_condition([self.app1, self.app2, self.app3,self.app4, self.app5], ResourceAction.STOP, self.app5, ResourceState.STARTED , "1s")
+
+ ec.deploy()
+
+ ec.wait_finished([self.app1, self.app2, self.app3,self.app4, self.app5])
+
+ self.assertEquals(round(tdiffsec(ec.get_resource(self.app2).start_time, ec.get_resource(self.app1).start_time),0), 3.0)
+ self.assertEquals(round(tdiffsec(ec.get_resource(self.app3).start_time, ec.get_resource(self.app2).start_time),0), 2.0)
+ self.assertEquals(round(tdiffsec(ec.get_resource(self.app4).start_time, ec.get_resource(self.app3).start_time),0), 3.0)
+ self.assertEquals(round(tdiffsec(ec.get_resource(self.app5).start_time, ec.get_resource(self.app3).start_time),0), 20.0)
+ self.assertEquals(round(tdiffsec(ec.get_resource(self.app5).start_time, ec.get_resource(self.app1).start_time),0), 25.0)
+
+ self.assertEquals(ec.get_resource(self.node1).state, ResourceState.STARTED)
+ self.assertEquals(ec.get_resource(self.iface1).state, ResourceState.STARTED)
+ self.assertEquals(ec.get_resource(self.channel).state, ResourceState.STARTED)
+ self.assertEquals(ec.get_resource(self.app1).state, ResourceState.STOPPED)
+ self.assertEquals(ec.get_resource(self.app2).state, ResourceState.STOPPED)
+ self.assertEquals(ec.get_resource(self.app3).state, ResourceState.STOPPED)
+ self.assertEquals(ec.get_resource(self.app4).state, ResourceState.STOPPED)
+ self.assertEquals(ec.get_resource(self.app5).state, ResourceState.STOPPED)
+
+ ec.shutdown()
+
+ self.assertEquals(ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(ec.get_resource(self.app1).state, ResourceState.RELEASED)
+ self.assertEquals(ec.get_resource(self.app2).state, ResourceState.RELEASED)
+ self.assertEquals(ec.get_resource(self.app3).state, ResourceState.RELEASED)
+ self.assertEquals(ec.get_resource(self.app4).state, ResourceState.RELEASED)
+ self.assertEquals(ec.get_resource(self.app5).state, ResourceState.RELEASED)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
+
+
--- /dev/null
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Julien Tribino <julien.tribino@inria.fr>
+
+
+from nepi.execution.resource import ResourceFactory, ResourceManager, ResourceAction, ResourceState
+from nepi.execution.ec import ExperimentController
+
+from nepi.resources.omf.node import OMFNode
+from nepi.resources.omf.application import OMFApplication
+from nepi.resources.omf.interface import OMFWifiInterface
+from nepi.resources.omf.channel import OMFChannel
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
+
+from nepi.util.timefuncs import *
+
+import time
+import unittest
+
+class OMFVLCWrongCaseAllCritical(unittest.TestCase):
+
+ id = 1000
+
+ def setUp(self):
+ self.ec = ExperimentController(exp_id = str(OMFVLCWrongCaseAllCritical.id))
+ OMFVLCWrongCaseAllCritical.id += 1
+
+ self.node1 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
+ self.ec.set(self.node1, 'xmppUser', "nepi")
+ self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node1, 'xmppPort', "5222")
+ self.ec.set(self.node1, 'xmppPassword', "1234")
+ self.ec.set(self.node1, 'version', "5")
+
+ self.iface1 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface1, 'name', "wlan0")
+ self.ec.set(self.iface1, 'mode', "adhoc")
+ self.ec.set(self.iface1, 'hw_mode', "g")
+ self.ec.set(self.iface1, 'essid', "vlcexp")
+ self.ec.set(self.iface1, 'ip', "10.0.0.17/24")
+ self.ec.set(self.iface1, 'version', "5")
+
+ self.app1 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app1, 'appid', 'Vlc#1')
+ self.ec.set(self.app1, 'command', "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
+ self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ self.ec.set(self.app1, 'version', "5")
+
+ self.ec.register_connection(self.app1, self.node1)
+ self.ec.register_connection(self.node1, self.iface1)
+
+ def test_deploy_wo_node(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'version', "5")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppPort', "5222")
+ self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+
+ self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "2s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1])
+
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+
+ def test_deploy_wo_hostname(self):
+
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppPort', "5222")
+ self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+
+ self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "2s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1])
+
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+
+ def test_deploy_wo_iface(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab17')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'version', "5")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppPort', "5222")
+ self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+
+ self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "2s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1])
+
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+
+ def test_deploy_wo_ip(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab17')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'version', "5")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppPort', "5222")
+ self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+
+ self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "2s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1])
+
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+
+ def test_deploy_wo_channel(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab17')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'version', "5")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'version', "5")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+
+ self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "2s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1])
+
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+
+ def test_deploy_wo_app(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab17')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppPort', "5222")
+ self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
+
+ self.app2 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app2, 'version', "5")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.iface2, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.app2, self.node2)
+
+ self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "2s")
+ self.ec.register_condition([self.app1, self.app2], ResourceAction.STOP, self.app1, ResourceState.STARTED , "4s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1, self.app2])
+
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.RELEASED)
+
+ def test_deploy_wo_app_path(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab17')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppPort', "5222")
+ self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
+
+ self.app2 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app2, 'appid', 'Vlc#2')
+ self.ec.set(self.app2, 'version', "5")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.iface2, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.app2, self.node2)
+
+ self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "2s")
+ self.ec.register_condition([self.app1, self.app2], ResourceAction.STOP, self.app1, ResourceState.STARTED , "4s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1, self.app2])
+
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.RELEASED)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
+
+
from nepi.resources.omf.application import OMFApplication
from nepi.resources.omf.interface import OMFWifiInterface
from nepi.resources.omf.channel import OMFChannel
-from nepi.resources.omf.omf_api import OMFAPIFactory
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
from nepi.util.timefuncs import *
self.node1 = self.ec.register_resource("OMFNode")
self.ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
- self.ec.set(self.node1, 'xmppSlice', "nepi")
- self.ec.set(self.node1, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node1, 'xmppUser', "nepi")
+ self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node1, 'xmppPort', "5222")
self.ec.set(self.node1, 'xmppPassword', "1234")
+ self.ec.set(self.node1, 'version', "5")
self.iface1 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface1, 'alias', "w0")
+ self.ec.set(self.iface1, 'name', "wlan0")
self.ec.set(self.iface1, 'mode', "adhoc")
- self.ec.set(self.iface1, 'type', "g")
+ self.ec.set(self.iface1, 'hw_mode', "g")
self.ec.set(self.iface1, 'essid', "vlcexp")
- self.ec.set(self.iface1, 'ip', "10.0.0.17")
+ self.ec.set(self.iface1, 'ip', "10.0.0.17/24")
+ self.ec.set(self.iface1, 'version', "5")
self.app1 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app1, 'appid', 'Kill#1')
- self.ec.set(self.app1, 'path', "/usr/bin/test")
- self.ec.set(self.app1, 'args', "-1")
+ self.ec.set(self.app1, 'command', "/usr/bin/test -1")
self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ self.ec.set(self.app1, 'version', "5")
self.ec.register_connection(self.app1, self.node1)
self.ec.register_connection(self.node1, self.iface1)
def test_deploy_with_node_nc(self):
self.node2 = self.ec.register_resource("OMFNode")
self.ec.set(self.node2, "critical", False)
+ self.ec.set(self.node2, 'version', "5")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.channel, 'xmppPort', "5222")
self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
def test_deploy_with_node_and_iface_nc(self):
self.node2 = self.ec.register_resource("OMFNode")
self.ec.set(self.node2, "critical", False)
+ self.ec.set(self.node2, 'version', "5")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
self.ec.set(self.node2, "critical", False)
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.channel, 'xmppPort', "5222")
self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
self.node2 = self.ec.register_resource("OMFNode")
self.ec.set(self.node2, "critical", False)
self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab37')
+ self.ec.set(self.node2, 'version', "5")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
self.ec.set(self.node2, "critical", False)
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
self.ec.set(self.channel, "critical", False)
+ self.ec.set(self.channel, 'version', "5")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
def test_deploy_with_app_nc(self):
self.node2 = self.ec.register_resource("OMFNode")
self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab37')
- self.ec.set(self.node2, 'xmppSlice', "nepi")
- self.ec.set(self.node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node2, 'xmppPort', "5222")
self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.channel, 'xmppPort', "5222")
self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
self.app2 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app2, "critical", False)
self.ec.set(self.app2, 'appid', 'Kill#22')
+ self.ec.set(self.app2, 'version', "5")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
self.node2 = self.ec.register_resource("OMFNode")
self.ec.set(self.node2, "critical", False)
self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab37')
+ self.ec.set(self.node2, 'version', "5")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
self.ec.set(self.iface2, "critical", False)
+ self.ec.set(self.iface2, 'version', "5")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, "critical", False)
self.ec.set(self.channel, 'channel', "6")
+ self.ec.set(self.channel, 'version', "5")
self.app2 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app2, 'appid', 'Kill#22')
+ self.ec.set(self.app2, 'version', "5")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
self.node1 = self.ec.register_resource("OMFNode")
self.ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
- self.ec.set(self.node1, 'xmppSlice', "nepi")
- self.ec.set(self.node1, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node1, 'xmppUser', "nepi")
+ self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node1, 'xmppPort', "5222")
self.ec.set(self.node1, 'xmppPassword', "1234")
+ self.ec.set(self.node1, 'version', "5")
self.iface1 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface1, 'alias', "w0")
+ self.ec.set(self.iface1, 'name', "wlan0")
self.ec.set(self.iface1, 'mode', "adhoc")
- self.ec.set(self.iface1, 'type', "g")
+ self.ec.set(self.iface1, 'hw_mode', "g")
self.ec.set(self.iface1, 'essid', "vlcexp")
- self.ec.set(self.iface1, 'ip', "10.0.0.17")
+ self.ec.set(self.iface1, 'ip', "10.0.0.17/24")
+ self.ec.set(self.iface1, 'version', "5")
self.app1 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app1, 'appid', 'Kill#1')
- self.ec.set(self.app1, 'path', "/usr/bin/test")
- self.ec.set(self.app1, 'args', "-1")
+ self.ec.set(self.app1, 'command', "/usr/bin/test -1")
self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ self.ec.set(self.app1, 'version', "5")
self.ec.register_connection(self.app1, self.node1)
self.ec.register_connection(self.node1, self.iface1)
def test_deploy_with_app_nc_and_critical_wrong(self):
self.node2 = self.ec.register_resource("OMFNode")
self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab37')
- self.ec.set(self.node2, 'xmppSlice', "nepi")
- self.ec.set(self.node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node2, 'xmppPort', "5222")
self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.channel, 'xmppPort', "5222")
self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
self.app2 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app2, "critical", False)
self.ec.set(self.app2, 'appid', 'Kill#32')
+ self.ec.set(self.app2, 'version', "5")
self.app3 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app3, 'appid', 'Kill#33')
+ self.ec.set(self.app3, 'version', "5")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
def test_deploy_with_app_nc_and_critical_right(self):
self.node2 = self.ec.register_resource("OMFNode")
self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab37')
- self.ec.set(self.node2, 'xmppSlice', "nepi")
- self.ec.set(self.node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node2, 'xmppPort', "5222")
self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.channel, 'xmppPort', "5222")
self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
self.app2 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app2, "critical", False)
self.ec.set(self.app2, 'appid', 'Kill#32')
+ self.ec.set(self.app2, 'version', "5")
self.app3 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app3, 'appid', 'Kill#3')
- self.ec.set(self.app3, 'path', "/usr/bin/test")
- self.ec.set(self.app3, 'args', "-1")
+ self.ec.set(self.app3, 'command', "/usr/bin/test -1")
self.ec.set(self.app3, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ self.ec.set(self.app3, 'version', "5")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
def test_deploy_with_many_app_nc_and_critical(self):
self.node2 = self.ec.register_resource("OMFNode")
self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab37')
- self.ec.set(self.node2, 'xmppSlice', "nepi")
- self.ec.set(self.node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node2, 'xmppPort', "5222")
self.ec.set(self.node2, 'xmppPassword', "1234")
+ self.ec.set(self.node2, 'version', "5")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.37/24")
+ self.ec.set(self.iface2, 'version', "5")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.channel, 'xmppPort', "5222")
self.ec.set(self.channel, 'xmppPassword', "1234")
+ self.ec.set(self.channel, 'version', "5")
self.app2 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app2, "critical", False)
self.ec.set(self.app2, 'appid', 'Kill#32')
+ self.ec.set(self.app2, 'version', "5")
self.app3 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app3, "critical", False)
self.ec.set(self.app3, 'appid', 'Kill#3')
- self.ec.set(self.app3, 'path', "/usr/bin/test")
- self.ec.set(self.app3, 'args', "-1")
+ self.ec.set(self.app3, 'command', "/usr/bin/test -1")
self.ec.set(self.app3, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ self.ec.set(self.app3, 'version', "5")
self.app4 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app4, 'appid', 'Kill#4')
- self.ec.set(self.app4, 'path', "/usr/bin/test")
- self.ec.set(self.app4, 'args', "-1")
+ self.ec.set(self.app4, 'command', "/usr/bin/test -1")
self.ec.set(self.app4, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ self.ec.set(self.app4, 'version', "5")
self.app5 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app5, "critical", False)
self.ec.set(self.app5, 'appid', 'Kill#32')
+ self.ec.set(self.app5, 'version', "5")
self.app6 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app6, 'appid', 'Kill#6')
- self.ec.set(self.app6, 'path', "/usr/bin/test")
- self.ec.set(self.app6, 'args', "-1")
+ self.ec.set(self.app6, 'command', "/usr/bin/test -1")
self.ec.set(self.app6, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+ self.ec.set(self.app6, 'version', "5")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
from nepi.resources.omf.application import OMFApplication
from nepi.resources.omf.interface import OMFWifiInterface
from nepi.resources.omf.channel import OMFChannel
-from nepi.resources.omf.omf_api import OMFAPIFactory
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
from nepi.util.timefuncs import *
def test_creation_phase(self):
self.assertEquals(OMFNode.get_rtype(), "OMFNode")
- self.assertEquals(len(OMFNode._attributes), 6)
+ self.assertEquals(len(OMFNode._attributes), 7)
self.assertEquals(OMFWifiInterface.get_rtype(), "OMFWifiInterface")
- self.assertEquals(len(OMFWifiInterface._attributes), 10)
+ self.assertEquals(len(OMFWifiInterface._attributes), 11)
self.assertEquals(OMFChannel.get_rtype(), "OMFChannel")
- self.assertEquals(len(OMFChannel._attributes), 6)
+ self.assertEquals(len(OMFChannel._attributes), 7)
self.assertEquals(OMFApplication.get_rtype(), "OMFApplication")
self.assertEquals(len(OMFApplication._attributes), 13)
self.ec = ExperimentController(exp_id = "99999")
self.node1 = self.ec.register_resource("OMFNode")
- self.ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
- self.ec.set(self.node1, 'xmppSlice', "nepi")
- self.ec.set(self.node1, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node1, 'hostname', 'wlab12')
+ self.ec.set(self.node1, 'xmppUser', "nepi")
+ self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node1, 'xmppPort', "5222")
self.ec.set(self.node1, 'xmppPassword', "1234")
self.iface1 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface1, 'alias', "w0")
+ self.ec.set(self.iface1, 'name', "wlan0")
self.ec.set(self.iface1, 'mode', "adhoc")
- self.ec.set(self.iface1, 'type', "g")
+ self.ec.set(self.iface1, 'hw_mode', "g")
self.ec.set(self.iface1, 'essid', "vlcexp")
- self.ec.set(self.iface1, 'ip', "10.0.0.17")
+ self.ec.set(self.iface1, 'ip', "10.0.0.17/24")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.channel, 'xmppUser', "nepi")
+ self.ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.channel, 'xmppPort', "5222")
self.ec.set(self.channel, 'xmppPassword', "1234")
self.app1 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app1, 'appid', 'Vlc#1')
- self.ec.set(self.app1, 'path', "/opt/vlc-1.1.13/cvlc")
- self.ec.set(self.app1, 'args', "/opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
+ self.ec.set(self.app1, 'command', "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
self.app2 = self.ec.register_resource("OMFApplication")
self.app3 = self.ec.register_resource("OMFApplication")
+
self.app4 = self.ec.register_resource("OMFApplication")
+
self.app5 = self.ec.register_resource("OMFApplication")
self.ec.register_connection(self.app1, self.node1)
self.ec.shutdown()
def test_creation_and_configuration_node(self):
- self.assertEquals(self.ec.get(self.node1, 'hostname'), 'omf.plexus.wlab17')
- self.assertEquals(self.ec.get(self.node1, 'xmppSlice'), 'nepi')
- self.assertEquals(self.ec.get(self.node1, 'xmppHost'), 'xmpp-plexus.onelab.eu')
+ self.assertEquals(self.ec.get(self.node1, 'hostname'), 'wlab12')
+ self.assertEquals(self.ec.get(self.node1, 'xmppUser'), 'nepi')
+ self.assertEquals(self.ec.get(self.node1, 'xmppServer'), 'xmpp-plexus.onelab.eu')
self.assertEquals(self.ec.get(self.node1, 'xmppPort'), '5222')
self.assertEquals(self.ec.get(self.node1, 'xmppPassword'), '1234')
+ self.assertEquals(self.ec.get(self.node1, 'version'), '6')
+
def test_creation_and_configuration_interface(self):
- self.assertEquals(self.ec.get(self.iface1, 'alias'), 'w0')
+ self.assertEquals(self.ec.get(self.iface1, 'name'), 'wlan0')
self.assertEquals(self.ec.get(self.iface1, 'mode'), 'adhoc')
- self.assertEquals(self.ec.get(self.iface1, 'type'), 'g')
+ self.assertEquals(self.ec.get(self.iface1, 'hw_mode'), 'g')
self.assertEquals(self.ec.get(self.iface1, 'essid'), 'vlcexp')
- self.assertEquals(self.ec.get(self.iface1, 'ip'), '10.0.0.17')
+ self.assertEquals(self.ec.get(self.iface1, 'ip'), '10.0.0.17/24')
+ self.assertEquals(self.ec.get(self.iface1, 'version'), '6')
def test_creation_and_configuration_channel(self):
self.assertEquals(self.ec.get(self.channel, 'channel'), '6')
- self.assertEquals(self.ec.get(self.channel, 'xmppSlice'), 'nepi')
- self.assertEquals(self.ec.get(self.channel, 'xmppHost'), 'xmpp-plexus.onelab.eu')
+ self.assertEquals(self.ec.get(self.channel, 'xmppUser'), 'nepi')
+ self.assertEquals(self.ec.get(self.channel, 'xmppServer'), 'xmpp-plexus.onelab.eu')
self.assertEquals(self.ec.get(self.channel, 'xmppPort'), '5222')
self.assertEquals(self.ec.get(self.channel, 'xmppPassword'), '1234')
+ self.assertEquals(self.ec.get(self.channel, 'version'), '6')
+
def test_creation_and_configuration_application(self):
self.assertEquals(self.ec.get(self.app1, 'appid'), 'Vlc#1')
- self.assertEquals(self.ec.get(self.app1, 'path'), '/opt/vlc-1.1.13/cvlc')
- self.assertEquals(self.ec.get(self.app1, 'args'), "/opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
+ self.assertEquals(self.ec.get(self.app1, 'command'), "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
self.assertEquals(self.ec.get(self.app1, 'env'), 'DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority')
+ self.assertEquals(self.ec.get(self.app1, 'version'), '6')
def test_connection(self):
self.assertEquals(len(self.ec.get_resource(self.node1).connections), 6)
ec = ExperimentController(exp_id = "5421" )
self.node1 = ec.register_resource("OMFNode")
- ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
- ec.set(self.node1, 'xmppSlice', "nepi")
- ec.set(self.node1, 'xmppHost', "xmpp-plexus.onelab.eu")
+ ec.set(self.node1, 'hostname', 'wlab12')
+ ec.set(self.node1, 'xmppUser', "nepi")
+ ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
ec.set(self.node1, 'xmppPort', "5222")
ec.set(self.node1, 'xmppPassword', "1234")
self.iface1 = ec.register_resource("OMFWifiInterface")
- ec.set(self.iface1, 'alias', "w0")
+ ec.set(self.iface1, 'name', "wlan0")
ec.set(self.iface1, 'mode', "adhoc")
- ec.set(self.iface1, 'type', "g")
+ ec.set(self.iface1, 'hw_mode', "g")
ec.set(self.iface1, 'essid', "vlcexp")
- ec.set(self.iface1, 'ip', "10.0.0.17")
+ ec.set(self.iface1, 'ip', "10.0.0.17/24")
self.channel = ec.register_resource("OMFChannel")
ec.set(self.channel, 'channel', "6")
- ec.set(self.channel, 'xmppSlice', "nepi")
- ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
+ ec.set(self.channel, 'xmppUser', "nepi")
+ ec.set(self.channel, 'xmppServer', "xmpp-plexus.onelab.eu")
ec.set(self.channel, 'xmppPort', "5222")
ec.set(self.channel, 'xmppPassword', "1234")
self.app1 = ec.register_resource("OMFApplication")
ec.set(self.app1, 'appid', 'Vlc#1')
- ec.set(self.app1, 'path', "/opt/vlc-1.1.13/cvlc")
- ec.set(self.app1, 'args', "/opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
+ ec.set(self.app1, 'command', "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
self.app2 = ec.register_resource("OMFApplication")
ec.set(self.app2, 'appid', 'Test#1')
- ec.set(self.app2, 'path', "/usr/bin/test")
- ec.set(self.app2, 'args', "-1")
+ ec.set(self.app2, 'command', "/usr/bin/test -1")
ec.set(self.app2, 'env', " ")
self.app3 = ec.register_resource("OMFApplication")
ec.set(self.app3, 'appid', 'Test#2')
- ec.set(self.app3, 'path', "/usr/bin/test")
- ec.set(self.app3, 'args', "-2")
+ ec.set(self.app3, 'command', "/usr/bin/test -2")
ec.set(self.app3, 'env', " ")
self.app4 = ec.register_resource("OMFApplication")
ec.set(self.app4, 'appid', 'Test#3')
- ec.set(self.app4, 'path', "/usr/bin/test")
- ec.set(self.app4, 'args', "-3")
+ ec.set(self.app4, 'command', "/usr/bin/test -3")
ec.set(self.app4, 'env', " ")
self.app5 = ec.register_resource("OMFApplication")
ec.set(self.app5, 'appid', 'Kill#2')
- ec.set(self.app5, 'path', "/usr/bin/killall")
- ec.set(self.app5, 'args', "vlc")
+ ec.set(self.app5, 'command', "/usr/bin/killall vlc")
ec.set(self.app5, 'env', " ")
ec.register_connection(self.app1, self.node1)
from nepi.resources.omf.application import OMFApplication
from nepi.resources.omf.interface import OMFWifiInterface
from nepi.resources.omf.channel import OMFChannel
-from nepi.resources.omf.omf_api import OMFAPIFactory
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
from nepi.util.timefuncs import *
OMFVLCWrongCaseAllCritical.id += 1
self.node1 = self.ec.register_resource("OMFNode")
- self.ec.set(self.node1, 'hostname', 'omf.plexus.wlab17')
- self.ec.set(self.node1, 'xmppSlice', "nepi")
- self.ec.set(self.node1, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node1, 'hostname', 'wlab12')
+ self.ec.set(self.node1, 'xmppUser', "nepi")
+ self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node1, 'xmppPort', "5222")
self.ec.set(self.node1, 'xmppPassword', "1234")
self.iface1 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface1, 'alias', "w0")
+ self.ec.set(self.iface1, 'name', "wlan0")
self.ec.set(self.iface1, 'mode', "adhoc")
- self.ec.set(self.iface1, 'type', "g")
+ self.ec.set(self.iface1, 'hw_mode', "g")
self.ec.set(self.iface1, 'essid', "vlcexp")
- self.ec.set(self.iface1, 'ip', "10.0.0.17")
+ self.ec.set(self.iface1, 'ip', "10.0.0.12/24")
self.app1 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app1, 'appid', 'Vlc#1')
- self.ec.set(self.app1, 'path', "/opt/vlc-1.1.13/cvlc")
- self.ec.set(self.app1, 'args', "/opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
+ self.ec.set(self.app1, 'command', "/opt/vlc-1.1.13/cvlc /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.49,port=1234,mux=ts}'")
self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+
self.ec.register_connection(self.app1, self.node1)
self.ec.register_connection(self.node1, self.iface1)
self.node2 = self.ec.register_resource("OMFNode")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
- self.ec.set(self.channel, 'xmppPort', "5222")
- self.ec.set(self.channel, 'xmppPassword', "1234")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
def test_deploy_wo_hostname(self):
self.node2 = self.ec.register_resource("OMFNode")
- self.ec.set(self.node2, 'xmppSlice', "nepi")
- self.ec.set(self.node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node2, 'xmppPort', "5222")
self.ec.set(self.node2, 'xmppPassword', "1234")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
- self.ec.set(self.channel, 'xmppPort', "5222")
- self.ec.set(self.channel, 'xmppPassword', "1234")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "2s")
def test_deploy_wo_iface(self):
self.node2 = self.ec.register_resource("OMFNode")
- self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab17')
- self.ec.set(self.node2, 'xmppSlice', "nepi")
- self.ec.set(self.node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node2, 'xmppPort', "5222")
self.ec.set(self.node2, 'xmppPassword', "1234")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
- self.ec.set(self.channel, 'xmppPort', "5222")
- self.ec.set(self.channel, 'xmppPassword', "1234")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "2s")
self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+ def test_deploy_wo_channel(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+
+ self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "2s")
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1])
+
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+
def test_deploy_wo_ip(self):
self.node2 = self.ec.register_resource("OMFNode")
- self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab17')
- self.ec.set(self.node2, 'xmppSlice', "nepi")
- self.ec.set(self.node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node2, 'xmppPort', "5222")
self.ec.set(self.node2, 'xmppPassword', "1234")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
- self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
- self.ec.set(self.channel, 'xmppPort', "5222")
- self.ec.set(self.channel, 'xmppPassword', "1234")
self.ec.register_connection(self.iface1, self.channel)
self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "2s")
def test_deploy_wo_app(self):
self.node2 = self.ec.register_resource("OMFNode")
- self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab17')
- self.ec.set(self.node2, 'xmppSlice', "nepi")
- self.ec.set(self.node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node2, 'xmppPort', "5222")
self.ec.set(self.node2, 'xmppPassword', "1234")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
- self.ec.set(self.channel, 'xmppPort', "5222")
- self.ec.set(self.channel, 'xmppPassword', "1234")
self.app2 = self.ec.register_resource("OMFApplication")
def test_deploy_wo_app_path(self):
self.node2 = self.ec.register_resource("OMFNode")
- self.ec.set(self.node2, 'hostname', 'omf.plexus.wlab17')
- self.ec.set(self.node2, 'xmppSlice', "nepi")
- self.ec.set(self.node2, 'xmppHost', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
self.ec.set(self.node2, 'xmppPort', "5222")
self.ec.set(self.node2, 'xmppPassword', "1234")
self.iface2 = self.ec.register_resource("OMFWifiInterface")
- self.ec.set(self.iface2, 'alias', "w0")
+ self.ec.set(self.iface2, 'name', "wlan0")
self.ec.set(self.iface2, 'mode', "adhoc")
- self.ec.set(self.iface2, 'type', "g")
+ self.ec.set(self.iface2, 'hw_mode', "g")
self.ec.set(self.iface2, 'essid', "vlcexp")
- self.ec.set(self.iface2, 'ip', "10.0.0.37")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
self.channel = self.ec.register_resource("OMFChannel")
self.ec.set(self.channel, 'channel', "6")
- self.ec.set(self.channel, 'xmppSlice', "nepi")
- self.ec.set(self.channel, 'xmppHost', "xmpp-plexus.onelab.eu")
- self.ec.set(self.channel, 'xmppPort', "5222")
- self.ec.set(self.channel, 'xmppPassword', "1234")
self.app2 = self.ec.register_resource("OMFApplication")
self.ec.set(self.app2, 'appid', 'Vlc#2')
--- /dev/null
+#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Julien Tribino <julien.tribino@inria.fr>
+
+
+from nepi.execution.resource import ResourceFactory, ResourceManager, ResourceAction, ResourceState
+from nepi.execution.ec import ExperimentController
+
+from nepi.resources.omf.node import OMFNode
+from nepi.resources.omf.application import OMFApplication
+from nepi.resources.omf.interface import OMFWifiInterface
+from nepi.resources.omf.channel import OMFChannel
+from nepi.resources.omf.omf_api_factory import OMFAPIFactory
+
+from nepi.util.timefuncs import *
+
+import time
+import unittest
+
+class OMFVLCWrongCaseWithNonCritical(unittest.TestCase):
+
+ id = 2000
+
+ def setUp(self):
+ self.ec = ExperimentController(exp_id = str(OMFVLCWrongCaseWithNonCritical.id))
+ OMFVLCWrongCaseWithNonCritical.id += 1
+
+ self.node1 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node1, 'hostname', 'wlab12')
+ self.ec.set(self.node1, 'xmppUser', "nepi")
+ self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node1, 'xmppPort', "5222")
+ self.ec.set(self.node1, 'xmppPassword', "1234")
+
+ self.iface1 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface1, 'name', "wlan0")
+ self.ec.set(self.iface1, 'mode', "adhoc")
+ self.ec.set(self.iface1, 'hw_mode', "g")
+ self.ec.set(self.iface1, 'essid', "vlcexp")
+ self.ec.set(self.iface1, 'ip', "10.0.0.12/24")
+
+ self.app1 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app1, 'appid', 'Kill#1')
+ self.ec.set(self.app1, 'command', "/usr/bin/test -1")
+ self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+
+ self.ec.register_connection(self.app1, self.node1)
+ self.ec.register_connection(self.node1, self.iface1)
+
+ def test_deploy_with_node_nc(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, "critical", False)
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+
+ self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "5s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1])
+
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.FAILED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+
+ def test_deploy_with_node_and_iface_nc(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, "critical", False)
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.node2, "critical", False)
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+
+ self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "5s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1])
+
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.FAILED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+
+ def test_deploy_with_node_iface_channel_nc(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, "critical", False)
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.node2, "critical", False)
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+ self.ec.set(self.channel, "critical", False)
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+
+ self.ec.register_condition([self.app1], ResourceAction.STOP, self.app1, ResourceState.STARTED , "10s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1])
+
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.FAILED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+
+ def test_deploy_with_app_nc(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+
+ self.app2 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app2, "critical", False)
+ self.ec.set(self.app2, 'appid', 'Kill#22')
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+ self.ec.register_connection(self.app2, self.node2)
+
+ self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "6s")
+ self.ec.register_condition([self.app1, self.app2], ResourceAction.STOP, self.app1, ResourceState.STARTED , "10s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1, self.app2])
+
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.STOPPED)
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.RELEASED)
+
+ def test_deploy_with_all_nc_and_app_critical(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, "critical", False)
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, "critical", False)
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, "critical", False)
+ self.ec.set(self.channel, 'channel', "6")
+
+ self.app2 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app2, 'appid', 'Kill#22')
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+ self.ec.register_connection(self.app2, self.node2)
+
+ self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "6s")
+ self.ec.register_condition([self.app1, self.app2], ResourceAction.STOP, self.app1, ResourceState.STARTED , "10s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1, self.app2])
+
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.RELEASED)
+
+
+class OMFVLCWrongCaseWithNonCriticalDep(unittest.TestCase):
+
+ id = 3000
+
+ def setUp(self):
+ self.ec = ExperimentController(exp_id = str(OMFVLCWrongCaseWithNonCriticalDep.id))
+ OMFVLCWrongCaseWithNonCriticalDep.id += 1
+
+ self.node1 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node1, 'hostname', 'wlab12')
+ self.ec.set(self.node1, 'xmppUser', "nepi")
+ self.ec.set(self.node1, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node1, 'xmppPort', "5222")
+ self.ec.set(self.node1, 'xmppPassword', "1234")
+
+ self.iface1 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface1, 'name', "wlan0")
+ self.ec.set(self.iface1, 'mode', "adhoc")
+ self.ec.set(self.iface1, 'hw_mode', "g")
+ self.ec.set(self.iface1, 'essid', "vlcexp")
+ self.ec.set(self.iface1, 'ip', "10.0.0.12/24")
+
+ self.app1 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app1, 'appid', 'Kill#1')
+ self.ec.set(self.app1, 'command', "/usr/bin/test -1")
+ self.ec.set(self.app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+
+ self.ec.register_connection(self.app1, self.node1)
+ self.ec.register_connection(self.node1, self.iface1)
+
+ def test_deploy_with_app_nc_and_critical_wrong(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+
+ self.app2 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app2, "critical", False)
+ self.ec.set(self.app2, 'appid', 'Kill#32')
+
+ self.app3 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app3, 'appid', 'Kill#33')
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+ self.ec.register_connection(self.app2, self.node2)
+ self.ec.register_connection(self.app3, self.node2)
+
+ self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "5s")
+ self.ec.register_condition(self.app3, ResourceAction.START, self.app2, ResourceState.STARTED , "5s")
+ self.ec.register_condition([self.app1, self.app2, self.app3], ResourceAction.STOP, self.app1, ResourceState.STARTED , "15s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1, self.app2, self.app3])
+
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.FAILED)
+ self.assertEquals(self.ec.get_resource(self.app3).state, ResourceState.FAILED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app3).state, ResourceState.RELEASED)
+
+ def test_deploy_with_app_nc_and_critical_right(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+
+ self.app2 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app2, "critical", False)
+ self.ec.set(self.app2, 'appid', 'Kill#32')
+
+ self.app3 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app3, 'appid', 'Kill#3')
+ self.ec.set(self.app3, 'command', "/usr/bin/test -3")
+ self.ec.set(self.app3, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+ self.ec.register_connection(self.app2, self.node2)
+ self.ec.register_connection(self.app3, self.node2)
+
+ self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "5s")
+ self.ec.register_condition(self.app3, ResourceAction.START, self.app2, ResourceState.STARTED , "5s")
+ self.ec.register_condition([self.app1, self.app2, self.app3], ResourceAction.STOP, self.app1, ResourceState.STARTED , "15s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1, self.app2, self.app3])
+
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.FAILED)
+ self.assertEquals(self.ec.get_resource(self.app3).state, ResourceState.STOPPED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app3).state, ResourceState.RELEASED)
+
+
+ def test_deploy_with_many_app_nc_and_critical(self):
+ self.node2 = self.ec.register_resource("OMFNode")
+ self.ec.set(self.node2, 'hostname', 'wlab49')
+ self.ec.set(self.node2, 'xmppUser', "nepi")
+ self.ec.set(self.node2, 'xmppServer', "xmpp-plexus.onelab.eu")
+ self.ec.set(self.node2, 'xmppPort', "5222")
+ self.ec.set(self.node2, 'xmppPassword', "1234")
+
+ self.iface2 = self.ec.register_resource("OMFWifiInterface")
+ self.ec.set(self.iface2, 'name', "wlan0")
+ self.ec.set(self.iface2, 'mode', "adhoc")
+ self.ec.set(self.iface2, 'hw_mode', "g")
+ self.ec.set(self.iface2, 'essid', "vlcexp")
+ self.ec.set(self.iface2, 'ip', "10.0.0.49/24")
+
+ self.channel = self.ec.register_resource("OMFChannel")
+ self.ec.set(self.channel, 'channel', "6")
+
+ self.app2 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app2, "critical", False)
+ self.ec.set(self.app2, 'appid', 'Kill#32')
+
+ self.app3 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app3, "critical", False)
+ self.ec.set(self.app3, 'appid', 'Kill#3')
+ self.ec.set(self.app3, 'command', "/usr/bin/test -3")
+ self.ec.set(self.app3, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+
+ self.app4 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app4, 'appid', 'Kill#4')
+ self.ec.set(self.app4, 'command', "/usr/bin/test -4")
+ self.ec.set(self.app4, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+
+ self.app5 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app5, "critical", False)
+ self.ec.set(self.app5, 'appid', 'Kill#32')
+
+ self.app6 = self.ec.register_resource("OMFApplication")
+ self.ec.set(self.app6, 'appid', 'Kill#6')
+ self.ec.set(self.app6, 'command', "/usr/bin/test -6")
+ self.ec.set(self.app6, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
+
+ self.ec.register_connection(self.iface1, self.channel)
+ self.ec.register_connection(self.node2, self.iface2)
+ self.ec.register_connection(self.iface2, self.channel)
+ self.ec.register_connection(self.app2, self.node1)
+ self.ec.register_connection(self.app3, self.node1)
+ self.ec.register_connection(self.app4, self.node2)
+ self.ec.register_connection(self.app5, self.node2)
+ self.ec.register_connection(self.app6, self.node2)
+
+ self.ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "4s")
+ self.ec.register_condition(self.app3, ResourceAction.START, self.app2, ResourceState.STARTED , "4s")
+ self.ec.register_condition(self.app4, ResourceAction.START, self.app1, ResourceState.STARTED , "4s")
+ self.ec.register_condition(self.app5, ResourceAction.START, self.app4, ResourceState.STARTED , "4s")
+ self.ec.register_condition(self.app6, ResourceAction.START, self.app5, ResourceState.STARTED , "4s")
+ self.ec.register_condition([self.app1, self.app2, self.app3, self.app4, self.app5, self.app6 ], ResourceAction.STOP, [self.app1, self.app2, self.app3, self.app4, self.app5, self.app6 ], ResourceState.STARTED , "5s")
+
+ self.ec.deploy()
+
+ self.ec.wait_finished([self.app1, self.app2, self.app3, self.app4, self.app5, self.app6])
+
+ self.assertEquals(self.ec.get_resource(self.app3).state, ResourceState.STOPPED)
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.FAILED)
+ self.assertEquals(self.ec.get_resource(self.app4).state, ResourceState.STOPPED)
+ self.assertEquals(self.ec.get_resource(self.app5).state, ResourceState.FAILED)
+ self.assertEquals(self.ec.get_resource(self.app6).state, ResourceState.STOPPED)
+
+ self.ec.shutdown()
+
+ self.assertEquals(self.ec.get_resource(self.node1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.node2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.iface2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.channel).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app1).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app2).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app3).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app4).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app5).state, ResourceState.RELEASED)
+ self.assertEquals(self.ec.get_resource(self.app6).state, ResourceState.RELEASED)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
+
+