def endJob(pid, state, jobstat):
    data = {}
    data['node'] = host
    data['siteName'] = site
    data['jobId'] = pid
    data['schedulerID'] = schedid
    data['pilotID'] = os.environ.get('GTAG', tpid)
    data['state'] = state
    data['timestamp'] = utils.timeStamp()
    data['transExitCode'] = jobstat
    data['computingElement'] = qname

    print "== Updating Panda with completion info"
    status, pars, response = utils.toServer(baseURLSSL,'updateJob',data,os.getcwd())
    if status != 0:
        print "Error contacting dispatcher to update job status: return value=%s" % status
    else:
        if jobstat == 0:
            print "==== PandaID %s successful completion reported to dispatcher" % pid
            print "!!FINISHED!!0!!PandaID %s done" % pid
        else:
            print "==== PandaID %s failed completion reported to dispatcher" % pid
            print "!!FAILED!!2999!!PandaID %s done" % pid
    print "==== Directory at job completion:"
    print commands.getoutput('pwd; ls -al')
Пример #2
0
def endJob(pid, state, jobstat):
    """this function is invoked when state is failed 
    """

    data = {}
    data['node'] = host
    data['siteName'] = site
    data['jobId'] = pid
    data['schedulerID'] = schedid
    data['pilotID'] = tpid
    data['state'] = state
    data['timestamp'] = utils.timeStamp()
    data['transExitCode'] = jobstat
    ### Prepare the xml catalog file
    data['xml'] = '' #xmltxt
    print "== Updating Panda with completion info"
    status, pars, response = utils.toServer(baseURLSSL,'updateJob',data,os.getcwd())
    if status != 0:
        print "Error contacting dispatcher to update job status: status=%s" % status
    else:
        if jobstat == 0:
            print "==== PandaID %s successful completion reported to dispatcher" % pid
            print "!!FINISHED!!0!!PandaID %s done" % pid
        else:
            print "==== PandaID %s failed completion reported to dispatcher" % pid
            print "!!FAILED!!2999!!PandaID %s done" % pid
    print "==== Directory at job completion:"
    print commands.getoutput('pwd; ls -al')
Пример #3
0
def getJob():
    """
    Get a job from the Panda dispatcher
    """

    global param
    ## Request job from dispatcher
    print "==== Request Panda job from dispatcher"

    # --mxp-- deprecated
    #    glexec_flag = getqueueparameter('glexec').capitalize()

    data = {
        'siteName':site,
        'node':host,
        'prodSourceLabel':'user', #'test' 
        'computingElement':qname,
        'getProxyKey':0
        }
    
    print data
    maxtries = 3
    ntries = 0
    status = 99
    PandaID = 0
    while status != 0:
        ntries += 1
        if ntries > maxtries: 
            break

        # performs a loop while dispatcher has no job (status==20)
        # or until the maxtime (10 min) passes
        totaltime = 0
        #        while totaltime < 10*60:
        while totaltime < 30:
            print 'trial after %s seconds' %totaltime
            status, param, response = utils.toServer(baseURLSSL,'getJob',data,os.getcwd())
            if status != 20:
                 break
            time.sleep(5)
            totaltime += 5
#        print 'results from getJob: '
#        print '   status = %s' %status
#        print '   param = %s' %param
#        print '   response = %s' %response
        if status == 0:
            print "==== Job retrieved:"
            ## Add VO as a param. Needs to go into schema. $$$
            param['vo'] = 'OSG'
            PandaID = param['PandaID']
#            for p in param:
#                print "   %s=%s" % ( p, param[p] )
        elif status == SC_TimeOut:
            # allow more tries
            print "Sleep for %s" % sleeptime
            time.sleep(sleeptime)
        else:
            break

    return status, PandaID
