File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ from pythonlsf import lsf
2
+ import sys
3
+
4
+
5
+ def restartSBD (opCode , message , hosts ) :
6
+ if lsf .lsb_init ("test" ) > 0 :
7
+ print ("failed to initialize" )
8
+ return
9
+ req = lsf .hostCtrlReq ()
10
+ req .opCode = opCode
11
+ req .message = message
12
+ if len (hosts ) > 0 :
13
+ for h in hosts :
14
+ print ("restarting sbatchd daemon on host <{}> ..." .format (h ))
15
+ req .host = h
16
+ cc = lsf .lsb_hostcontrol (req )
17
+ if cc == 0 :
18
+ print ("sbatchd daemon restarted successfully." )
19
+ elif cc == - 1 :
20
+ print ("ERROR: sbatchd daemon failed to restart." )
21
+ else :
22
+ print ("ERROR: return {} while trying to restart sbatchd." .format (cc ))
23
+ else :
24
+ print ("restarting sbatchd daemon on local host ..." )
25
+ cc = lsf .lsb_hostcontrol (req )
26
+ if cc == 0 :
27
+ print ("sbatchd daemon restarted successfully." )
28
+ elif cc == - 1 :
29
+ print ("ERROR: sbatchd daemon failed to restart." )
30
+ else :
31
+ print ("ERROR: return {} while trying to restart sbatchd." .format (cc ))
32
+
33
+
34
+ if __name__ == "__main__" :
35
+ opCode = lsf .HOST_REBOOT
36
+ message = "reboot according to python-api"
37
+ if len (sys .argv ) > 1 :
38
+ hosts = sys .argv [1 :]
39
+ else :
40
+ hosts = []
41
+ restartSBD (opCode , message , hosts )
42
+
You can’t perform that action at this time.
0 commit comments