+ self.begin_deploy_time = tnow()
+
+ 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 trace(self, name, attr = TraceAttr.ALL, block = 512, offset = 0):
+ self.info("Retrieving '%s' trace %s " % (name, attr))
+ if name == 'stdout' :
+ suffix = '.out'
+ elif name == 'stderr' :
+ suffix = '.err'
+ else :
+ suffix = '.misc'
+
+ trace_path = '/tmp/'+ self._topic_app + suffix
+
+ if attr == TraceAttr.PATH:
+ return trace_path
+
+ if attr == TraceAttr.ALL:
+ try:
+ f = open(trace_path ,'r')
+ except IOError:
+ print("File with traces has not been found")
+ return False
+ out = f.read()
+ f.close()
+ return out
+
+
+ def do_start(self):