我正在使用 Centos 7 安装一个简单的 Corosync/pacemaker/drbd 高可用性集群,并希望使用自定义硬件(使用 USB 连接的电源开关)提供隔离/STONITH。因此,我需要将这些设备作为 STONITH 资源添加到我的集群中。有没有一个简单的虚拟脚本可以让我开始使用?我在 中找到了几个文件/usr/sbin/fence_*
,但这些文件似乎通过某种网络连接并且只接受预配置的选项。
答案1
这是基于的最小脚本fence_cisco_ucs
。我不知道为什么密码字段是必填的,也不知道它get_list
应该做什么。
例如,给出“状态:开启”。如果和./script.py -o status -p x -s y
中的功能得到相应修改,这个脚本实际上可能会有用。get_power_status
set_power_status
#!/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()