Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions examples/restartSBD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from pythonlsf import lsf
import sys


def restartSBD(opCode, message, hosts) :
if lsf.lsb_init("test") > 0:
print("failed to initialize")
return
req = lsf.hostCtrlReq()
req.opCode = opCode
req.message = message
if len(hosts) > 0 :
for h in hosts:
print("restarting sbatchd daemon on host <{}> ...".format(h))
req.host = h
cc = lsf.lsb_hostcontrol(req)
if cc == 0 :
print("sbatchd daemon restarted successfully.")
elif cc == -1 :
print("ERROR: sbatchd daemon failed to restart.")
else :
print("ERROR: return {} while trying to restart sbatchd.".format(cc))
else :
print("restarting sbatchd daemon on local host ...")
cc = lsf.lsb_hostcontrol(req)
if cc == 0 :
print("sbatchd daemon restarted successfully.")
elif cc == -1 :
print("ERROR: sbatchd daemon failed to restart.")
else :
print("ERROR: return {} while trying to restart sbatchd.".format(cc))


if __name__ == "__main__":
opCode = lsf.HOST_REBOOT
message = "reboot according to python-api"
if len(sys.argv) > 1 :
hosts = sys.argv[1:]
else :
hosts = []
restartSBD(opCode, message, hosts)