From 149ee266626c0ed66d4facf5eaf00cfdf381aff6 Mon Sep 17 00:00:00 2001 From: Julien Tribino Date: Tue, 22 Oct 2013 17:10:14 +0200 Subject: [PATCH] update omf part with last changes for the demo --- .../omf/automated_vlc_experiment_plexus.py | 147 -------------- examples/omf/manual_vlc_experiment_plexus.py | 189 ------------------ examples/omf/nepi_omf_vlc_experiment.py | 17 +- examples/omf/nepi_omf_vlc_nitos.py | 16 -- examples/omf/nepi_omf_xeyes_nitos.py | 8 - src/nepi/resources/omf/application.py | 64 ++++-- src/nepi/resources/omf/channel.py | 18 +- src/nepi/resources/omf/interface.py | 80 +++++--- src/nepi/resources/omf/messages_5_4.py | 20 ++ src/nepi/resources/omf/node.py | 60 ++---- src/nepi/resources/omf/xx_omf_resource.py | 56 ------ test/resources/omf/vlc.py | 59 +----- 12 files changed, 150 insertions(+), 584 deletions(-) delete mode 100755 examples/omf/automated_vlc_experiment_plexus.py delete mode 100755 examples/omf/manual_vlc_experiment_plexus.py delete mode 100644 src/nepi/resources/omf/xx_omf_resource.py diff --git a/examples/omf/automated_vlc_experiment_plexus.py b/examples/omf/automated_vlc_experiment_plexus.py deleted file mode 100755 index e1e99fa6..00000000 --- a/examples/omf/automated_vlc_experiment_plexus.py +++ /dev/null @@ -1,147 +0,0 @@ -#!/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 . -# -# Author: Julien Tribino - -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() diff --git a/examples/omf/manual_vlc_experiment_plexus.py b/examples/omf/manual_vlc_experiment_plexus.py deleted file mode 100755 index 1b9ec405..00000000 --- a/examples/omf/manual_vlc_experiment_plexus.py +++ /dev/null @@ -1,189 +0,0 @@ -#!/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 . -# -# Author: Julien Tribino - -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() diff --git a/examples/omf/nepi_omf_vlc_experiment.py b/examples/omf/nepi_omf_vlc_experiment.py index 3e5e7c4c..5cf0e8b9 100644 --- a/examples/omf/nepi_omf_vlc_experiment.py +++ b/examples/omf/nepi_omf_vlc_experiment.py @@ -18,15 +18,12 @@ """ #!/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') @@ -81,30 +78,18 @@ ec.set(app1, 'args', "--quiet /opt/10-by-p0d.avi --sout '#rtp{dst=10.0.0.37,port #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) diff --git a/examples/omf/nepi_omf_vlc_nitos.py b/examples/omf/nepi_omf_vlc_nitos.py index 5a1237a2..61ef0756 100644 --- a/examples/omf/nepi_omf_vlc_nitos.py +++ b/examples/omf/nepi_omf_vlc_nitos.py @@ -80,40 +80,24 @@ 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, '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) diff --git a/examples/omf/nepi_omf_xeyes_nitos.py b/examples/omf/nepi_omf_xeyes_nitos.py index 1049ff8f..509d1ed4 100644 --- a/examples/omf/nepi_omf_xeyes_nitos.py +++ b/examples/omf/nepi_omf_xeyes_nitos.py @@ -61,20 +61,12 @@ ec.set(app1, 'appid', 'XEyes#1') 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) diff --git a/src/nepi/resources/omf/application.py b/src/nepi/resources/omf/application.py index 0bc0c622..f0fc5f10 100644 --- a/src/nepi/resources/omf/application.py +++ b/src/nepi/resources/omf/application.py @@ -18,15 +18,19 @@ # Author: Alina Quereilhac # Julien Tribino -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 : @@ -51,24 +55,25 @@ class OMFApplication(ResourceManager): """ 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): """ @@ -91,12 +96,26 @@ class OMFApplication(ResourceManager): 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. @@ -120,9 +139,7 @@ class OMFApplication(ResourceManager): "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) @@ -136,10 +153,15 @@ class OMFApplication(ResourceManager): 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" @@ -147,8 +169,15 @@ class OMFApplication(ResourceManager): 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. @@ -198,6 +227,7 @@ class OMFApplication(ResourceManager): return super(OMFApplication, self).stop() + self.set_finished() def release(self): """ Clean the RM at the end of the experiment and release the API. @@ -206,7 +236,7 @@ class OMFApplication(ResourceManager): 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() diff --git a/src/nepi/resources/omf/channel.py b/src/nepi/resources/omf/channel.py index ccd67be0..b5d96a37 100644 --- a/src/nepi/resources/omf/channel.py +++ b/src/nepi/resources/omf/channel.py @@ -18,15 +18,16 @@ # Author: Alina Quereilhac # Julien Tribino -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 : @@ -51,15 +52,7 @@ class OMFChannel(ResourceManager): """ 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): """ @@ -79,8 +72,6 @@ class OMFChannel(ResourceManager): @property def exp_id(self): - if self.ec.exp_id.startswith('exp-'): - return None return self.ec.exp_id def valid_connection(self, guid): @@ -198,6 +189,7 @@ class OMFChannel(ResourceManager): """ super(OMFChannel, self).stop() + self.set_finished() def release(self): """ Clean the RM at the end of the experiment and release the API diff --git a/src/nepi/resources/omf/interface.py b/src/nepi/resources/omf/interface.py index 1fb17626..4e1a66da 100644 --- a/src/nepi/resources/omf/interface.py +++ b/src/nepi/resources/omf/interface.py @@ -18,16 +18,17 @@ # Author: Alina Quereilhac # Julien Tribino -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 : @@ -59,15 +60,7 @@ class OMFWifiInterface(ResourceManager): 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) @@ -102,6 +95,7 @@ class OMFWifiInterface(ResourceManager): 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" % \ @@ -110,6 +104,10 @@ class OMFWifiInterface(ResourceManager): return False + @property + def exp_id(self): + return self.ec.exp_id + @property def node(self): rm_list = self.get_connected(OMFNode.rtype()) @@ -122,6 +120,7 @@ class OMFWifiInterface(ResourceManager): if rm_list: return rm_list[0] return None + def configure_iface(self): """ Configure the interface without the ip @@ -137,11 +136,13 @@ class OMFWifiInterface(ResourceManager): 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 @@ -158,21 +159,23 @@ class OMFWifiInterface(ResourceManager): 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() @@ -183,13 +186,13 @@ class OMFWifiInterface(ResourceManager): 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) +") : " + \ @@ -197,24 +200,43 @@ class OMFWifiInterface(ResourceManager): 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() diff --git a/src/nepi/resources/omf/messages_5_4.py b/src/nepi/resources/omf/messages_5_4.py index b27531ae..06c38f47 100644 --- a/src/nepi/resources/omf/messages_5_4.py +++ b/src/nepi/resources/omf/messages_5_4.py @@ -102,6 +102,26 @@ class MessageHandler(): 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 diff --git a/src/nepi/resources/omf/node.py b/src/nepi/resources/omf/node.py index 570afd07..99bedf67 100644 --- a/src/nepi/resources/omf/node.py +++ b/src/nepi/resources/omf/node.py @@ -19,17 +19,17 @@ # Julien Tribino -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 : @@ -54,38 +54,8 @@ class OMFNode(ResourceManager): """ 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 @@ -101,6 +71,10 @@ class OMFNode(ResourceManager): 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. @@ -130,22 +104,22 @@ class OMFNode(ResourceManager): 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')) @@ -153,7 +127,7 @@ class OMFNode(ResourceManager): msg = "Credentials are not initialzed. XMPP Connections impossible" self.error(msg) self.fail() - return + #raise AttributeError, msg super(OMFNode, self).deploy() @@ -174,6 +148,7 @@ class OMFNode(ResourceManager): It becomes STARTED as soon as this method starts. """ + super(OMFNode, self).start() def stop(self): @@ -182,17 +157,18 @@ class OMFNode(ResourceManager): """ 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() diff --git a/src/nepi/resources/omf/xx_omf_resource.py b/src/nepi/resources/omf/xx_omf_resource.py deleted file mode 100644 index 2e9b269e..00000000 --- a/src/nepi/resources/omf/xx_omf_resource.py +++ /dev/null @@ -1,56 +0,0 @@ -# -# 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 . -# -# Author: Alina Quereilhac -# Julien Tribino - -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 - - diff --git a/test/resources/omf/vlc.py b/test/resources/omf/vlc.py index a86af14f..ddc18137 100755 --- a/test/resources/omf/vlc.py +++ b/test/resources/omf/vlc.py @@ -39,13 +39,12 @@ class DummyEC(ExperimentController): 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) @@ -54,7 +53,7 @@ class OMFResourceFactoryTestCase(unittest.TestCase): 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): @@ -92,10 +91,6 @@ 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") @@ -152,10 +147,6 @@ class OMFEachTestCase(unittest.TestCase): 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) @@ -172,7 +163,6 @@ class OMFEachTestCase(unittest.TestCase): self.assertEquals(len(self.ec.get_resource(self.app5).conditions[ResourceAction.START]), 2) - class OMFVLCTestCaseComplete(unittest.TestCase): def test_deploy(self): @@ -208,50 +198,30 @@ class OMFVLCTestCaseComplete(unittest.TestCase): 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) @@ -273,7 +243,7 @@ class OMFVLCTestCaseComplete(unittest.TestCase): 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) @@ -291,7 +261,7 @@ class OMFVLCTestCaseComplete(unittest.TestCase): 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) @@ -305,7 +275,7 @@ class OMFVLCTestCaseComplete(unittest.TestCase): class OMFVLCTestCaseNoComplete(unittest.TestCase): - def test_deploy(self): + def xtest_deploy(self): ec = DummyEC(exp_id = "1245" ) @@ -343,16 +313,8 @@ class OMFVLCTestCaseNoComplete(unittest.TestCase): 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') @@ -360,12 +322,10 @@ class OMFVLCTestCaseNoComplete(unittest.TestCase): 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) @@ -373,13 +333,12 @@ class OMFVLCTestCaseNoComplete(unittest.TestCase): 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) @@ -388,8 +347,7 @@ class OMFVLCTestCaseNoComplete(unittest.TestCase): 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) @@ -403,7 +361,6 @@ class OMFVLCTestCaseNoComplete(unittest.TestCase): 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() -- 2.47.0