Skip to content

add example for restart local sbd #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2023
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)