Ejemplo n.º 1
0
    def getJobStatus(self, jobIDList):
        """Get the status information for the given list of jobs"""
        # If we use a local schedd, then we have to cleanup executables regularly
        if self.useLocalSchedd:
            self.__cleanup()

        self.log.verbose("Job ID List for status: %s " % jobIDList)
        if isinstance(jobIDList, six.string_types):
            jobIDList = [jobIDList]

        resultDict = {}
        condorIDs = {}
        # Get all condorIDs so we can just call condor_q and condor_history once
        for jobRef in jobIDList:
            job, _, jobID = condorIDAndPathToResultFromJobRef(jobRef)
            condorIDs[job] = jobID

        qList = []
        for _condorIDs in breakListIntoChunks(condorIDs.values(), 100):

            # This will return a list of 1245.75 3
            status, stdout_q = commands.getstatusoutput(
                "condor_q %s %s -af:j JobStatus " %
                (self.remoteScheddOptions, " ".join(_condorIDs)))
            if status != 0:
                return S_ERROR(stdout_q)
            _qList = stdout_q.strip().split("\n")
            qList.extend(_qList)

            # FIXME: condor_history does only support j for autoformat from 8.5.3,
            # format adds whitespace for each field This will return a list of 1245 75 3
            # needs to cocatenate the first two with a dot
            condorHistCall = "condor_history %s %s -af ClusterId ProcId JobStatus" % (
                self.remoteScheddOptions,
                " ".join(_condorIDs),
            )

            treatCondorHistory(condorHistCall, qList)

        for job, jobID in condorIDs.items():

            pilotStatus = parseCondorStatus(qList, jobID)
            if pilotStatus == "HELD":
                # make sure the pilot stays dead and gets taken out of the condor_q
                _rmStat, _rmOut = commands.getstatusoutput(
                    "condor_rm %s %s " % (self.remoteScheddOptions, jobID))
                # self.log.debug( "condor job killed: job %s, stat %s, message %s " % ( jobID, rmStat, rmOut ) )
                pilotStatus = PilotStatus.ABORTED

            resultDict[job] = pilotStatus

        self.log.verbose("Pilot Statuses: %s " % resultDict)
        return S_OK(resultDict)
Ejemplo n.º 2
0
    def getJobStatus(self, jobIDList):
        """ Get the status information for the given list of jobs
    """
        self.__cleanup()

        self.log.verbose("Job ID List for status: %s " % jobIDList)
        if isinstance(jobIDList, basestring):
            jobIDList = [jobIDList]

        resultDict = {}
        condorIDs = {}
        ##Get all condorIDs so we can just call condor_q and condor_history once
        for jobRef in jobIDList:
            job, jobID = condorIDFromJobRef(jobRef)
            condorIDs[job] = jobID

        ##This will return a list of 1245.75 3
        status, stdout_q = commands.getstatusoutput(
            'condor_q %s %s -af:j JobStatus ' %
            (self.remoteScheddOptions, ' '.join(condorIDs.values())))
        if status != 0:
            return S_ERROR(stdout_q)
        qList = stdout_q.strip().split('\n')

        ##FIXME: condor_history does only support j for autoformat from 8.5.3,
        ## format adds whitespace for each field This will return a list of 1245 75 3
        ## needs to cocatenate the first two with a dot
        condorHistCall = 'condor_history %s %s -af ClusterId ProcId JobStatus' % (
            self.remoteScheddOptions, ' '.join(condorIDs.values()))

        treatCondorHistory(condorHistCall, qList)

        for job, jobID in condorIDs.iteritems():

            pilotStatus = parseCondorStatus(qList, jobID)
            if pilotStatus == 'HELD':
                #make sure the pilot stays dead and gets taken out of the condor_q
                _rmStat, _rmOut = commands.getstatusoutput(
                    'condor_rm %s %s ' % (self.remoteScheddOptions, jobID))
                #self.log.debug( "condor job killed: job %s, stat %s, message %s " % ( jobID, rmStat, rmOut ) )
                pilotStatus = 'Aborted'

            resultDict[job] = pilotStatus

        self.log.verbose("Pilot Statuses: %s " % resultDict)
        return S_OK(resultDict)
  def getJobStatus(self, jobIDList):
    """ Get the status information for the given list of jobs
    """
    self.__cleanup()

    self.log.verbose("Job ID List for status: %s " % jobIDList)
    if isinstance(jobIDList, basestring):
      jobIDList = [jobIDList]

    resultDict = {}
    condorIDs = {}
    # Get all condorIDs so we can just call condor_q and condor_history once
    for jobRef in jobIDList:
      job, jobID = condorIDFromJobRef(jobRef)
      condorIDs[job] = jobID

    # This will return a list of 1245.75 3
    status, stdout_q = commands.getstatusoutput(
        'condor_q %s %s -af:j JobStatus ' %
        (self.remoteScheddOptions, ' '.join(
            condorIDs.values())))
    if status != 0:
      return S_ERROR(stdout_q)
    qList = stdout_q.strip().split('\n')

    # FIXME: condor_history does only support j for autoformat from 8.5.3,
    # format adds whitespace for each field This will return a list of 1245 75 3
    # needs to cocatenate the first two with a dot
    condorHistCall = 'condor_history %s %s -af ClusterId ProcId JobStatus' % (
        self.remoteScheddOptions, ' '.join(condorIDs.values()))

    treatCondorHistory(condorHistCall, qList)

    for job, jobID in condorIDs.iteritems():

      pilotStatus = parseCondorStatus(qList, jobID)
      if pilotStatus == 'HELD':
        # make sure the pilot stays dead and gets taken out of the condor_q
        _rmStat, _rmOut = commands.getstatusoutput('condor_rm %s %s ' % (self.remoteScheddOptions, jobID))
        #self.log.debug( "condor job killed: job %s, stat %s, message %s " % ( jobID, rmStat, rmOut ) )
        pilotStatus = 'Aborted'

      resultDict[job] = pilotStatus

    self.log.verbose("Pilot Statuses: %s " % resultDict)
    return S_OK(resultDict)