Esempio n. 1
0
def query_queue(queue_name):
    """
    "query queue info"
    """

    if lsf.lsb_init("test") > 0:
        return -1;

    intp_num_queues = lsf.new_intp();
    lsf.intp_assign(intp_num_queues, 1);
    strArr = lsf.new_stringArray(1);
    #print lsf.intp_value(intp_num_queues);
    lsf.stringArray_setitem(strArr, 0, queue_name);
    #print lsf.stringArray_getitem(strArr, 0);
    queueInfo = lsf.lsb_queueinfo(strArr,intp_num_queues,None,None,0);
    if queueInfo != None:
        print 'queueInfo is not null';
    else:
        print 'queueInfo is null'
        return -1;

    print 'queue name = %s' % queueInfo.queue;
    print 'queue description = %s' % queueInfo.description; 

    return 0;
Esempio n. 2
0
def read_eventrec(path):
    """
    read lsb.streams
    """

    if lsf.lsb_init("test") > 0:
        exit(1)

    s = lsf.lsbStream()
    s.streamFile = path
    s.maxStreamSize = 1024 * 1024 * 1024
    s.maxStreamFileNum = 10

    cc = lsf.lsb_openstream(s)
    if cc < 0:
        print("Cannot open the file %s. Ensure you are the file owner." %
              (path))
        exit(1)

    lineNum = lsf.new_intp()
    lsf.intp_assign(lineNum, 0)
    flag = 1

    while flag > 0:
        log = lsf.lsb_readstream(lineNum)
        if log:
            display(log)
        else:
            flag = 0

    lsf.lsb_closestream(path)
def read_eventrec(path):
    """
    read lsb.streams
    """

    if lsf.lsb_init("test") > 0:
        exit(1)

    s = lsf.lsbStream()
    s.streamFile = path;
    s.maxStreamSize = 1024*1024*1024
    s.maxStreamFileNum = 10;

    cc = lsf.lsb_openstream(s)
    if cc < 0 :
        print("Cannot open the file %s. Ensure you are the file owner." % (path))
        exit(1);

    lineNum = lsf.new_intp()
    lsf.intp_assign(lineNum, 0)
    flag = 1

    while flag > 0:
        log = lsf.lsb_readstream(lineNum)
        if log:
            display(log)
        else:
            flag = 0
Esempio n. 4
0
def read_all_jobs(count):
    jobs = []
    more = lsf.new_intp()
    while count > 0:
        jobp = lsf.lsb_readjobinfo(more)
        #create a copy of data
        job = JobInfo(jobp)
        jobs.append(job)
        count = lsf.intp_value(more)
    lsf.delete_intp(more)
    return jobs
Esempio n. 5
0
def read_all_jobs(count):
    jobs = []
    more = lsf.new_intp()
    while count > 0:
        jobp = lsf.lsb_readjobinfo(more)
        #create a copy of data
        job = JobInfo(jobp)
        jobs.append(job)
        #print job
        count = lsf.intp_value(more)
    lsf.delete_intp(more)
    return jobs
Esempio n. 6
0
def printAppInfo():
    if lsf.lsb_init("test") > 0:
        return -1

    intp_nent = lsf.new_intp()
    ents = lsf.lsb_appInfo(intp_nent)
    nent = lsf.intp_value(intp_nent)

    print("{} apps in the cluster.".format(nent))

    for i in range(nent):
        ent = lsf.appInfoEntArray_getitem(ents, i)
        print('No.{} app name : {}, description: {}'.format(
            i, ent.name, ent.description))

    return 0
Esempio n. 7
0
def printHostInfo():
    if lsf.lsb_init("test") > 0:
        return -1

    intp_nhosts = lsf.new_intp()
    lsf.intp_assign(intp_nhosts, 0)
    all_lsload_data = lsf.ls_load_py(None, intp_nhosts, 0, None)
    nhosts = lsf.intp_value(intp_nhosts)

    print("{} hosts in the cluster.".format(nhosts))

    for i in range(nhosts):
        host = all_lsload_data[i]
        print('No.{} host name : {}'.format(i, host.hostName))

    return 0
Esempio n. 8
0
def read_eventrec(path):
    """
    read lsb.events
    """
    lineNum = lsf.new_intp()
    lsf.intp_assign(lineNum, 0)
    fp = lsf.fopen(path, "r")
    flag = 1

    if lsf.lsb_init("test") > 0:
        exit(1)

    while flag > 0:
        log = lsf.lsb_geteventrec(fp, lineNum)
        if log:
            display(log)
        else:
            flag = 0
def read_eventrec(path):
    """
    read lsb.events
    """
    lineNum = lsf.new_intp()
    lsf.intp_assign(lineNum, 0)
    fp = lsf.fopen(path, "r")
    flag = 1

    if lsf.lsb_init("test") > 0:
        exit(1)

    while flag > 0:
        log = lsf.lsb_geteventrec(fp, lineNum)
        if log:
            display(log)
        else:
            flag = 0
