Aqui está um script mínimo baseado em fence_cisco_ucs
. Eu não sei porque o campo de senha é obrigatório, e não tenho idéia do que o get_list
deve fazer.
Por exemplo, ./script.py -o status -p x -s y
fornece "Status: ON". Se a funcionalidade em get_power_status
e set_power_status
for modificada de acordo, esse script pode realmente ser útil.
#!/usr/bin/python
import sys, re
sys.path.append("/usr/share/fence")
from fencing import *
def get_power_status(conn, options):
someoption = options["--someoption"]
#status = send_command(someoption)
status = "on"
return status
def set_power_status(conn, options):
action = options["--action"]
if action == "on":
onoff = "1"
else:
onoff = "0"
#send_command(onoff)
return
def get_list(conn, options):
outlets = { }
return outlets
def define_new_opts():
all_opt["someoption"] = {
"getopt" : "s:",
"longopt" : "someoption",
"help" : "--someoption=[string] Some option.",
"required" : "1",
"shortdesc" : "Some option.",
"order" : 1 }
def main():
device_opt = [ "passwd", "someoption" ]
atexit.register(atexit_handler)
define_new_opts()
options = check_input(device_opt, process_input(device_opt))
docs = { }
docs["shortdesc"] = "Short Description"
docs["longdesc"] = "Longer Description"
docs["vendorurl"] = "http://somewhere"
show_docs(options, docs)
## Do the delay of the fence device before logging in
## Delay is important for two-node clusters fencing but we do not need to delay 'status' operations
if options["--action"] in ["off", "reboot"]:
time.sleep(int(options["--delay"]))
result = fence_action(None, options, set_power_status, get_power_status, get_list)
sys.exit(result)
if __name__ == "__main__":
main()