|
| 1 | +from pythonlsf import lsf |
| 2 | + |
| 3 | +def printGuaranteedResourcePools(): |
| 4 | + if lsf.lsb_init("test") > 0: |
| 5 | + print("Unable to init LSF API") |
| 6 | + return -1; |
| 7 | + |
| 8 | + intp_size = lsf.copy_intp(0) |
| 9 | + req = lsf.guaranteedResourcePoolInfoReq() |
| 10 | + strArr = lsf.new_stringArray(1); |
| 11 | + lsf.stringArray_setitem(strArr, 0, ""); |
| 12 | + req.poolsC = 0 |
| 13 | + req.poolNames = strArr; |
| 14 | + req.queueName = "" |
| 15 | + pp_ents = lsf.calloc_guaranteedResourcePoolEntPtrPtr() |
| 16 | + |
| 17 | + rc = lsf.lsb_guaranteedResourcePoolInfo(req,pp_ents,intp_size) |
| 18 | + |
| 19 | + if rc == -1 : |
| 20 | + print('Call LSF API failed') |
| 21 | + return -1; |
| 22 | + |
| 23 | + ents = lsf.guaranteedResourcePoolEntPtrPtr_value(pp_ents) |
| 24 | + size = lsf.intp_value(intp_size) |
| 25 | + |
| 26 | + print("{} guaranteed resource pools in the cluster.".format(size)) |
| 27 | + |
| 28 | + for i in range(size) : |
| 29 | + ent = lsf.guaranteedResourcePoolEntArray_getitem(ents, i) |
| 30 | + print("Pool name: {}".format(ent.name)) |
| 31 | + print("Resource type: {}".format(ent.type)) |
| 32 | + print("Pool status: {}".format(ent.status)) |
| 33 | + print("Total resources in pool: {}".format(ent.total)) |
| 34 | + print("Free resources in pool: {}".format(ent.free)) |
| 35 | + currentHostList = lsf.char_p_p_to_pylist(ent.currentHosts,ent.currentHostsC) |
| 36 | + print('Current hosts in the resource pool: ' + ' '.join(currentHostList)) |
| 37 | + |
| 38 | + lsf.delete_stringArray(strArr); |
| 39 | + lsf.free_guaranteedResourcePoolEntPtrPtr(pp_ents); |
| 40 | + |
| 41 | + return 0 |
| 42 | + |
| 43 | +if __name__ == '__main__': |
| 44 | + print("LSF Clustername is : {}".format(lsf.ls_getclustername())) |
| 45 | + printGuaranteedResourcePools() |
| 46 | + |
0 commit comments