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;
Beispiel #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
Beispiel #4
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
Beispiel #5
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
Beispiel #7
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)
Beispiel #8
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
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
Beispiel #10
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
Beispiel #11
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
Beispiel #12
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))