def checkJobs( self, jobIds, errors ):
        """
        check a list of provided job id
        """
        
        for jobId in jobIds:

            try:
                
                wrapStatus = Status(jobId, 0)
                # Check for Errors
                err , apiMsg = wrapStatus.get_error ()
                if err:
                    # Print the error and terminate
                    raise Exception(apiMsg)

                # Retrieve the number of status (in this case is always 1)
                # statusNumber = wrapStatus.getStatusNumber()
 
                # Retrieve the list of attributes for the current UNIQUE event
                statusAttribute = wrapStatus.getStatusAttributes(0)
                
                # Check for Errors
                err , apiMsg = wrapStatus.get_error ()
                if err:
                    # Print the error and terminate
                    raise Exception(apiMsg)

                jobInfo = statusAttribute

                # retrieve scheduler Id
                jobSchedId = str(jobInfo[self.jobId])

                # update just loaded jobs
                try:
                    job = jobIds[jobSchedId]
                except :
                    continue
                    
                 # update runningJob
                self.getJobInfo(jobInfo, job )
                if job['statusScheduler'] == 'Aborted' :
                    self.getAbortReason(job)
                
                jobIds[jobSchedId] = job
                
            except Exception, err :
                errors.append(
                    "skipping " + jobId + " : " +  str(err) )
Exemple #2
0
    def __init__(self):

        # counter
        self.st = 0

        # instatiating status object
        self.statusObj = Status()

        # Loading dictionary with available parameters list
        self.jobStatus = lbJob.JobStatus(self.statusObj)
        self.states = self.jobStatus.states_names
        self.attrNumber = self.jobStatus.ATTR_MAX

        # defining fields of interest
        self.status = self.states.index('Status')
        self.reason = self.states.index('Reason')
        self.networkServer = self.states.index('Network server')
        self.destination = self.states.index('Destination')
        self.stateEnterTimes = self.states.index('Stateentertimes')
        self.doneCode = self.states.index('Done code')
        self.jobId = self.states.index('Jobid')

        import re
        self.ft = re.compile(
            "(\d+)Undefined=(\d+) Submitted=(\d+) Waiting=(\d+) Ready=(\d+) Scheduled=(\d+) Running=(\d+) Done=(\d+) Cleared=(\d+) Aborted=(\d+) Cancelled=(\d+) Unknown=(\d+) Purged=(\d+)"
        )
Exemple #3
0
    def checkJobs(self, jobIds, errors):
        """
        check a list of provided job id
        """

        for jobId in jobIds:

            try:

                wrapStatus = Status(jobId, 0)
                # Check for Errors
                err, apiMsg = wrapStatus.get_error()
                if err:
                    # Print the error and terminate
                    raise Exception(apiMsg)

                # Retrieve the number of status (in this case is always 1)
                # statusNumber = wrapStatus.getStatusNumber()

                # Retrieve the list of attributes for the current UNIQUE event
                statusAttribute = wrapStatus.getStatusAttributes(0)

                # Check for Errors
                err, apiMsg = wrapStatus.get_error()
                if err:
                    # Print the error and terminate
                    raise Exception(apiMsg)

                jobInfo = statusAttribute

                # retrieve scheduler Id
                jobSchedId = str(jobInfo[self.jobId])

                # update just loaded jobs
                try:
                    job = jobIds[jobSchedId]
                except:
                    continue

                # update runningJob
                self.getJobInfo(jobInfo, job)

                jobIds[jobSchedId] = job

            except Exception as err:
                errors.append("skipping " + jobId + " : " + str(err))
    def __init__(self, config, name):
        glite_path = os.environ.get('GLITE_WMS_LOCATION',
                                    os.environ.get('GLITE_LOCATION', ''))
        stored_sys_path = list(sys.path)
        for dn in [
                'lib', 'lib64',
                os.path.join('lib', 'python'),
                os.path.join('lib64', 'python')
        ]:
            sys.path.append(os.path.join(glite_path, dn))

        try:  # gLite 3.2
            import wmsui_api
            glite_state_name_list = wmsui_api.states_names

            def _get_status_direct(wms_id):
                try:  # new parameter json
                    job_status = wmsui_api.getStatus(
                        wmsui_api.getJobIdfromList(None, [wms_id])[0], 0)
                except Exception:
                    clear_current_exception()
                    job_status = wmsui_api.getStatus(
                        wmsui_api.getJobIdfromList([wms_id])[0], 0)
                return lmap(
                    lambda name: (name.lower(),
                                  job_status.getAttribute(
                                      glite_state_name_list.index(name))),
                    glite_state_name_list)
        except Exception:  # gLite 3.1
            clear_current_exception()
            try:
                from glite_wmsui_LbWrapper import Status
                wrapper_status = Status()
                job_status = __import__('Job').JobStatus(wrapper_status)

                def _get_status_direct(wms_id):
                    wrapper_status.getStatus(wms_id, 0)
                    err, api_msg = wrapper_status.get_error()
                    if err:
                        raise BackendError(api_msg)
                    info = wrapper_status.loadStatus()
                    return lzip(imap(str.lower, job_status.states_names),
                                info[0:job_status.ATTR_MAX])
            except Exception:
                clear_current_exception()
                _get_status_direct = None
        sys.path = stored_sys_path

        check_executor = None
        if _get_status_direct:
            check_executor = GliteWMSDirectCheckJobs(config,
                                                     _get_status_direct)
        GliteWMS.__init__(self, config, name, check_executor=check_executor)