def updateJob(pid):
    data = {}
    data['node'] = host
    data['siteName'] = site
    data['jobId'] = pid
    data['schedulerID'] = schedid
    data['pilotID'] = os.environ.get('GTAG', tpid)
    data['state'] = 'running'
    data['timestamp'] = utils.timeStamp()

    # update server
    print "== Updating Panda with running state"
    status, pars, response = utils.toServer(baseURLSSL,'updateJob',data,os.getcwd())
    if status != 0:
        print "Error contacting dispatcher to update job status: status=%s" % status
    else:
        print "==== PandaID %s running status reported to dispatcher" % pid
def getJob():
    """
    Get a job from the Panda dispatcher
    """

    global param
    global glexec_flag
    ## Request job from dispatcher
    print "==== Request Panda job from dispatcher"

    # When glexec is True, then it is needed to read 
    # the value of 'credname' and 'myproxy' from the panda server
    # This info is delivered only if getProxyKey is "TRUE"
    # If glexec is needed or not in this site is known
    # thru parameter 'glexec' included in queuedata.txt
    glexec_flag = getqueueparameter('glexec').capitalize()

    data = {
        'siteName':site,
        'node':host,
        'prodSourceLabel':'user', #'test' 
        'computingElement':qname,
        'getProxyKey':glexec_flag,
        }
    
    maxtries = 3
    ntries = 0
    status = 99
    PandaID = 0
    while status != 0:
        ntries += 1
        if ntries > maxtries: 
            break

        # performs a loop while dispatcher has no job (status==20)
        # or until the maxtime (10 min) passes
        totaltime = 0
        while totaltime < 10*60:
            print 'trial after %s seconds' %totaltime
            status, param, response = utils.toServer(baseURLSSL,'getJob',data,os.getcwd())
            if status != 20:
                 break
            time.sleep(60)
            totaltime += 60
        print 'results from getJob: '
        print '   status = %s' %status
        print '   param = %s' %param
        print '   response = %s' %response
        if status == 0:
            print "==== Job retrieved:"
            ## Add VO as a param. Needs to go into schema. $$$
            param['vo'] = 'OSG'
            PandaID = param['PandaID']
            for p in param:
                print "   %s=%s" % ( p, param[p] )
        elif status == SC_TimeOut:
            # allow more tries
            print "Sleep for %s" % sleeptime
            time.sleep(sleeptime)
        else:
            break

    return status, PandaID
Пример #6
0
def getJob():
    """
    Get a job from the Panda dispatcher
    """

    global param
    ## Request job from dispatcher
    print "==== Request Panda job from dispatcher"

    # --mxp-- deprecated
    #    glexec_flag = getqueueparameter('glexec').capitalize()

    data = {
        'siteName': site,
        'node': host,
        'prodSourceLabel': 'user',  #'test' 
        'computingElement': qname,
        'getProxyKey': 0
    }

    print data
    maxtries = 3
    ntries = 0
    status = 99
    PandaID = 0
    while status != 0:
        ntries += 1
        if ntries > maxtries:
            break

        # performs a loop while dispatcher has no job (status==20)
        # or until the maxtime (10 min) passes
        totaltime = 0
        #        while totaltime < 10*60:
        while totaltime < 30:
            print 'trial after %s seconds' % totaltime
            status, param, response = utils.toServer(baseURLSSL, 'getJob',
                                                     data, os.getcwd())
            if status != 20:
                break
            time.sleep(5)
            totaltime += 5
#        print 'results from getJob: '
#        print '   status = %s' %status
#        print '   param = %s' %param
#        print '   response = %s' %response
        if status == 0:
            print "==== Job retrieved:"
            ## Add VO as a param. Needs to go into schema. $$$
            param['vo'] = 'OSG'
            PandaID = param['PandaID']


#            for p in param:
#                print "   %s=%s" % ( p, param[p] )
        elif status == SC_TimeOut:
            # allow more tries
            print "Sleep for %s" % sleeptime
            time.sleep(sleeptime)
        else:
            break

    return status, PandaID