|
| 1 | +from pythonlsf import lsf |
| 2 | + |
| 3 | +def printLimitItem(name, item): |
| 4 | + print(name+' :') |
| 5 | + print(' consumerC : {}'.format(item.consumerC)) |
| 6 | + consumers = lsf.limitConsumerArray_frompointer(item.consumerV) |
| 7 | + for j in range (item.consumerC) : |
| 8 | + print(' [{}] type : {}'.format(j, consumers[j].type)) |
| 9 | + print(' [{}] name : {}'.format(j, consumers[j].name)) |
| 10 | + print(' resourceC : {}'.format(item.resourceC)) |
| 11 | + resources = lsf.limitResourceArray_frompointer(item.resourceV) |
| 12 | + for j in range (item.resourceC) : |
| 13 | + print(' [{}] name : {}'.format(j, resources[j].name)) |
| 14 | + print(' [{}] type : {}'.format(j, resources[j].type)) |
| 15 | + print(' [{}] val : {}'.format(j, resources[j].val)) |
| 16 | + |
| 17 | + return 0 |
| 18 | + |
| 19 | +def printLimit(): |
| 20 | + if lsf.lsb_init("test") > 0: |
| 21 | + return -1; |
| 22 | + |
| 23 | + req = lsf.limitInfoReq() |
| 24 | + req.name = " "; |
| 25 | + pp_ents = lsf.calloc_limitInfoEntPtrPtr() |
| 26 | + intp_size = lsf.copy_intp(0) |
| 27 | + lsinfo = lsf.lsInfo() |
| 28 | + |
| 29 | + rc = lsf.lsb_limitInfo(req, pp_ents, intp_size, lsinfo) |
| 30 | + if rc == -1 : |
| 31 | + print('call lsf failed') |
| 32 | + return -1; |
| 33 | + |
| 34 | + ents = lsf.limitInfoEntPtrPtr_value(pp_ents) |
| 35 | + size = lsf.intp_value(intp_size) |
| 36 | + |
| 37 | + print("{} limits in the cluster.".format(size)) |
| 38 | + |
| 39 | + for i in range(size) : |
| 40 | + ent = lsf.limitInfoEntArray_getitem(ents, i) |
| 41 | + # print limit name |
| 42 | + print('Limit No.{} : {}'.format(i, ent.name)) |
| 43 | + |
| 44 | + # print confInfo in the limit |
| 45 | + printLimitItem('confInfo', ent.confInfo) |
| 46 | + |
| 47 | + # print usageC in the limit |
| 48 | + print('usageC : {}'.format(ent.usageC)) |
| 49 | + # print usageInfo in the limit |
| 50 | + all_usageInfo = lsf.limitItemArray_frompointer(ent.usageInfo) |
| 51 | + for j in range (ent.usageC) : |
| 52 | + printLimitItem('usageInfo', all_usageInfo[j]) |
| 53 | + |
| 54 | + # print ineligible in the limit |
| 55 | + print('ineligible : {}\n\n'.format(ent.ineligible)) |
| 56 | + |
| 57 | + return 0 |
| 58 | + |
| 59 | +if __name__ == '__main__': |
| 60 | + print("LSF Clustername is : {}".format(lsf.ls_getclustername())) |
| 61 | + printLimit() |
| 62 | + |
0 commit comments