use soft shutdown/reboot in IPMI

This commit is contained in:
frank 2011-07-07 17:05:59 -07:00
parent d0de1a5b94
commit fa0373b6e9

View File

@ -132,7 +132,17 @@ def reboot(args):
print "No hostname"
return 1
o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "status")
if o.ret:
print o.stderr
return 1
if "is on" in o.stdout:
o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "cycle")
else:
o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "reset")
if o.ret:
print o.stderr
return 1
@ -166,14 +176,14 @@ def boot_or_reboot(args):
return 1
if "is on" in o.stdout:
args["action"] = "reset"
return reboot(args)
elif "is off" in o.stdout:
args["action"] = "on"
return power(args)
else:
print "unknown power status:" + o.stdout
return 1
return power(args)
call_table = {"ping":ping, "boot_dev":boot_dev, "reboot":reboot, "power":power, "boot_or_reboot":boot_or_reboot}
def dispatch(args):