+++ /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, 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
-
-import logging
-import time
-
-logging.basicConfig()
-
-# Create the EC
-ec = ExperimentController()
-
-# 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, 'xmppPort', "5222")
-ec.set(node1, 'xmppPassword', "1234")
-ec.set(node1, 'xmppSlice', "nepi")
-ec.set(node1, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(node1, 'xmppPort', "5222")
-ec.set(node1, 'xmppPassword', "1234")
-
-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, 'xmppPort', "5222")
-ec.set(node2, 'xmppPassword', "1234")
-ec.set(node2, 'xmppSlice', "nepi")
-ec.set(node2, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(node2, 'xmppPort', "5222")
-ec.set(node2, 'xmppPassword', "1234")
-
-# Create and Configure the Interfaces
-iface1 = ec.register_resource("OMFWifiInterface")
-ec.set(iface1, 'alias', "w0")
-ec.set(iface1, 'mode', "adhoc")
-ec.set(iface1, 'type', "g")
-ec.set(iface1, 'essid', "vlcexp")
-#ec.set(iface1, 'ap', "11:22:33:44:55:66")
-ec.set(iface1, 'ip', "10.0.0.17")
-ec.set(iface1, 'xmppSlice', "nepi")
-ec.set(iface1, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(iface1, 'xmppPort', "5222")
-ec.set(iface1, 'xmppPassword', "1234")
-
-iface2 = ec.register_resource("OMFWifiInterface")
-ec.set(iface2, 'alias', "w0")
-ec.set(iface2, 'mode', "adhoc")
-ec.set(iface2, 'type', 'g')
-ec.set(iface2, 'essid', "vlcexp")
-#ec.set(iface2, 'ap', "11:22:33:44:55:66")
-ec.set(iface2, 'ip', "10.0.0.37")
-ec.set(iface2, 'xmppSlice', "nepi")
-ec.set(iface2, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(iface2, 'xmppPort', "5222")
-ec.set(iface2, 'xmppPassword', "1234")
-
-# 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, 'xmppPort', "5222")
-ec.set(channel, 'xmppPassword', "1234")
-
-# 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', "/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.37,port=1234,mux=ts} '")
-ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
-ec.set(app1, 'xmppSlice', "nepi")
-ec.set(app1, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(app1, 'xmppPort', "5222")
-ec.set(app1, 'xmppPassword', "1234")
-
-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, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
-ec.set(app2, 'xmppSlice', "nepi")
-ec.set(app2, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(app2, 'xmppPort', "5222")
-ec.set(app2, 'xmppPassword', "1234")
-
-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, 'env', " ")
-ec.set(app3, 'xmppSlice', "nepi")
-ec.set(app3, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(app3, 'xmppPort', "5222")
-ec.set(app3, 'xmppPassword', "1234")
-
-# 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)
-
-# 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")
-
-# Deploy
-ec.deploy()
-
-ec.wait_finished([app1, app2, app3])
-
-# Stop Experiment
-#time.sleep(55)
-ec.shutdown()
+++ /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
-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
-
-import logging
-import time
-
-logging.basicConfig()
-
-# Create the EC
-ec = ExperimentController()
-
-# Register the different RM that will be used
-ResourceFactory.register_type(OMFNode)
-ResourceFactory.register_type(OMFWifiInterface)
-ResourceFactory.register_type(OMFChannel)
-ResourceFactory.register_type(OMFApplication)
-
-# Create and Configure the Nodes
-guid = ec.register_resource("OMFNode")
-node1 = ec.get_resource(guid)
-node1.set('hostname', 'omf.plexus.wlab17')
-node1.set('xmppSlice', "nepi")
-node1.set('xmppHost', "xmpp-plexus.onelab.eu")
-node1.set('xmppPort', "5222")
-node1.set('xmppPassword', "1234")
-
-guid = ec.register_resource("OMFNode")
-node2 = ec.get_resource(guid)
-node2.set('hostname', "omf.plexus.wlab37")
-node2.set('xmppSlice', "nepi")
-node2.set('xmppHost', "xmpp-plexus.onelab.eu")
-node2.set('xmppPort', "5222")
-node2.set('xmppPassword', "1234")
-
-# Create and Configure the Interfaces
-guid = ec.register_resource("OMFWifiInterface")
-iface1 = ec.get_resource(guid)
-iface1.set('alias', "w0")
-iface1.set('mode', "adhoc")
-iface1.set('type', "g")
-iface1.set('essid', "helloworld")
-iface1.set('ip', "10.0.0.17")
-iface1.set('xmppSlice', "nepi")
-iface1.set('xmppHost', "xmpp-plexus.onelab.eu")
-iface1.set('xmppPort', "5222")
-iface1.set('xmppPassword', "1234")
-
-guid = ec.register_resource("OMFWifiInterface")
-iface2 = ec.get_resource(guid)
-iface2.set('alias', "w0")
-iface2.set('mode', "adhoc")
-iface2.set('type', 'g')
-iface2.set('essid', "helloworld")
-iface2.set('ip', "10.0.0.37")
-iface2.set('xmppSlice', "nepi")
-iface2.set('xmppHost', "xmpp-plexus.onelab.eu")
-iface2.set('xmppPort', "5222")
-iface2.set('xmppPassword', "1234")
-
-# Create and Configure the Channel
-guid = ec.register_resource("OMFChannel")
-channel = ec.get_resource(guid)
-channel.set('channel', "6")
-channel.set('xmppSlice', "nepi")
-channel.set('xmppHost', "xmpp-plexus.onelab.eu")
-channel.set('xmppPort', "5222")
-channel.set('xmppPassword', "1234")
-
-# Create and Configure the Application
-guid = ec.register_resource("OMFApplication")
-app1 = ec.get_resource(guid)
-app1.set('appid', 'Vlc#1')
-app1.set('path', "/opt/vlc-1.1.13/cvlc")
-app1.set('args', "/opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port=1234,mux=ts}'")
-app1.set('env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
-app1.set('xmppSlice', "nepi")
-app1.set('xmppHost', "xmpp-plexus.onelab.eu")
-app1.set('xmppPort', "5222")
-app1.set('xmppPassword', "1234")
-
-guid = ec.register_resource("OMFApplication")
-app2 = ec.get_resource(guid)
-app2.set('appid', 'Vlc#2')
-app2.set('path', "/opt/vlc-1.1.13/cvlc")
-app2.set('args', "rtp://10.0.0.37:1234")
-app2.set('env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
-app2.set('xmppSlice', "nepi")
-app2.set('xmppHost', "xmpp-plexus.onelab.eu")
-app2.set('xmppPort', "5222")
-app2.set('xmppPassword', "1234")
-
-guid = ec.register_resource("OMFApplication")
-app3 = ec.get_resource(guid)
-app3.set('appid', 'Kill#2')
-app3.set('path', "/usr/bin/killall")
-app3.set('args', "vlc")
-app3.set('env', " ")
-app3.set('xmppSlice', "nepi")
-app3.set('xmppHost', "xmpp-plexus.onelab.eu")
-app3.set('xmppPort', "5222")
-app3.set('xmppPassword', "1234")
-
-# register_connection
-app3.register_connection(node1.guid)
-node1.register_connection(app3.guid)
-
-app1.register_connection(node1.guid)
-node1.register_connection(app1.guid)
-
-node1.register_connection(iface1.guid)
-iface1.register_connection(node1.guid)
-
-iface1.register_connection(channel.guid)
-channel.register_connection(iface1.guid)
-
-channel.register_connection(iface2.guid)
-iface2.register_connection(channel.guid)
-
-iface2.register_connection(node2.guid)
-node2.register_connection(iface2.guid)
-
-node2.register_connection(app2.guid)
-app2.register_connection(node2.guid)
-
-# Local Deploy
-node1.deploy()
-node2.deploy()
-iface1.deploy()
-iface2.deploy()
-channel.deploy()
-app1.deploy()
-app2.deploy()
-app3.deploy()
-
-# Start the Nodes
-node1.start()
-node2.start()
-time.sleep(2)
-
-# Start the Interfaces
-iface1.start()
-iface2.start()
-
-# Start the Channel
-time.sleep(2)
-channel.start()
-time.sleep(2)
-
-# Start the Application
-app1.start()
-time.sleep(2)
-app2.start()
-
-time.sleep(20)
-
-# Stop the Application
-app1.stop()
-app2.stop()
-time.sleep(1)
-app3.start()
-time.sleep(2)
-
-# Stop Experiment
-ec.shutdown()
"""
#!/usr/bin/env python
-from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState, populate_factory
+from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
from nepi.execution.ec import ExperimentController
# Create the EC
ec = ExperimentController()
-# Register the different RM that will be used
-populate_factory()
-
# Create and Configure the Nodes
node1 = ec.register_resource("OMFNode")
ec.set(node1, 'hostname', 'omf.plexus.wlab17')
#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, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
-ec.set(app1, 'xmppSlice', "nepi")
-ec.set(app1, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(app1, 'xmppPort', "5222")
-ec.set(app1, 'xmppPassword', "1234")
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, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
-ec.set(app2, 'xmppSlice', "nepi")
-ec.set(app2, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(app2, 'xmppPort', "5222")
-ec.set(app2, 'xmppPassword', "1234")
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, 'env', " ")
-ec.set(app3, 'xmppSlice', "nepi")
-ec.set(app3, 'xmppHost', "xmpp-plexus.onelab.eu")
-ec.set(app3, 'xmppPort', "5222")
-ec.set(app3, 'xmppPassword', "1234")
# Connection
ec.register_connection(app3, node1)
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, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
-ec.set(app1, 'xmppSlice', "ZZZ")
-ec.set(app1, 'xmppHost', "nitlab.inf.uth.gr")
-ec.set(app1, 'xmppPort', "5222")
-ec.set(app1, 'xmppPassword', "1234")
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, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
-ec.set(app2, 'xmppSlice', "ZZZ")
-ec.set(app2, 'xmppHost', "nitlab.inf.uth.gr")
-ec.set(app2, 'xmppPort', "5222")
-ec.set(app2, 'xmppPassword', "1234")
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, 'env', " ")
-ec.set(app3, 'xmppSlice', "ZZZ")
-ec.set(app3, 'xmppHost', "nitlab.inf.uth.gr")
-ec.set(app3, 'xmppPort', "5222")
-ec.set(app3, 'xmppPassword', "1234")
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, 'env', " ")
-ec.set(app4, 'xmppSlice', "ZZZ")
-ec.set(app4, 'xmppHost', "nitlab.inf.uth.gr")
-ec.set(app4, 'xmppPort', "5222")
-ec.set(app4, 'xmppPassword', "1234")
# Connection
ec.register_connection(app3, node1)
ec.set(app1, 'path', "/usr/bin/xeyes")
ec.set(app1, 'args', " ")
ec.set(app1, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
-ec.set(app1, 'xmppSlice', "ZZZ")
-ec.set(app1, 'xmppHost', "nitlab.inf.uth.gr")
-ec.set(app1, 'xmppPort', "5222")
-ec.set(app1, 'xmppPassword', "1234")
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, 'xmppSlice', "ZZZ")
-ec.set(app2, 'xmppHost', "nitlab.inf.uth.gr")
-ec.set(app2, 'xmppPort', "5222")
-ec.set(app2, 'xmppPassword', "1234")
# Connection
ec.register_connection(app2, node1)
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
# Julien Tribino <julien.tribino@inria.fr>
-from nepi.execution.resource import ResourceManager, clsinit, ResourceState, \
+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.util.sshfuncs import ProcStatus
+from nepi.util import sshfuncs
-@clsinit
-class OMFApplication(ResourceManager):
+
+@clsinit_copy
+class OMFApplication(OMFResource):
"""
.. class:: Class Args :
""" 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")
env = Attribute("env", "Environnement variable of the application")
- xmppSlice = Attribute("xmppSlice","Name of the slice", flags = Flags.Credential)
- xmppHost = Attribute("xmppHost", "Xmpp Server",flags = Flags.Credential)
- xmppPort = Attribute("xmppPort", "Xmpp Port",flags = Flags.Credential)
- xmppPassword = Attribute("xmppPassword", "Xmpp Port",flags = Flags.Credential)
+ stdin = Attribute("stdin", "Input of the application", default = "")
+ sources = Attribute("sources", "Sources of the application",
+ flags = Flags.ExecReadOnly)
+ sshuser = Attribute("sshUser", "user to connect with ssh",
+ flags = Flags.ExecReadOnly)
+ sshkey = Attribute("sshKey", "key to use for ssh",
+ flags = Flags.ExecReadOnly)
cls._register_attribute(appid)
cls._register_attribute(path)
cls._register_attribute(args)
cls._register_attribute(env)
- cls._register_attribute(xmppSlice)
- cls._register_attribute(xmppHost)
- cls._register_attribute(xmppPort)
- cls._register_attribute(xmppPassword)
-
+ cls._register_attribute(stdin)
+ cls._register_attribute(sources)
+ cls._register_attribute(sshuser)
+ cls._register_attribute(sshkey)
def __init__(self, ec, guid):
"""
self._omf_api = None
+ self.add_set_hook()
+
+ @property
+ def exp_id(self):
+ return self.ec.exp_id
+
@property
def node(self):
rm_list = self.get_connected(OMFNode.rtype())
if rm_list: return rm_list[0]
return None
+ def stdin_hook(self, old_value, new_value):
+ self._omf_api.send_stdin(self.node.get('hostname'), new_value, self.get('appid'))
+ return new_value
+
+ def add_set_hook(self):
+ attr = self._attrs["stdin"]
+ attr.set_hook = self.stdin_hook
+
def valid_connection(self, guid):
""" Check if the connection with the guid in parameter is possible.
Only meaningful connections are allowed.
"This Application is already connected" ) % \
(self.rtype(), self._guid, rm.rtype(), guid)
self.debug(msg)
-
return False
-
else :
msg = "Connection between %s %s and %s %s accepted" % (
self.rtype(), self._guid, rm.rtype(), guid)
It becomes DEPLOYED after getting the xmpp client.
"""
+ self.set('xmppSlice', self.node.get('xmppSlice'))
+ self.set('xmppHost', self.node.get('xmppHost'))
+ self.set('xmppPort', self.node.get('xmppPort'))
+ self.set('xmppPassword', self.node.get('xmppPassword'))
+
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.ec.exp_id)
+ self.get('xmppPassword'), exp_id = self.exp_id)
if not self._omf_api :
msg = "Credentials are not initialzed. XMPP Connections impossible"
self.fail()
return
+ 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)
+
super(OMFApplication, self).deploy()
+
def start(self):
""" Start the RM. It means : Send Xmpp Message Using OMF protocol
to execute the application.
return
super(OMFApplication, self).stop()
+ self.set_finished()
def 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.ec.exp_id)
+ self.get('xmppPassword'), exp_id = self.exp_id)
super(OMFApplication, self).release()
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
# Julien Tribino <julien.tribino@inria.fr>
-from nepi.execution.resource import ResourceManager, clsinit, ResourceState, \
+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.omf_api import OMFAPIFactory
-@clsinit
-class OMFChannel(ResourceManager):
+@clsinit_copy
+class OMFChannel(OMFResource):
"""
.. class:: Class Args :
"""
channel = Attribute("channel", "Name of the application")
- xmppSlice = Attribute("xmppSlice","Name of the slice", flags = Flags.Credential)
- xmppHost = Attribute("xmppHost", "Xmpp Server",flags = Flags.Credential)
- xmppPort = Attribute("xmppPort", "Xmpp Port",flags = Flags.Credential)
- xmppPassword = Attribute("xmppPassword", "Xmpp Port",flags = Flags.Credential)
cls._register_attribute(channel)
- cls._register_attribute(xmppSlice)
- cls._register_attribute(xmppHost)
- cls._register_attribute(xmppPort)
- cls._register_attribute(xmppPassword)
def __init__(self, ec, guid):
"""
@property
def exp_id(self):
- if self.ec.exp_id.startswith('exp-'):
- return None
return self.ec.exp_id
def valid_connection(self, guid):
"""
super(OMFChannel, self).stop()
+ self.set_finished()
def release(self):
""" Clean the RM at the end of the experiment and release the API
# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
# Julien Tribino <julien.tribino@inria.fr>
-from nepi.execution.resource import ResourceManager, clsinit, ResourceState, \
+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.omf_resource import ResourceGateway, OMFResource
from nepi.resources.omf.channel import OMFChannel
from nepi.resources.omf.omf_api import OMFAPIFactory
-@clsinit
-class OMFWifiInterface(ResourceManager):
+@clsinit_copy
+class OMFWifiInterface(OMFResource):
"""
.. class:: Class Args :
type = Attribute("type","Type of the interface")
essid = Attribute("essid","Essid of the interface")
ip = Attribute("ip","IP of the interface")
- xmppSlice = Attribute("xmppSlice","Name of the slice", flags = Flags.Credential)
- xmppHost = Attribute("xmppHost", "Xmpp Server",flags = Flags.Credential)
- xmppPort = Attribute("xmppPort", "Xmpp Port",flags = Flags.Credential)
- xmppPassword = Attribute("xmppPassword", "Xmpp Port",flags = Flags.Credential)
cls._register_attribute(alias)
- cls._register_attribute(xmppSlice)
- cls._register_attribute(xmppHost)
- cls._register_attribute(xmppPort)
- cls._register_attribute(xmppPassword)
cls._register_attribute(mode)
cls._register_attribute(type)
cls._register_attribute(essid)
msg = "Connection between %s %s and %s %s accepted" % \
(self.rtype(), self._guid, rm.rtype(), guid)
self.debug(msg)
+
return True
msg = "Connection between %s %s and %s %s refused" % \
return False
+ @property
+ def exp_id(self):
+ return self.ec.exp_id
+
@property
def node(self):
rm_list = self.get_connected(OMFNode.rtype())
if rm_list: return rm_list[0]
return None
+
def configure_iface(self):
""" Configure the interface without the ip
self._omf_api.configure(self.node.get('hostname'), attrname,
attrval)
except AttributeError:
+ self._state = ResourceState.FAILED
msg = "Credentials are not initialzed. XMPP Connections impossible"
- self.error(msg)
- raise
+ self.debug(msg)
+ #raise
super(OMFWifiInterface, self).provision()
+ return True
def configure_ip(self):
""" Configure the ip of the interface
attrval)
except AttributeError:
msg = "Credentials are not initialzed. XMPP Connections impossible"
- self.error(msg)
- raise
+ self.debug(msg)
+ self.fail()
+ #raise
+ return True
def 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
"""
- if not self._omf_api:
+ 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.ec.exp_id)
+ self.get('xmppPassword'), exp_id = self.exp_id)
- if not self._omf_api:
+ if not self._omf_api :
msg = "Credentials are not initialzed. XMPP Connections impossible"
self.error(msg)
self.fail()
msg = "Interface's variable are not initialized"
self.error(msg)
self.fail()
- return
+ return False
if not self.node.get('hostname') :
msg = "The channel is connected with an undefined node"
self.error(msg)
self.fail()
- return
+ return False
# Just for information
self.debug(" " + self.rtype() + " ( Guid : " + str(self._guid) +") : " + \
self.get('essid') + " : " + self.get('ip'))
# Check if the node is already deployed
- try:
- if self.state < ResourceState.PROVISIONED:
- if self.configure_iface():
- self.configure_ip()
- except:
- self.fail()
- return
+ chk1 = True
+ if self.state < ResourceState.PROVISIONED:
+ chk1 = self.configure_iface()
+ if chk1:
+ chk2 = self.configure_ip()
+ if not (chk1 and chk2) :
+ return False
+
super(OMFWifiInterface, self).deploy()
+ return True
+
+
+ def start(self):
+ """ Start the RM. It means nothing special for a channel for now
+ It becomes STARTED as soon as this method starts.
+
+ """
+
+ super(OMFWifiInterface, self).start()
+
+ def stop(self):
+ """ Stop the RM. It means nothing special for a channel for now
+ It becomes STOPPED as soon as this method is called
+
+ """
+ super(OMFWifiInterface, self).stop()
+ self.set_finished()
def release(self):
""" Clean the RM at the end of the experiment and release the API
"""
- if self._omf_api:
+ if self._omf_api :
OMFAPIFactory.release_api(self.get('xmppSlice'),
self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.ec.exp_id)
+ self.get('xmppPassword'), exp_id = self.exp_id)
super(OMFWifiInterface, self).release()
path = self._attr_element(execute,"PATH",path)
return payload
+ def stdin_function(self, target, value, appid):
+ """ Build an Execute Message
+
+ :param value: parameter that go in the stdin
+ :type value: str
+ :param target: Hrn of the target node (ex : omf.plexus.wlab17)
+ :type target: str
+ :param appid: Application id
+ :type appid: str
+
+ """
+ payload = ET.Element("omf-message")
+ stdin = self._id_element(payload,"STDIN")
+ value = self._attr_element(stdin,"VALUE",value)
+ sliceid = self._attr_element(stdin,"SLICEID",self._slice_id)
+ expid = self._attr_element(stdin,"EXPID",self._exp_id)
+ target = self._attr_element(stdin,"TARGET",target)
+ appid = self._attr_element(stdin,"APPID",appid)
+ return payload
+
def exit_function(self, target, appid):
""" Build an Exit Message
# Julien Tribino <julien.tribino@inria.fr>
-from nepi.execution.resource import ResourceManager, clsinit, ResourceState, \
+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.omf_api import OMFAPIFactory
import time
-@clsinit
-class OMFNode(ResourceManager):
+@clsinit_copy
+class OMFNode(OMFResource):
"""
.. class:: Class Args :
"""
hostname = Attribute("hostname", "Hostname of the machine")
- cpu = Attribute("cpu", "CPU of the node")
- ram = Attribute("ram", "RAM of the node")
- xmppSlice = Attribute("xmppSlice","Name of the slice",
- flags = Flags.Credential)
- xmppHost = Attribute("xmppHost", "Xmpp Server",
- flags = Flags.Credential)
- xmppPort = Attribute("xmppPort", "Xmpp Port",
- flags = Flags.Credential)
- xmppPassword = Attribute("xmppPassword", "Xmpp Port",
- flags = Flags.Credential)
-
- host = Attribute("host", "Hostname of the machine",
- flags = Flags.Filter)
- gateway = Attribute("gateway", "Gateway",
- flags = Flags.Filter)
- granularity = Attribute("granularity", "Granularity of the reservation time",
- flags = Flags.Filter)
- hardware_type = Attribute("hardware_type", "Hardware type of the machine",
- flags = Flags.Filter)
cls._register_attribute(hostname)
- cls._register_attribute(ram)
- cls._register_attribute(cpu)
- cls._register_attribute(xmppSlice)
- cls._register_attribute(xmppHost)
- cls._register_attribute(xmppPort)
- cls._register_attribute(xmppPassword)
-
- cls._register_attribute(host)
- cls._register_attribute(gateway)
- cls._register_attribute(granularity)
- cls._register_attribute(hardware_type)
# XXX: We don't necessary need to have the credentials at the
# moment we create the RM
self._omf_api = None
+ @property
+ def exp_id(self):
+ return self.ec.exp_id
+
def valid_connection(self, guid):
""" Check if the connection with the guid in parameter is possible.
Only meaningful connections are allowed.
It becomes DEPLOYED after sending messages to enroll the node
"""
- if not self._omf_api:
+ 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.ec.exp_id)
+ self.get('xmppPassword'), exp_id = self.exp_id)
- if not self._omf_api:
+ if not self._omf_api :
msg = "Credentials are not initialzed. XMPP Connections impossible"
self.error(msg)
self.fail()
return
- if not self.get('hostname'):
+ if not self.get('hostname') :
msg = "Hostname's value is not initialized"
self.error(msg)
self.fail()
- return
+ return False
try:
self._omf_api.enroll_host(self.get('hostname'))
msg = "Credentials are not initialzed. XMPP Connections impossible"
self.error(msg)
self.fail()
- return
+ #raise AttributeError, msg
super(OMFNode, self).deploy()
It becomes STARTED as soon as this method starts.
"""
+
super(OMFNode, self).start()
def stop(self):
"""
super(OMFNode, self).stop()
+ self.set_finished()
def release(self):
"""Clean the RM at the end of the experiment
"""
- if self._omf_api:
+ if self._omf_api :
self._omf_api.release(self.get('hostname'))
OMFAPIFactory.release_api(self.get('xmppSlice'),
self.get('xmppHost'), self.get('xmppPort'),
- self.get('xmppPassword'), exp_id = self.ec.exp_id)
+ self.get('xmppPassword'), exp_id = self.exp_id)
super(OMFNode, self).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 nepi.execution.resource import ResourceManager, clsinit
-from nepi.execution.attribute import Attribute
-
-from nepi.resources.omf.omf_api import OMFAPIFactory
-
-@clsinit
-class OMFResource(ResourceManager):
- _rtype = "OMFResource"
-
- @classmethod
- def _register_attributes(cls):
- xmppSlice = Attribute("xmppSlice","Name of the slice", flags = "0x02")
- xmppHost = Attribute("xmppHost", "Xmpp Server",flags = "0x02")
- xmppPort = Attribute("xmppPort", "Xmpp Port",flags = "0x02")
- xmppPassword = Attribute("xmppPassword", "Xmpp Port",flags = "0x02")
- cls._register_attribute(xmppSlice)
- cls._register_attribute(xmppHost)
- cls._register_attribute(xmppPort)
- cls._register_attribute(xmppPassword)
-
- def __init__(self, ec, guid, creds):
- super(OMFNode, self).__init__(ec, guid)
- self.set('xmppSlice', creds['xmppSlice'])
- self.set('xmppHost', creds['xmppHost'])
- self.set('xmppPort', creds['xmppPort'])
- self.set('xmppPassword', creds['xmppPassword'])
-
- self._omf_api = OMFAPIFactory.get_api(self.get('xmppSlice'), self.get('xmppHost'), self.get('xmppPort'), self.get('xmppPassword'))
-
- def discover(self):
- pass
-
- def provision(self, credential):
- pass
-
-
class DummyRM(ResourceManager):
pass
-
class OMFResourceFactoryTestCase(unittest.TestCase):
def test_creation_phase(self):
self.assertEquals(OMFNode.rtype(), "OMFNode")
- self.assertEquals(len(OMFNode._attributes), 11)
+ self.assertEquals(len(OMFNode._attributes), 5)
self.assertEquals(OMFWifiInterface.rtype(), "OMFWifiInterface")
self.assertEquals(len(OMFWifiInterface._attributes), 9)
self.assertEquals(len(OMFChannel._attributes), 5)
self.assertEquals(OMFApplication.rtype(), "OMFApplication")
- self.assertEquals(len(OMFApplication._attributes), 8)
+ self.assertEquals(len(OMFApplication._attributes), 12)
class OMFEachTestCase(unittest.TestCase):
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, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
- self.ec.set(self.app1, 'xmppSlice', "nepi")
- self.ec.set(self.app1, 'xmppHost', "xmpp-plexus.onelab.eu")
- self.ec.set(self.app1, 'xmppPort', "5222")
- self.ec.set(self.app1, 'xmppPassword', "1234")
self.app2 = self.ec.register_resource("OMFApplication")
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, 'env'), 'DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority')
- self.assertEquals(self.ec.get(self.app1, 'xmppSlice'), 'nepi')
- self.assertEquals(self.ec.get(self.app1, 'xmppHost'), 'xmpp-plexus.onelab.eu')
- self.assertEquals(self.ec.get(self.app1, 'xmppPort'), '5222')
- self.assertEquals(self.ec.get(self.app1, 'xmppPassword'), '1234')
def test_connection(self):
self.assertEquals(len(self.ec.get_resource(self.node1).connections), 6)
self.assertEquals(len(self.ec.get_resource(self.app5).conditions[ResourceAction.START]), 2)
-
class OMFVLCTestCaseComplete(unittest.TestCase):
def test_deploy(self):
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, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
- ec.set(self.app1, 'xmppSlice', "nepi")
- ec.set(self.app1, 'xmppHost', "xmpp-plexus.onelab.eu")
- ec.set(self.app1, 'xmppPort', "5222")
- ec.set(self.app1, 'xmppPassword', "1234")
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, 'env', " ")
- ec.set(self.app2, 'xmppSlice', "nepi")
- ec.set(self.app2, 'xmppHost', "xmpp-plexus.onelab.eu")
- ec.set(self.app2, 'xmppPort', "5222")
- ec.set(self.app2, 'xmppPassword', "1234")
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, 'env', " ")
- ec.set(self.app3, 'xmppSlice', "nepi")
- ec.set(self.app3, 'xmppHost', "xmpp-plexus.onelab.eu")
- ec.set(self.app3, 'xmppPort', "5222")
- ec.set(self.app3, 'xmppPassword', "1234")
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, 'env', " ")
- ec.set(self.app4, 'xmppSlice', "nepi")
- ec.set(self.app4, 'xmppHost', "xmpp-plexus.onelab.eu")
- ec.set(self.app4, 'xmppPort', "5222")
- ec.set(self.app4, 'xmppPassword', "1234")
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, 'env', " ")
- ec.set(self.app5, 'xmppSlice', "nepi")
- ec.set(self.app5, 'xmppHost', "xmpp-plexus.onelab.eu")
- ec.set(self.app5, 'xmppPort', "5222")
- ec.set(self.app5, 'xmppPassword', "1234")
ec.register_connection(self.app1, self.node1)
ec.register_connection(self.app2, self.node1)
ec.wait_finished([self.app1, self.app2, self.app3,self.app4, self.app5])
- time.sleep(2)
+ time.sleep(1)
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(ec.get_resource(self.app5).state, ResourceState.FINISHED)
ec.shutdown()
- time.sleep(2)
+ time.sleep(1)
self.assertEquals(ec.get_resource(self.node1).state, ResourceState.RELEASED)
self.assertEquals(ec.get_resource(self.iface1).state, ResourceState.RELEASED)
class OMFVLCTestCaseNoComplete(unittest.TestCase):
- def test_deploy(self):
+ def xtest_deploy(self):
ec = DummyEC(exp_id = "1245" )
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, 'env', "DISPLAY=localhost:10.0 XAUTHORITY=/root/.Xauthority")
- ec.set(self.app1, 'xmppSlice', "nepi")
- ec.set(self.app1, 'xmppHost', "xmpp-plexus.onelab.eu")
- ec.set(self.app1, 'xmppPort', "5222")
- ec.set(self.app1, 'xmppPassword', "1234")
self.app2 = ec.register_resource("OMFApplication")
- ec.set(self.app2, 'xmppSlice', "nepi")
- ec.set(self.app2, 'xmppHost', "xmpp-plexus.onelab.eu")
- ec.set(self.app2, 'xmppPort', "5222")
- ec.set(self.app2, 'xmppPassword', "1234")
self.app3 = ec.register_resource("OMFApplication")
ec.set(self.app3, 'appid', 'Kill#2')
ec.set(self.app3, 'args', "vlc")
ec.set(self.app3, 'env', " ")
- self.app4 = ec.register_resource("OMFApplication")
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.node1, self.iface1)
ec.register_connection(self.iface1, self.channel)
ec.register_connection(self.node2, self.iface2)
ec.register_condition(self.app2, ResourceAction.START, self.app1, ResourceState.STARTED , "2s")
ec.register_condition(self.app3, ResourceAction.START, self.app2, ResourceState.STARTED , "2s")
- ec.register_condition(self.app4, ResourceAction.START, [self.app3, self.app2], ResourceState.STARTED , "2s")
- ec.register_condition([self.app1, self.app2, self.app3], ResourceAction.STOP, self.app1, ResourceState.STARTED , "8s")
+ ec.register_condition([self.app1, self.app2, self.app3], ResourceAction.STOP, self.app1, ResourceState.STARTED , "6s")
ec.deploy()
- ec.wait_finished([self.app1, self.app2, self.app3,self.app4])
+ ec.wait_finished([self.app1, self.app2, self.app3])
self.assertEquals(ec.get_resource(self.node1).state, ResourceState.STARTED)
self.assertEquals(ec.get_resource(self.node2).state, ResourceState.FAILED)
self.assertEquals(ec.get_resource(self.channel).state, ResourceState.STARTED)
self.assertEquals(ec.get_resource(self.app1).state, ResourceState.FINISHED)
self.assertEquals(ec.get_resource(self.app2).state, ResourceState.FAILED)
- self.assertEquals(ec.get_resource(self.app3).state, ResourceState.FAILED)
- self.assertEquals(ec.get_resource(self.app4).state, ResourceState.FAILED)
+ self.assertEquals(ec.get_resource(self.app3).state, ResourceState.FINISHED)
time.sleep(1)
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)
if __name__ == '__main__':
unittest.main()