From: Julien Tribino Date: Mon, 4 Nov 2013 17:45:02 +0000 (+0100) Subject: updated Robot demo X-Git-Tag: nepi-3.0.0~20^2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=2260b2cb2db7fa845eeae311bc044742e7f7b06d;p=nepi.git updated Robot demo --- diff --git a/examples/omf/nepi_omf_stdin_iminds.py b/examples/omf/nepi_omf_stdin_iminds.py index 1c6d91e7..df95a247 100644 --- a/examples/omf/nepi_omf_stdin_iminds.py +++ b/examples/omf/nepi_omf_stdin_iminds.py @@ -42,6 +42,8 @@ from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState from nepi.execution.ec import ExperimentController +import time + # Create the EC ec = ExperimentController() @@ -58,11 +60,11 @@ ec.set(node1, 'xmppPassword', "1234") # Create and Configure the Application app1 = ec.register_resource("OMFRobotApplication") ec.set(app1, 'appid', "robot") -ec.set(app1, 'path', "/users/jtribino/RobotCTRLComm.rb") -ec.set(app1, 'args', "/users/jtribino/coordinate.csv") +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, 'env', " ") -ec.set(app1, 'sources', "/home/wlab18/Desktop/coordinate.csv") -ec.set(app1, 'sshUser', "jtribino") +ec.set(app1, 'sources', "/home/wlab18/Desktop/coordinate.csv") # local path +ec.set(app1, 'sshUser', "jtribino") # username # Connection ec.register_connection(app1, node1) @@ -85,5 +87,5 @@ ec.set(app1, 'stdin', "2;openlefteye") ec.wait_finished([app1]) - Stop Experiment +# Stop Experiment ec.shutdown() diff --git a/src/nepi/resources/omf/application.py b/src/nepi/resources/omf/application.py index 4a3f027f..75a277f1 100644 --- a/src/nepi/resources/omf/application.py +++ b/src/nepi/resources/omf/application.py @@ -25,6 +25,8 @@ 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 import sshfuncs + @clsinit_copy class OMFApplication(OMFResource): """ @@ -56,11 +58,20 @@ class OMFApplication(OMFResource): args = Attribute("args", "Argument of the application") env = Attribute("env", "Environnement variable of the application") 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(stdin) + cls._register_attribute(sources) + cls._register_attribute(sshuser) + cls._register_attribute(sshkey) def __init__(self, ec, guid): """ @@ -142,15 +153,27 @@ class OMFApplication(OMFResource): 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.get('xmppSlice') and self.get('xmppHost') + and self.get('xmppPort') and self.get('xmppPassword')): + msg = "Credentials are 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._omf_api : - msg = "Credentials are not initialzed. XMPP Connections impossible" - self.error(msg) - raise RuntimeError, 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) super(OMFApplication, self).do_deploy()