Exemple #5
0
    def __init__(self, config, name):
        glite_path = os.environ.get('GLITE_WMS_LOCATION',
                                    os.environ.get('GLITE_LOCATION', ''))
        stored_sys_path = list(sys.path)
        for p in [
                'lib', 'lib64',
                os.path.join('lib', 'python'),
                os.path.join('lib64', 'python')
        ]:
            sys.path.append(os.path.join(glite_path, p))

        try:  # gLite 3.2
            import wmsui_api
            glStates = wmsui_api.states_names

            def getStatusDirect(wmsID):
                try:  # new parameter json
                    jobStatus = wmsui_api.getStatus(
                        wmsui_api.getJobIdfromList(None, [wmsID])[0], 0)
                except Exception:
                    jobStatus = wmsui_api.getStatus(
                        wmsui_api.getJobIdfromList([wmsID])[0], 0)
                return lmap(
                    lambda name: (name.lower(
                    ), jobStatus.getAttribute(glStates.index(name))), glStates)
        except Exception:  # gLite 3.1
            try:
                from glite_wmsui_LbWrapper import Status
                import Job
                wrStatus = Status()
                jobStatus = Job.JobStatus(wrStatus)

                def getStatusDirect(wmsID):
                    wrStatus.getStatus(wmsID, 0)
                    err, apiMsg = wrStatus.get_error()
                    if err:
                        raise BackendError(apiMsg)
                    info = wrStatus.loadStatus()
                    return lzip(imap(str.lower, jobStatus.states_names),
                                info[0:jobStatus.ATTR_MAX])
            except Exception:
                getStatusDirect = None
        sys.path = stored_sys_path

        checkExecutor = None
        if getStatusDirect:
            checkExecutor = GliteWMSDirect_CheckJobs(config, getStatusDirect)
        GliteWMS.__init__(self, config, name, checkExecutor=checkExecutor)
