IBM Support

Example for Python API "lsb_mig"

General Page

A simple python script that migrates a job to "hostA".
from pythonlsf import lsf
def bmig():
    if lsf.lsb_init("script") != 0:
        raise Exception(lsf.lsb_sysmsg())
    submig = lsf.submig()
    submig.jobId = 12345              # job_id
    submig.numAskedHosts = 1
    asked_hosts = lsf.new_stringArray(1)
    lsf.stringArray_setitem(asked_hosts, 0, "hostA")  # target_hostname hostA
    submig.askedHosts = asked_hosts
    submig.acAction = -1              #  initialize
    submig.acActionStr = ""          
    bad_host_idx = lsf.new_intp()
    if lsf.lsb_mig(submig, bad_host_idx) != 0:
        print lsf.lsb_sysmsg() 
        print "fail"
    else:
        print "ok"

bmig()
 
$ bsub -r sleep 1000
Job <12345> is submitted to default queue <testq>.

$ bjobs 12345
JOBID      USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
12345      jxiu    RUN   testq      submit_host hostA       sleep 1000 Jan 16 13:21

$ python ./bmig.py
ok

Then the job is migrated to hostB.
$ bjobs 12345
JOBID      USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
12345      jxiu    RUN   testq      submit_host hostB       sleep 1000 Jan 16 13:21

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSWRJV","label":"IBM Spectrum LSF"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
05 December 2019

UID

ibm10795406