Exemple #1
0
    def execute(self, conf=None, caller=None, apMon=None, logger=None):
        """
        This method is invoked by fdtd once the action object is received
        from remote fdtcp (where the action instance was created). Options
        known on fdtd are set on the action instance (e.g. finalizing command
        for invoking FDT Java - location of fdt.jar is known only at fdtd site).
        """
        # this method is called on PYRO service side, user its logger
        # from now on
        localGridUser = self.options["gridUserSrc"]
        logger.debug("Local grid user is '%s'" % localGridUser)
        self.options["sudouser"] = localGridUser

        self._setUp(conf)
        killTimeout = conf.get("fdtSendingClientKillTimeout")
        executor = Executor(self.id,
                            self.command,
                            blocking=True,
                            caller=caller,
                            userName=localGridUser,
                            killTimeout=killTimeout,
                            syncFlag=False,
                            logger=logger)
        try:
            try:
                output = executor.execute()
            except ExecutorException as ex:
                m = ("FDT Java client on %s failed, "
                     "reason: %s" % (getHostName(), ex))
                logger.error(m)
                raise FDTDException(m)
            except Exception as ex:
                m = ("FDT Java client on %s failed, "
                     "reason: %s" % (getHostName(), ex))
                logger.error(m, traceBack=True)
                raise FDTDException(m)
            else:
                # no other exception was raised during execution
                r = Result(self.id)
                r.status = 0
                r.log = output
                r.msg = "Output from FDT client"
                logger.debug("FDT client log (as sent to "
                             "fdtcp):\n%s" % output)
                return r
        finally:
            # give signal on this actions Executor instance that its handling
            # finished (e.g. CleanupProcessesAction may be waiting for this)
            executor.syncFlag = False