Exemple #6
0
    def checkJobsBulk(self, jobIds, parentIds, errors):
        """
        check a list of provided job parent ids
        """

        if self.attrNumber == 0:
            # raise an exception here? What kind of exception?
            raise

        self.st = 0

        # convert to string
        # lbJobs = wmsui_api.getJobIdfromList ( parentIds )

        for bulkId in parentIds:

            try:

                wrapStatus = Status(bulkId, 0)
                # Check for Errors
                err, apiMsg = wrapStatus.get_error()
                if err:
                    # Print the error and terminate
                    raise Exception(apiMsg)

                # Retrieve the number of status
                statesNumber = wrapStatus.getStatusNumber()

                # Retrieve the list of attributes for each logged event
                for statusNumber in range(statesNumber):

                    # Retrieve the list of attributes for the current event
                    statusAttribute = \
                        wrapStatus.getStatusAttributes(statusNumber)

                    # Check for Errors
                    err, apiMsg = wrapStatus.get_error()
                    if err:
                        # Print the error and terminate
                        raise Exception(apiMsg)

                bulkInfo = statusAttribute

                # how many jobs in the bulk?
                intervals = int(len(bulkInfo) / self.attrNumber)

                # look if the parent is aborted
                if str(bulkInfo[self.status]) == 'Aborted':
                    # warnings.append('Parent Job Failed')
                    forceAborted = True
                else:
                    forceAborted = False

                # loop over retrieved jobs
                for off in range(1, intervals):

                    # adjust list ofset
                    offset = off * self.attrNumber

                    # focus over specific job related info
                    jobInfo = bulkInfo[offset:offset + self.attrNumber]

                    # retrieve scheduler Id
                    jobSchedId = str(jobInfo[self.jobId])

                    # update just loaded jobs
                    #job = None
                    try:
                        job = jobIds[jobSchedId]
                    except:
                        continue

                    # update runningJob
                    self.getJobInfo(jobInfo, job, forceAborted)
                    jobIds[jobSchedId] = job

                self.st = self.st + 1

            except Exception as err:
                errors.append("skipping " + bulkId + " : " + str(err))
    def checkJobsBulk( self, jobIds, parentIds, errors ):
        """
        check a list of provided job parent ids
        """

        if self.attrNumber == 0 :
            # raise an exception here? What kind of exception?
            raise

        self.st = 0

        # convert to string
        # lbJobs = wmsui_api.getJobIdfromList ( parentIds )

        for bulkId in parentIds:

            try:

                wrapStatus = Status(bulkId, 0)
                # Check for Errors
                err , apiMsg = wrapStatus.get_error ()
                if err:
                    # Print the error and terminate
                    raise Exception(apiMsg)

                # Retrieve the number of status
                statesNumber = wrapStatus.getStatusNumber()

                # Retrieve the list of attributes for each logged event
                for statusNumber in range(statesNumber):

                    # Retrieve the list of attributes for the current event
                    statusAttribute = \
                        wrapStatus.getStatusAttributes(statusNumber)

                    # Check for Errors
                    err , apiMsg = wrapStatus.get_error ()
                    if err:
                        # Print the error and terminate
                        raise Exception(apiMsg)

                bulkInfo = statusAttribute

                # how many jobs in the bulk?
                intervals = int ( len(bulkInfo) / self.attrNumber )

                # look if the parent is aborted
                if str(bulkInfo[self.status]) == 'Aborted' :
                    # warnings.append('Parent Job Failed')
                    forceAborted = True
                else :
                    forceAborted = False

                # loop over retrieved jobs
                for off in range ( 1, intervals ):

                    # adjust list ofset
                    offset = off * self.attrNumber

                    # focus over specific job related info
                    jobInfo = bulkInfo[ offset : offset + self.attrNumber ]

                    # retrieve scheduler Id
                    jobSchedId = str(jobInfo[self.jobId])

                    # update just loaded jobs
                    #job = None
                    try:
                        job = jobIds[jobSchedId]
                    except :
                        continue

                    # update runningJob
                    self.getJobInfo( jobInfo, job, forceAborted)
                    jobIds[jobSchedId] = job


                self.st = self.st + 1

            except Exception as err :
                errors.append("skipping " + bulkId + " : " +  str(err))
try:  # gLite 3.2
    import wmsui_api
    glStates = wmsui_api.states_names

    def getStatusDirect(wmsId):
        jobStatusDirect = wmsui_api.getStatusDirect(
            wmsui_api.getJobIdfromList([wmsId])[0], 0)
        return lmap(
            lambda name:
            (name.lower(), jobStatusDirect.getAttribute(glStates.index(name))),
            glStates)
except Exception:  # gLite 3.1
    try:
        from glite_wmsui_LbWrapper import Status
        import Job
        wrStatus = Status()
        jobStatus = Job.JobStatus(wrStatus)

        def getStatusDirect(wmsId):
            wrStatus.getStatusDirect(wmsId, 0)
            err, apiMsg = wrStatus.get_error()
            if err:
                raise BackendError(apiMsg)
            info = wrStatus.loadStatus()
            return lzip(imap(str.lower, jobStatus.states_names),
                        info[0:jobStatus.ATTR_MAX])
    except Exception:
        getStatusDirect = None


class GliteWMSDirect(GliteWMS):