Skip to content

Commit 21adf75

Browse files
authored
Merge pull request #62 from liyancn/master
add example for restarting RES daemons on specified 1 or multiple hosts
2 parents 9859460 + a392c83 commit 21adf75

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

examples/restartRES.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import sys,socket
2+
from pythonlsf import lsf
3+
4+
def restartres(hostlist):
5+
if lsf.ls_initdebug("resrestart") < 0:
6+
print("ls_initdebug failed!")
7+
return -1
8+
num_port = len(hostlist) * 2
9+
if lsf.ls_initrex(num_port, 0) < num_port :
10+
lsf.ls_perror("ls_initrex")
11+
return -1
12+
for host in hostlist:
13+
rc=lsf.ls_rescontrol(host, lsf.RES_CMD_REBOOT, 0)
14+
15+
if rc < 0:
16+
lsf.ls_perror("lsf.ls_rescontrol")
17+
print("failed restart res on {}".format(host))
18+
else :
19+
print("res on {} restarted".format(host))
20+
return
21+
22+
if __name__ == '__main__':
23+
if len(sys.argv) > 1 :
24+
hostlist = sys.argv[1:]
25+
else :
26+
hostlist = [socket.gethostname()]
27+
restartres(hostlist)
28+

0 commit comments

Comments
 (0)