/usr/sbin/fence_hds_cb is in fence-agents 4.0.22-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | #!/usr/bin/python -tt
#####
##
## The Following Agent Has Been Tested On:
##
## Model Modle/Firmware
## +--------------------+---------------------------+
## (1) Main application CB2000/A0300-E-6617
##
#####
import sys, re
import atexit
sys.path.append("/usr/share/fence")
from fencing import *
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="4.0.22"
BUILD_DATE="(built Sat, 06 Feb 2016 12:34:18 +0100)"
REDHAT_COPYRIGHT="Copyright (C) Red Hat, Inc. 2004-2010 All rights reserved."
#END_VERSION_GENERATION
RE_STATUS_LINE = r"^([0-9]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+).*$"
def get_power_status(conn, options):
#### Maybe should put a conn.log_expect here to make sure
#### we have properly entered into the main menu
conn.sendline("S") # Enter System Command Mode
conn.log_expect("SVP>", int(options["--shell-timeout"]))
conn.sendline("PC") # Enter partition control
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
result = {}
# Status can now be obtained from the output of the PC
# command. Line looks like the following:
# "P Power Condition LID lamp Mode Auto power on"
# "0 On Normal Off Basic Synchronized"
# "1 On Normal Off Basic Synchronized"
for line in conn.before.splitlines():
# populate the relevant fields based on regex
partition = re.search(RE_STATUS_LINE, line)
if partition != None:
# find the blade number defined in args
if partition.group(1) == options["--plug"]:
result = partition.group(2).lower()
# We must make sure we go back to the main menu as the
# status is checked before any fencing operations are
# executed. We could in theory save some time by staying in
# the partition control, but the logic is a little cleaner
# this way.
conn.sendline("Q") # Back to system command mode
conn.log_expect("SVP>", int(options["--shell-timeout"]))
conn.sendline("EX") # Back to system console main menu
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
return result
def set_power_status(conn, options):
action = {
'on' : "P",
'off': "F",
'reboot' : "H",
}[options["--action"]]
conn.sendline("S") # Enter System Command Mode
conn.log_expect("SVP>", int(options["--shell-timeout"]))
conn.sendline("PC") # Enter partition control
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
conn.sendline("P") # Enter power control menu
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
conn.sendline(action) # Execute action from array above
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
conn.sendline(options["--plug"]) # Select blade number from args
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
conn.sendline("Y") # Confirm action
conn.log_expect("Hit enter key.", int(options["--shell-timeout"]))
conn.sendline("") # Press the any key
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
conn.sendline("Q") # Quit back to partition control
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
conn.sendline("Q") # Quit back to system command mode
conn.log_expect("SVP>", int(options["--shell-timeout"]))
conn.sendline("EX") # Quit back to system console menu
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
def get_blades_list(conn, options):
outlets = {}
conn.sendline("S") # Enter System Command Mode
conn.log_expect("SVP>", int(options["--shell-timeout"]))
conn.sendline("PC") # Enter partition control
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
# Status can now be obtained from the output of the PC
# command. Line looks like the following:
# "P Power Condition LID lamp Mode Auto power on"
# "0 On Normal Off Basic Synchronized"
# "1 On Normal Off Basic Synchronized"
for line in conn.before.splitlines():
partition = re.search(RE_STATUS_LINE, line)
if partition != None:
outlets[partition.group(1)] = (partition.group(2), "")
conn.sendline("Q") # Quit back to system command mode
conn.log_expect("SVP>", int(options["--shell-timeout"]))
conn.sendline("EX") # Quit back to system console menu
conn.log_expect(options["--command-prompt"], int(options["--shell-timeout"]))
return outlets
def main():
device_opt = ["ipaddr", "login", "passwd", "cmd_prompt", "secure", \
"port", "missing_as_off", "telnet"]
atexit.register(atexit_handler)
all_opt["power_wait"]["default"] = "5"
all_opt["cmd_prompt"]["default"] = [r"\) :"]
options = check_input(device_opt, process_input(device_opt))
docs = {}
docs["shortdesc"] = "Fence agent for Hitachi Compute Blade systems"
docs["longdesc"] = "fence_hds_cb is an I/O Fencing agent \
which can be used with Hitachi Compute Blades with recent enough firmware that \
includes telnet support."
docs["vendorurl"] = "http://www.hds.com"
show_docs(options, docs)
##
## Operate the fencing device
######
conn = fence_login(options)
result = fence_action(conn, options, set_power_status, get_power_status, get_blades_list)
fence_logout(conn, "X")
sys.exit(result)
if __name__ == "__main__":
main()
|