I am installing a simple Corosync/pacemaker/drbd high availability cluster using Centos 7 and would like to provide fencing/STONITH using custom hardware (power switches using USB connections). As such, I need to add these devices as STONITH resources in my cluster. Is there a simple dummy script I can start with? I found several files in /usr/sbin/fence_*
, but these seem to connect via some sort of network and only accept pre-configured options.
Asked
Active
Viewed 3,452 times
2

C-Otto
- 334
- 5
- 18
-
`fence_cisco_ucs` defines new arguments in `define_new_opts` using the predefined `all_opt` hash. I guess I can work with that. – C-Otto Sep 08 '14 at 14:06
1 Answers
1
Here's a minimal script based on fence_cisco_ucs
. I do not know why the password field is mandatory, and I have no idea what get_list
is supposed to do.
For example, ./script.py -o status -p x -s y
gives "Status: ON". If the functionality in get_power_status
and set_power_status
is modified accordingly, this script might actually be useful.
#!/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()

C-Otto
- 334
- 5
- 18
-
how did you integrate it into pcs so that it can be referred to in the config and mentioned in `pcs stonith create fence_x`? – André Fernandes Nov 06 '14 at 23:52
-
-
To further detail your answer to my question: integration is done via the fence script's `-o metadata` option. pcs will call `fence_x -o metadata` and expect some XML which describes the arguments and commands that the script will accept. – André Fernandes Nov 07 '14 at 10:11