Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F4638428
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/fence/agents/ilo_ssh/fence_ilo_ssh.py b/fence/agents/ilo_ssh/fence_ilo_ssh.py
index a510b2e6..ad711365 100644
--- a/fence/agents/ilo_ssh/fence_ilo_ssh.py
+++ b/fence/agents/ilo_ssh/fence_ilo_ssh.py
@@ -1,75 +1,74 @@
#!/usr/bin/python -tt
import sys, re
import atexit
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
#BEGIN_VERSION_GENERATION
RELEASE_VERSION=""
REDHAT_COPYRIGHT=""
BUILD_DATE=""
#END_VERSION_GENERATION
def get_power_status(conn, options):
conn.send_eol("show /system1")
re_state = re.compile('EnabledState=(.*)', re.IGNORECASE)
conn.log_expect(re_state, int(options["--shell-timeout"]))
status = conn.match.group(1).lower()
if status.startswith("enabled"):
return "on"
else:
return "off"
def set_power_status(conn, options):
if options["--action"] == "on":
conn.send_eol("start /system1")
else:
conn.send_eol("power off hard")
conn.log_expect(options["--command-prompt"], int(options["--power-timeout"]))
return
def reboot_cycle(conn, options):
conn.send_eol("reset hard /system1")
conn.log_expect(options["--command-prompt"], int(options["--power-timeout"]))
return
def main():
device_opt = ["ipaddr", "login", "passwd", "secure", "cmd_prompt", "method", "telnet"]
atexit.register(atexit_handler)
all_opt["cmd_prompt"]["default"] = ["MP>", "hpiLO->"]
all_opt["power_wait"]["default"] = 5
- all_opt["method"]["default"] = "onoff"
options = check_input(device_opt, process_input(device_opt))
docs = {}
docs["shortdesc"] = "Fence agent for HP iLO over SSH"
docs["longdesc"] = "fence_ilo_ssh is a fence agent that connects to iLO device. It logs into \
device via ssh and reboot a specified outlet. "
docs["vendorurl"] = "http://www.hp.com"
docs["symlink"] = [("fence_ilo3_ssh", "Fence agent for HP iLO3 over SSH"),
("fence_ilo4_ssh", "Fence agent for HP iLO4 over SSH")]
show_docs(options, docs)
options["eol"] = "\r"
conn = fence_login(options)
conn.send_eol("SMCLP")
##
## Fence operations
####
result = fence_action(conn, options, set_power_status, get_power_status, None, reboot_cycle)
fence_logout(conn, "exit")
sys.exit(result)
if __name__ == "__main__":
main()
diff --git a/fence/agents/rcd_serial/fence_rcd_serial.py b/fence/agents/rcd_serial/fence_rcd_serial.py
index 104efb9b..7fd7ea68 100644
--- a/fence/agents/rcd_serial/fence_rcd_serial.py
+++ b/fence/agents/rcd_serial/fence_rcd_serial.py
@@ -1,106 +1,107 @@
#!/usr/bin/python -tt
# Copyright 2015 Infoxchange, Danielle Madeley, Sam McLeod-Jones
# Controls an RCD serial device
# Ported from stonith/rcd_serial.c
# The Following Agent Has Been Tested On:
# CentOS Linux release 7.1.1503
# Resource example:
# primitive stonith_node_1 ocf:rcd_serial_py params port="/dev/ttyS0" time=1000 hostlist=stonith_node_1 stonith-timeout=5s
import sys
import atexit
import os
import struct
import logging
import time
from fcntl import ioctl
from termios import TIOCMBIC, TIOCMBIS, TIOCM_RTS, TIOCM_DTR
from time import sleep
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
#BEGIN_VERSION_GENERATION
RELEASE_VERSION="rcd_serial (serial reset) fence agent"
REDHAT_COPYRIGHT=""
BUILD_DATE="22 Jul 2015"
#END_VERSION_GENERATION
class RCDSerial(object):
"""Control class for serial device"""
def __init__(self, port='/dev/ttyS0'):
self.fd = fd = os.open(port, os.O_RDONLY | os.O_NDELAY)
logging.debug("Opened %s on fd %i", port, fd)
ioctl(fd, TIOCMBIC, struct.pack('I', TIOCM_RTS | TIOCM_DTR))
def close(self):
"""Close the serial device"""
logging.debug("Closing serial device")
ret = os.close(self.fd)
return ret
def toggle_pin(self, pin=TIOCM_DTR, time=1000):
"""Toggle the pin high for the time specified"""
logging.debug("Set pin high")
ioctl(self.fd, TIOCMBIS, struct.pack('I', pin))
sleep(float(time) / 1000.)
logging.debug("Set pin low")
ioctl(self.fd, TIOCMBIC, struct.pack('I', pin))
def reboot_device(conn, options):
conn.toggle_pin(time=options["--power-wait"])
return True
def main():
device_opt = ["serial_port", "no_status", "no_password", "no_login", "method", "no_on", "no_off"]
atexit.register(atexit_handler)
all_opt["serial_port"] = {
"getopt" : ":",
"longopt" : "serial-port",
"help":"--serial-port=[port] Port of the serial device (e.g. /dev/ttyS0)",
"required" : "1",
"shortdesc" : "Port of the serial device",
"default" : "/dev/ttyS0",
"order": 1
}
all_opt["method"]["default"] = "cycle"
all_opt["power_wait"]["default"] = "2"
+ all_opt["method"]["help"] = "-m, --method=[method] Method to fence (onoff|cycle) (Default: cycle)"
options = check_input(device_opt, process_input(device_opt))
docs = {}
docs["shortdesc"] = "rcd_serial fence agent"
docs["longdesc"] = "fence_rcd_serial operates a serial cable that toggles a \
reset of an opposing server using the reset switch on its motherboard. The \
cable itself is simple with no power, network or moving parts. An example of \
the cable is available here: https://smcleod.net/rcd-stonith/ and the circuit \
design is available in the fence-agents src as SVG"
docs["vendorurl"] = "http://www.scl.co.uk/rcd_serial/"
show_docs(options, docs)
if options["--action"] in ["off", "reboot"]:
time.sleep(int(options["--delay"]))
## Operate the fencing device
conn = RCDSerial(port=options["--serial-port"])
result = fence_action(conn, options, None, None, reboot_cycle_fn=reboot_device)
conn.close()
sys.exit(result)
if __name__ == "__main__":
main()
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jul 10, 12:30 AM (53 m, 27 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2009313
Default Alt Text
(5 KB)
Attached To
Mode
rF Fence Agents
Attached
Detach File
Event Timeline
Log In to Comment