Esempio n. 10
0
def query_queue(queue_name):
    """
    c api style
    """

    if lsf.lsb_init("test") != 0:
        exit(1)

    intp_num_queues = lsf.new_intp()
    lsf.intp_assign(intp_num_queues, 1)
    queue_p = lsf.new_stringArray(1)
    lsf.stringArray_setitem(queue_p, 0, queue_name)
    info = lsf.lsb_queueinfo(queue_p, intp_num_queues, None, None, 0)
    if info is not None:
        return info.queue, info.description
    else:
        print 'queueInfo is null'
        exit(1)
Esempio n. 11
0
def printHostInfo():
    if lsf.lsb_init("test") > 0:
        return -1;

    intp_nhosts = lsf.new_intp()
    lsf.intp_assign(intp_nhosts, 0) 
    hostsdata = lsf.ls_load(None, intp_nhosts, 0, None)
    nhosts = lsf.intp_value(intp_nhosts)
    all_lsload_data = lsf.hostLoadArray_frompointer(hostsdata)

    print("{} hosts in the cluster.".format(nhosts))

    for i in range(nhosts) :
        host = all_lsload_data[i]
        hostname = ctypes.cast( host.hostName, ctypes.c_char_p)
        print('No.{} host name : {}'.format(i, hostname.value))

    return 0
Esempio n. 12
0
def get_jobs(job_id=0, job_name=None, user_name=lsf.ALL_USERS, queue_name=None, host_name=None,
             option=lsf.ALL_JOB):
    """
    Standard job_ent query function.
    :param job_id: 
    :param job_name: 
    :param user_name: 
    :param queue_name: 
    :param host_name: 
    :param option: 
    :return: 
    """
    job_cnt = lsf.lsb_openjobinfo(job_id, job_name, user_name, queue_name, host_name, option)
    more = lsf.new_intp()
    job_list = list()
    for _ in xrange(job_cnt):
        job_info = lsf.lsb_readjobinfo(more)
        job_list.append(_convert_job_dict(job_info))
    lsf.delete_intp(more)
    lsf.lsb_closejobinfo()
    return job_list
def read_eventrec(path):
    """
    read lsb.events
    """
    lineNum = lsf.new_intp()
    lsf.intp_assign(lineNum, 0)
    fp = lsf.fopen(path, "r")
    if fp is None:
        print("The file %s does not exist." % path)
        sys.exit(1)

    flag = 1

    if lsf.lsb_init("test") > 0:
        exit(1)

    while flag > 0:
        log = lsf.lsb_geteventrec(fp, lineNum)
        if log:
            display(log)
        else:
            flag = 0
Esempio n. 14
0
def read_eventrec(path):
    """
    read lsb.events
    """
    lineNum = lsf.new_intp()
    lsf.intp_assign(lineNum, 0)
    fp = lsf.fopen(path, "r")
    if fp is None:
        print("The file %s does not exist." % path)
        sys.exit(1)

    flag = 1

    if lsf.lsb_init("test") > 0:
        exit(1)

    while flag > 0:
        log = lsf.lsb_geteventrec(fp, lineNum)
        if log:
            display(log)
        else:
            flag = 0
Esempio n. 15
0
def read_eventrec(path):
    """
    read lsb.streams
    """
    s = lsf.lsbStream()
    s.streamFile = path;
    s.maxStreamSize = 1024*1024*1024
    s.maxStreamFileNum = 10;

    lsf.lsb_openstream(s)

    lineNum = lsf.new_intp()
    lsf.intp_assign(lineNum, 0)
    flag = 1

    if lsf.lsb_init("test") > 0:
        exit(1)

    while flag > 0:
        log = lsf.lsb_readstream(lineNum)
        if log:
            display(log)
        else:
            flag = 0
Esempio n. 16
0
from pythonlsf import lsf
if __name__ == '__main__':
   print("LSF Clustername is : {}".format(lsf.ls_getclustername()))
   if lsf.lsb_init("test") > 0:
       exit -1;
   host_names = None
   num_hosts = lsf.new_intp()
   lsf.intp_assign(num_hosts, 0)
   host_data = lsf.lsb_hostinfo_ex(host_names, num_hosts, "", 4096)
   all_host_data = lsf.hostInfoEntArray_frompointer(host_data)
   for i in range(0, lsf.intp_value(num_hosts)):
     hostname = all_host_data[i].host
     print(hostname)
     gpudata = all_host_data[i].gpuData
     print("ngpus avail_shared_gpus avail_excl_gpus")
     print("   {}              {}              {}". \
                format(gpudata.ngpus, gpudata.avail_shared_ngpus, gpudata.avail_excl_ngpus))