Skip to content

Commit 65fe2f9

Browse files
authored
Merge pull request #45 from liyancn/master
support 2nd parameter for lsb_guaranteedResourcePoolInfo
2 parents 15b9043 + ba934be commit 65fe2f9

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+

pythonlsf/lsf.i

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ int fclose(FILE *f);
3232
%pointer_functions(long, longp)
3333
%pointer_functions(LS_LONG_INT, LS_LONG_INT_POINTER)
3434
%pointer_functions(limitInfoEnt *, limitInfoEntPtrPtr)
35+
%pointer_functions(guaranteedResourcePoolEnt *, guaranteedResourcePoolEntPtrPtr)
3536

3637
%allocators(limitInfoEnt *, limitInfoEntPtrPtr);
38+
%allocators(guaranteedResourcePoolEnt *, guaranteedResourcePoolEntPtrPtr);
3739

3840
%array_functions(int, intArray)
3941
%array_functions(float, floatArray)
@@ -47,6 +49,7 @@ int fclose(FILE *f);
4749
%array_functions(struct gpuRusage, gpuRusageArray)
4850
#endif
4951
%array_functions(LS_LONG_INT, LS_LONG_INTArray)
52+
%array_functions(guaranteedResourcePoolEnt, guaranteedResourcePoolEntArray)
5053

5154
//helper function for transforming char** to python list
5255
%inline %{
@@ -708,5 +711,5 @@ PyObject * get_pids_from_stream(struct jRusage * jrusage) {
708711
}
709712
return result;
710713
}
711-
714+
712715
%}

0 commit comments

Comments
 (0)