Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/agents/rcd_serial/fence_rcd_serial.py b/agents/rcd_serial/fence_rcd_serial.py
index 4b80f420..2614772f 100644
--- a/agents/rcd_serial/fence_rcd_serial.py
+++ b/agents/rcd_serial/fence_rcd_serial.py
@@ -1,100 +1,100 @@
#!@PYTHON@ -tt
-# Copyright 2015 Infoxchange, Danielle Madeley, Sam McLeod-Jones
+# Copyright 2018 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
+# CentOS Linux release 7.5.1804
# 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 *
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/"
+ docs["vendorurl"] = "https://github.com/sammcj/fence_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()
diff --git a/tests/data/metadata/fence_rcd_serial.xml b/tests/data/metadata/fence_rcd_serial.xml
index 7576f4d0..c22f78de 100644
--- a/tests/data/metadata/fence_rcd_serial.xml
+++ b/tests/data/metadata/fence_rcd_serial.xml
@@ -1,92 +1,92 @@
<?xml version="1.0" ?>
<resource-agent name="fence_rcd_serial" shortdesc="rcd_serial fence agent" >
<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</longdesc>
-<vendor-url>http://www.scl.co.uk/rcd_serial/</vendor-url>
+<vendor-url>https://github.com/sammcj/fence_rcd_serial</vendor-url>
<parameters>
<parameter name="action" unique="0" required="1">
<getopt mixed="-o, --action=[action]" />
<content type="string" default="reboot" />
<shortdesc lang="en">Fencing action</shortdesc>
</parameter>
<parameter name="method" unique="0" required="0">
<getopt mixed="-m, --method=[method]" />
<content type="select" default="cycle" >
<option value="onoff" />
<option value="cycle" />
</content>
<shortdesc lang="en">Method to fence</shortdesc>
</parameter>
<parameter name="serial_port" unique="0" required="1">
<getopt mixed="--serial-port=[port]" />
<content type="string" default="/dev/ttyS0" />
<shortdesc lang="en">Port of the serial device</shortdesc>
</parameter>
<parameter name="quiet" unique="0" required="0">
<getopt mixed="-q, --quiet" />
<content type="boolean" />
<shortdesc lang="en">Disable logging to stderr. Does not affect --verbose or --debug-file or logging to syslog.</shortdesc>
</parameter>
<parameter name="verbose" unique="0" required="0">
<getopt mixed="-v, --verbose" />
<content type="boolean" />
<shortdesc lang="en">Verbose mode</shortdesc>
</parameter>
<parameter name="debug" unique="0" required="0" deprecated="1">
<getopt mixed="-D, --debug-file=[debugfile]" />
<content type="string" />
<shortdesc lang="en">Write debug information to given file</shortdesc>
</parameter>
<parameter name="debug_file" unique="0" required="0" obsoletes="debug">
<getopt mixed="-D, --debug-file=[debugfile]" />
<content type="string" />
<shortdesc lang="en">Write debug information to given file</shortdesc>
</parameter>
<parameter name="version" unique="0" required="0">
<getopt mixed="-V, --version" />
<content type="boolean" />
<shortdesc lang="en">Display version information and exit</shortdesc>
</parameter>
<parameter name="help" unique="0" required="0">
<getopt mixed="-h, --help" />
<content type="boolean" />
<shortdesc lang="en">Display help and exit</shortdesc>
</parameter>
<parameter name="delay" unique="0" required="0">
<getopt mixed="--delay=[seconds]" />
<content type="second" default="0" />
<shortdesc lang="en">Wait X seconds before fencing is started</shortdesc>
</parameter>
<parameter name="login_timeout" unique="0" required="0">
<getopt mixed="--login-timeout=[seconds]" />
<content type="second" default="5" />
<shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
</parameter>
<parameter name="power_timeout" unique="0" required="0">
<getopt mixed="--power-timeout=[seconds]" />
<content type="second" default="20" />
<shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
</parameter>
<parameter name="power_wait" unique="0" required="0">
<getopt mixed="--power-wait=[seconds]" />
<content type="second" default="2" />
<shortdesc lang="en">Wait X seconds after issuing ON/OFF</shortdesc>
</parameter>
<parameter name="shell_timeout" unique="0" required="0">
<getopt mixed="--shell-timeout=[seconds]" />
<content type="second" default="3" />
<shortdesc lang="en">Wait X seconds for cmd prompt after issuing command</shortdesc>
</parameter>
<parameter name="retry_on" unique="0" required="0">
<getopt mixed="--retry-on=[attempts]" />
<content type="integer" default="1" />
<shortdesc lang="en">Count of attempts to retry power on</shortdesc>
</parameter>
</parameters>
<actions>
<action name="reboot" />
<action name="monitor" />
<action name="metadata" />
<action name="manpage" />
<action name="validate-all" />
</actions>
</resource-agent>

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 8, 3:45 PM (18 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1991860
Default Alt Text
(7 KB)

Event Timeline