fence-agents: master - fence_docker: new fence agent for Docker containers
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=bc817b...
Commit: bc817baa3d02c6c20eb558b30669ff059a283aa5
Parent: 2b80f70df2e225492e96b592ffca690046a9e6f7
Author: Ondrej Mular <omular(a)redhat.com>
AuthorDate: Thu Jun 26 06:38:51 2014 -0400
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Jun 26 16:03:02 2014 +0200
fence_docker: new fence agent for Docker containers
With support for TLS authentication.
---
.gitignore | 1 +
configure.ac | 1 +
fence/agents/docker/Makefile.am | 20 +++++
fence/agents/docker/fence_docker.py | 152 ++++++++++++++++++++++++++++++++++
tests/data/metadata/fence_docker.xml | 129 ++++++++++++++++++++++++++++
5 files changed, 303 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index 75b9aa7..8bcae2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,6 +39,7 @@ fence/agents/bullpap/fence_bullpap
fence/agents/cisco_mds/fence_cisco_mds
fence/agents/cisco_ucs/fence_cisco_ucs
fence/agents/cpint/fence_cpint
+fence/agents/docker/fence_docker
fence/agents/drac/fence_drac
fence/agents/drac5/fence_drac5
fence/agents/eaton_snmp/fence_eaton_snmp
diff --git a/configure.ac b/configure.ac
index b1c8519..3589bfa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -265,6 +265,7 @@ AC_CONFIG_FILES([Makefile
fence/agents/brocade/Makefile
fence/agents/cisco_mds/Makefile
fence/agents/cisco_ucs/Makefile
+ fence/agents/docker/Makefile
fence/agents/drac/Makefile
fence/agents/drac5/Makefile
fence/agents/dummy/Makefile
diff --git a/fence/agents/docker/Makefile.am b/fence/agents/docker/Makefile.am
new file mode 100644
index 0000000..a232902
--- /dev/null
+++ b/fence/agents/docker/Makefile.am
@@ -0,0 +1,20 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+TARGET = fence_docker
+
+SRC = $(TARGET).py
+
+EXTRA_DIST = $(SRC)
+
+sbin_SCRIPTS = $(TARGET)
+
+man_MANS = $(TARGET).8
+
+FENCE_TEST_ARGS = -a test -n 1
+
+include $(top_srcdir)/make/fencebuild.mk
+include $(top_srcdir)/make/fenceman.mk
+include $(top_srcdir)/make/agentpycheck.mk
+
+clean-local: clean-man
+ rm -f $(TARGET)
diff --git a/fence/agents/docker/fence_docker.py b/fence/agents/docker/fence_docker.py
new file mode 100644
index 0000000..7363611
--- /dev/null
+++ b/fence/agents/docker/fence_docker.py
@@ -0,0 +1,152 @@
+#!/usr/bin/python -tt
+
+import atexit
+import sys
+import StringIO
+import logging
+import pycurl
+import json
+
+sys.path.append("@FENCEAGENTSLIBDIR@")
+from fencing import fail_usage, all_opt, fence_action, atexit_handler, check_input, process_input, show_docs, run_delay
+
+#BEGIN_VERSION_GENERATION
+RELEASE_VERSION = ""
+REDHAT_COPYRIGHT = ""
+BUILD_DATE = ""
+#END_VERSION_GENERATION
+
+def get_power_status(conn, options):
+ del conn
+ status = send_cmd(options, "containers/%s/json" % options["--plug"])
+ if status is None:
+ return None
+ return "on" if status["State"]["Running"] else "off"
+
+
+def set_power_status(conn, options):
+ del conn
+ if options["--action"] == "on":
+ send_cmd(options, "containers/%s/start" % options["--plug"], True)
+ else:
+ send_cmd(options, "containers/%s/kill" % options["--plug"], True)
+ return
+
+
+def reboot_cycle(conn, options):
+ del conn
+ send_cmd(options, "containers/%s/restart" % options["--plug"], True)
+ return get_power_status(conn, options)
+
+
+def get_list(conn, options):
+ del conn
+ output = send_cmd(options, "containers/json?all=1")
+ containers = {}
+ for container in output:
+ containers[container["Id"]] = (container["Names"][0], {True:"off", False: "on"}[container["Status"][:4].lower() == "exit"])
+ return containers
+
+
+def send_cmd(options, cmd, post = False):
+ url = "http%s://%s:%s/v1.11/%s" % ("s" if "--ssl" in options else "", options["--ip"], options["--ipport"], cmd)
+ conn = pycurl.Curl()
+ output_buffer = StringIO.StringIO()
+ if logging.getLogger().getEffectiveLevel() < logging.WARNING:
+ conn.setopt(pycurl.VERBOSE, True)
+ conn.setopt(pycurl.HTTPGET, 1)
+ conn.setopt(pycurl.URL, str(url))
+ if post:
+ conn.setopt(pycurl.POST, 1)
+ conn.setopt(pycurl.POSTFIELDSIZE, 0)
+ conn.setopt(pycurl.WRITEFUNCTION, output_buffer.write)
+ conn.setopt(pycurl.TIMEOUT, int(options["--shell-timeout"]))
+ if "--ssl" in options:
+ if not (set(("--tlscert", "--tlskey", "--tlscacert")) <= set(options)):
+ fail_usage("Failed. If --ssl option is used, You have to also \
+specify: --tlscert, --tlskey and --tlscacert")
+ conn.setopt(pycurl.SSL_VERIFYPEER, 1)
+ conn.setopt(pycurl.SSLCERT, options["--tlscert"])
+ conn.setopt(pycurl.SSLKEY, options["--tlskey"])
+ conn.setopt(pycurl.CAINFO, options["--tlscacert"])
+ else:
+ conn.setopt(pycurl.SSL_VERIFYPEER, 0)
+ conn.setopt(pycurl.SSL_VERIFYHOST, 0)
+
+ logging.debug("URL: " + url)
+
+ try:
+ conn.perform()
+ result = output_buffer.getvalue()
+ return_code = conn.getinfo(pycurl.RESPONSE_CODE)
+
+ logging.debug("RESULT [" + str(return_code) + \
+ "]: " + result)
+ conn.close()
+ if return_code == 200:
+ return json.loads(result)
+ except pycurl.error:
+ logging.error("Connection failed")
+ except:
+ logging.error("Cannot parse json")
+ return None
+
+
+def main():
+ atexit.register(atexit_handler)
+
+ all_opt["tlscert"] = {
+ "getopt" : ":",
+ "longopt" : "tlscert",
+ "help" : "--tlscert "
+ "Path to client certificate for TLS authentication",
+ "required" : "0",
+ "shortdesc" : "Path to client certificate (PEM format) \
+for TLS authentication. Required if --ssl option is used.",
+ "order": 2
+ }
+
+ all_opt["tlskey"] = {
+ "getopt" : ":",
+ "longopt" : "tlskey",
+ "help" : "--tlskey "
+ "Path to client key for TLS authentication",
+ "required" : "0",
+ "shortdesc" : "Path to client key (PEM format) for TLS \
+authentication. Required if --ssl option is used.",
+ "order": 2
+ }
+
+ all_opt["tlscacert"] = {
+ "getopt" : ":",
+ "longopt" : "tlscacert",
+ "help" : "--tlscacert "
+ "Path to CA certificate for TLS authentication",
+ "required" : "0",
+ "shortdesc" : "Path to CA certificate (PEM format) for \
+TLS authentication. Required if --ssl option is used.",
+ "order": 2
+ }
+
+ device_opt = ["ipaddr", "no_password", "no_login", "port", "method", "web", "tlscert", "tlskey", "tlscacert", "ssl"]
+
+ options = check_input(device_opt, process_input(device_opt))
+
+ docs = { }
+ docs["shortdesc"] = "Fence agent for Docker"
+ docs["longdesc"] = "fence_docker is I/O fencing agent which \
+can be used with the Docker Engine containers. You can use this \
+fence-agent without any authentication, or you can use TLS authentication \
+(use --ssl option, more info about TLS authentication in docker: \
+http://docs.docker.com/examples/https/)."
+ docs["vendorurl"] = "www.docker.io"
+ show_docs(options, docs)
+
+ run_delay(options)
+
+ result = fence_action(None, options, set_power_status, get_power_status, get_list, reboot_cycle)
+
+ sys.exit(result)
+
+if __name__ == "__main__":
+ main()
diff --git a/tests/data/metadata/fence_docker.xml b/tests/data/metadata/fence_docker.xml
new file mode 100644
index 0000000..bda31d01
--- /dev/null
+++ b/tests/data/metadata/fence_docker.xml
@@ -0,0 +1,129 @@
+<?xml version="1.0" ?>
+<resource-agent name="fence_docker" shortdesc="Fence agent for Docker" >
+<longdesc>fence_docker is I/O fencing agent which can be used with the Docker Engine containers. You can use this fence-agent without any authentication, or you can use TLS authentication (use --ssl option, more info about TLS authentication in docker: http://docs.docker.com/examples/https/).</longdesc>
+<vendor-url>www.docker.io</vendor-url>
+<parameters>
+ <parameter name="ipport" unique="0" required="0">
+ <getopt mixed="-u, --ipport=[port]" />
+ <content type="string" default="80" />
+ <shortdesc lang="en">TCP/UDP port to use for connection with device</shortdesc>
+ </parameter>
+ <parameter name="port" unique="0" required="1">
+ <getopt mixed="-n, --plug=[id]" />
+ <content type="string" />
+ <shortdesc lang="en">Physical plug number, name of virtual machine or UUID</shortdesc>
+ </parameter>
+ <parameter name="inet6_only" unique="0" required="0">
+ <getopt mixed="-6, --inet6-only" />
+ <content type="boolean" />
+ <shortdesc lang="en">Forces agent to use IPv6 addresses only</shortdesc>
+ </parameter>
+ <parameter name="ipaddr" unique="0" required="1">
+ <getopt mixed="-a, --ip=[ip]" />
+ <content type="string" />
+ <shortdesc lang="en">IP Address or Hostname</shortdesc>
+ </parameter>
+ <parameter name="inet4_only" unique="0" required="0">
+ <getopt mixed="-4, --inet4-only" />
+ <content type="boolean" />
+ <shortdesc lang="en">Forces agent to use IPv4 addresses only</shortdesc>
+ </parameter>
+ <parameter name="method" unique="0" required="0">
+ <getopt mixed="-m, --method=[method]" />
+ <content type="select" default="onoff" >
+ <option value="onoff" />
+ <option value="cycle" />
+ </content>
+ <shortdesc lang="en">Method to fence (onoff|cycle)</shortdesc>
+ </parameter>
+ <parameter name="ssl" unique="0" required="0">
+ <getopt mixed="-z, --ssl" />
+ <content type="boolean" />
+ <shortdesc lang="en">SSL connection</shortdesc>
+ </parameter>
+ <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="tlskey" unique="0" required="0">
+ <getopt mixed="--tlskey" />
+ <content type="string" />
+ <shortdesc lang="en">Path to client key (PEM format) for TLS authentication. Required if --ssl option is used.</shortdesc>
+ </parameter>
+ <parameter name="tlscacert" unique="0" required="0">
+ <getopt mixed="--tlscacert" />
+ <content type="string" />
+ <shortdesc lang="en">Path to CA certificate (PEM format) for TLS authentication. Required if --ssl option is used.</shortdesc>
+ </parameter>
+ <parameter name="tlscert" unique="0" required="0">
+ <getopt mixed="--tlscert" />
+ <content type="string" />
+ <shortdesc lang="en">Path to client certificate (PEM format) for TLS authentication. Required if --ssl option is used.</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">
+ <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="separator" unique="0" required="0">
+ <getopt mixed="-C, --separator=[char]" />
+ <content type="string" default="," />
+ <shortdesc lang="en">Separator for CSV created by operation list</shortdesc>
+ </parameter>
+ <parameter name="power_wait" unique="0" required="0">
+ <getopt mixed="--power-wait=[seconds]" />
+ <content type="string" default="0" />
+ <shortdesc lang="en">Wait X seconds after issuing ON/OFF</shortdesc>
+ </parameter>
+ <parameter name="power_timeout" unique="0" required="0">
+ <getopt mixed="--power-timeout=[seconds]" />
+ <content type="string" default="20" />
+ <shortdesc lang="en">Test X seconds for status change after ON/OFF</shortdesc>
+ </parameter>
+ <parameter name="delay" unique="0" required="0">
+ <getopt mixed="--delay=[seconds]" />
+ <content type="string" 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="string" default="5" />
+ <shortdesc lang="en">Wait X seconds for cmd prompt after login</shortdesc>
+ </parameter>
+ <parameter name="shell_timeout" unique="0" required="0">
+ <getopt mixed="--shell-timeout=[seconds]" />
+ <content type="string" 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="string" default="1" />
+ <shortdesc lang="en">Count of attempts to retry power on</shortdesc>
+ </parameter>
+</parameters>
+<actions>
+ <action name="on" automatic="0"/>
+ <action name="off" />
+ <action name="reboot" />
+ <action name="status" />
+ <action name="list" />
+ <action name="monitor" />
+ <action name="metadata" />
+</actions>
+</resource-agent>
9 years, 10 months
fence-agents: master - fencing: Fix problems with options without short getopt
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=2b80f7...
Commit: 2b80f70df2e225492e96b592ffca690046a9e6f7
Parent: d27c5cc8fcf108ee8eb5b434df898ee2137fbaf2
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Jun 26 16:02:24 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Jun 26 16:02:24 2014 +0200
fencing: Fix problems with options without short getopt
---
fence/agents/lib/fencing.py.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 0584b7e..4520ea8 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -559,9 +559,10 @@ def process_input(avail_opt):
getopt_string = ""
longopt_list = []
for k in avail_opt:
- if all_opt.has_key(k):
+ if all_opt.has_key(k) and all_opt[k]["getopt"] != ":":
+ # getopt == ":" means that opt is without short getopt, but has value
getopt_string += all_opt[k]["getopt"]
- else:
+ elif not all_opt.has_key(k):
fail_usage("Parse error: unknown option '"+k+"'")
if all_opt.has_key(k) and all_opt[k].has_key("longopt"):
9 years, 10 months
fence-agents: master - [build] Ensure that we are building in correct directory
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=d27c5c...
Commit: d27c5cc8fcf108ee8eb5b434df898ee2137fbaf2
Parent: 0bf859a69fb8546c29946e985c030d0cc3b8e8f2
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Jun 26 15:32:39 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Jun 26 15:32:39 2014 +0200
[build] Ensure that we are building in correct directory
---
configure.ac | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 4d0aa6a..b1c8519 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,6 +12,7 @@ LT_PREREQ([2.2.6])
LT_INIT
AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_SRCDIR([fence/agents/lib/fencing.py.py])
AC_CONFIG_HEADERS([make/clusterautoconfig.h])
AC_CANONICAL_HOST
9 years, 10 months
fence-agents: master - fencing: Checking status of several slots was done incorectly
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=0bf859...
Commit: 0bf859a69fb8546c29946e985c030d0cc3b8e8f2
Parent: 62d90e3a0827fcdc5be632bdf4103d3c08b39622
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Jun 23 17:10:11 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Jun 23 17:10:11 2014 +0200
fencing: Checking status of several slots was done incorectly
Found-by: Ondrej Mular
---
fence/agents/lib/fencing.py.py | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 5084f24..0584b7e 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -818,11 +818,11 @@ def set_multi_power_fn(tn, options, set_power_fn, get_power_fn, retry_attempts =
set_power_fn(tn, options)
time.sleep(int(options["--power-wait"]))
- for _ in xrange(int(options["--power-timeout"])):
- if get_multi_power_fn(tn, options, get_power_fn) != options["--action"]:
- time.sleep(1)
- else:
- return True
+ for _ in xrange(int(options["--power-timeout"])):
+ if get_multi_power_fn(tn, options, get_power_fn) != options["--action"]:
+ time.sleep(1)
+ else:
+ return True
return False
def show_docs(options, docs=None):
9 years, 10 months
fence-agents: RHEL6 - fencing: Delay should be used also with "disable"
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=a5ce29...
Commit: a5ce29b7dd9b07f0e5038b197a8260a313b7cadd
Parent: b972ec00ea7e50664aa684efa7a2873d98a11c48
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Jun 26 14:23:45 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Jun 26 14:23:45 2014 +0200
fencing: Delay should be used also with "disable"
Previously, delay was used only with off and reboot actions.
Resolves: rhbz#641632
---
fence/agents/lib/fencing.py.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 775b567..eeb0a3f 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -892,7 +892,7 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name: )|(userna
## 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["-o"] in ["off", "reboot"]:
+ if options["-o"] in ["off", "reboot", "disable"]:
time.sleep(int(options["-f"]))
try:
9 years, 10 months
fence-agents: RHEL6 - fence_ilo: Fix issue with "
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=b972ec...
Commit: b972ec00ea7e50664aa684efa7a2873d98a11c48
Parent: 917ed4bc76235d50ce36393817e6119e9065b2ef
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Jun 26 14:22:29 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Thu Jun 26 14:22:29 2014 +0200
fence_ilo: Fix issue with "
Previous patch was not backported correctly, there were additional quotes
Resolves: rhbz#990537
---
fence/agents/ilo/fence_ilo.py | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index 2541729..a50cdee 100644
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -23,8 +23,8 @@ BUILD_DATE="March, 2008"
#END_VERSION_GENERATION
def get_power_status(conn, options):
- conn.send("<LOGIN USER_LOGIN = \"" + quoteattr(options["-l"]) + "\"" + \
- " PASSWORD = \"" + quoteattr(options["-p"]) + "\">\r\n")
+ conn.send("<LOGIN USER_LOGIN = " + quoteattr(options["-l"]) + \
+ " PASSWORD = " + quoteattr(options["-p"]) + ">\r\n")
conn.send("<SERVER_INFO MODE = \"read\"><GET_HOST_POWER_STATUS/>\r\n")
conn.send("</SERVER_INFO></LOGIN>\r\n")
try:
@@ -38,8 +38,8 @@ def get_power_status(conn, options):
return status.lower().strip()
def set_power_status(conn, options):
- conn.send("<LOGIN USER_LOGIN = \"" + quoteattr(options["-l"]) + "\"" + \
- " PASSWORD = \"" + quoteattr(options["-p"]) + "\">\r\n")
+ conn.send("<LOGIN USER_LOGIN = " + quoteattr(options["-l"]) + \
+ " PASSWORD = " + quoteattr(options["-p"]) + ">\r\n")
conn.send("<SERVER_INFO MODE = \"write\">")
if options.has_key("fw_processor") and options["fw_processor"] == "iLO2":
@@ -102,8 +102,8 @@ the iLO card through an XML stream."
else:
conn.send("<RIBCL VERSION=\"1.2\">\r\n")
- conn.send("<LOGIN USER_LOGIN = \"" + quoteattr(options["-l"]) + "\"" + \
- " PASSWORD = \"" + quoteattr(options["-p"]) + "\">\r\n")
+ conn.send("<LOGIN USER_LOGIN = " + quoteattr(options["-l"]) + \
+ " PASSWORD = " + quoteattr(options["-p"]) + ">\r\n")
if options["-r"] >= 2:
conn.send("<RIB_INFO MODE=\"read\"><GET_FW_VERSION />\r\n")
conn.send("</RIB_INFO>\r\n")
9 years, 10 months
fence-agents: RHEL6 - fence_scsi: Possibility for hard reboot when fence_scsi_check fails
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=917ed4...
Commit: 917ed4bc76235d50ce36393817e6119e9065b2ef
Parent: 3d471cad9d71706f938a177661a97fc3eed7237a
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Jun 23 14:07:38 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Jun 23 14:07:38 2014 +0200
fence_scsi: Possibility for hard reboot when fence_scsi_check fails
Resolves: rhbz#1050022
---
fence/agents/scsi/Makefile.am | 7 +++++--
fence/agents/scsi/fence_scsi_check.pl | 4 ++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/fence/agents/scsi/Makefile.am b/fence/agents/scsi/Makefile.am
index 5652bda..32f6549 100644
--- a/fence/agents/scsi/Makefile.am
+++ b/fence/agents/scsi/Makefile.am
@@ -5,11 +5,11 @@ TARGET = fence_scsi
SRC = $(TARGET).pl
EXTRA_DIST = $(SRC) \
- $(TARGET)_check.pl
+ $(TARGET)_check.pl $(TARGET)_check_hardreboot.pl
scsidatadir = $(CLUSTERDATA)
-scsidata_SCRIPTS = $(TARGET)_check.pl
+scsidata_SCRIPTS = $(TARGET)_check.pl $(TARGET)_check_hardreboot.pl
sbin_SCRIPTS = $(TARGET)
@@ -19,3 +19,6 @@ include $(top_srcdir)/make/fencebuild.mk
clean-local:
rm -f $(TARGET)
+
+fence_scsi_check_hardreboot.pl: fence_scsi_check.pl
+ cp fence_scsi_check.pl fence_scsi_check_hardreboot.pl
diff --git a/fence/agents/scsi/fence_scsi_check.pl b/fence/agents/scsi/fence_scsi_check.pl
index 9ecd7a5..a08c416 100644
--- a/fence/agents/scsi/fence_scsi_check.pl
+++ b/fence/agents/scsi/fence_scsi_check.pl
@@ -1,6 +1,7 @@
#!/usr/bin/perl
use POSIX;
+require 'syscall.ph';
################################################################################
@@ -128,6 +129,9 @@ sub dev_read ()
################################################################################
if ($ARGV[0] =~ /^repair$/i) {
+ if ($0 =~ /hardreboot/) {
+ syscall(&SYS_reboot, 0xfee1dead, 672274793, 0x01234567);
+ }
exit ($ARGV[1]);
}
9 years, 10 months
fence-agents: RHEL6 - fence_rsb: Accept new prompt in parsing
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=3d471c...
Commit: 3d471cad9d71706f938a177661a97fc3eed7237a
Parent: 9c38cbf1b3e474b6a8eff80f4b8a719047792855
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Fri Jun 20 15:37:40 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Fri Jun 20 15:37:40 2014 +0200
fence_rsb: Accept new prompt in parsing
Resolves: rhbz#1110428
---
fence/agents/rsb/fence_rsb.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py
index 7ce1906..0353071 100755
--- a/fence/agents/rsb/fence_rsb.py
+++ b/fence/agents/rsb/fence_rsb.py
@@ -34,7 +34,8 @@ def set_power_status(conn, options):
conn.send("2")
conn.log_expect(options, options["-c"], int(options["-Y"]))
conn.send_eol(action)
- conn.log_expect(options, ["want to power off", "'yes' or 'no'"], int(options["-Y"]))
+ conn.log_expect(options, ["want to power " + options["-o"],
+ "yes/no", "'yes' or 'no'"], int(options["-Y"]))
conn.send_eol("yes")
conn.log_expect(options, "any key to continue", int(options["-g"]))
conn.send_eol("")
9 years, 10 months
cluster: RHEL6 - rgmanager: Don't crash if a resource agent does not specify a primary attribute
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=d8825398b6b...
Commit: d8825398b6b75f988b86bec0b5a76aab45f16da5
Parent: 113888ed16483827c9119861e3cccb975bfd523a
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Sun Jun 22 20:54:06 2014 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Sun Jun 22 21:12:51 2014 -0400
rgmanager: Don't crash if a resource agent does not specify a primary attribute
Fix a crash that would occur if an errant resource agent did not specify a
primary attribute.
Resolves: rhbz#1018079
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/daemons/reslist.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/daemons/reslist.c b/rgmanager/src/daemons/reslist.c
index e1695fb..2a50f17 100644
--- a/rgmanager/src/daemons/reslist.c
+++ b/rgmanager/src/daemons/reslist.c
@@ -260,6 +260,9 @@ find_resource_by_ref(resource_t **reslist, const char *type, const char *ref)
resource_t *first_possible = NULL;
int x, flags = RA_UNIQUE|RA_REQUIRED;
+ if (!ref)
+ return NULL;
+
list_do(reslist, curr) {
if (strcmp(curr->r_rule->rr_type, type))
continue;
9 years, 10 months
cluster: RHEL6 - rgmanager: clusvcadm: If service doesn't exist, try again as VM
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=113888ed164...
Commit: 113888ed16483827c9119861e3cccb975bfd523a
Parent: 6fbf7b593dbd48245fee4411935abb03ba063183
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Sun Jun 22 20:42:12 2014 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Sun Jun 22 21:12:48 2014 -0400
rgmanager: clusvcadm: If service doesn't exist, try again as VM
Currently clusvcadm requires that be specified as 'vm:name'. This
patch causes clusvcadm to retry with "vm:<name>" when an operation
returns no such service on <name>.
Resolves: rhbz#952729
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/utils/clusvcadm.c | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/rgmanager/src/utils/clusvcadm.c b/rgmanager/src/utils/clusvcadm.c
index 8d0b502..ec0d5b8 100644
--- a/rgmanager/src/utils/clusvcadm.c
+++ b/rgmanager/src/utils/clusvcadm.c
@@ -225,7 +225,7 @@ int
main(int argc, char **argv)
{
extern char *optarg;
- char *svcname=NULL, nodename[256], realsvcname[64];
+ char *svcname=NULL, nodename[256], realsvcname[64], *origname=NULL;
int opt;
msgctx_t ctx;
cman_handle_t ch;
@@ -341,6 +341,7 @@ main(int argc, char **argv)
return 1;
}
+ origname = svcname;
if (!strchr(svcname,':')) {
snprintf(realsvcname, sizeof(realsvcname), "service:%s",
svcname);
@@ -383,8 +384,6 @@ main(int argc, char **argv)
//strcpy(nodename,"me");
}
- build_message(&msg, action, svcname, svctarget, fod, 0);
-
if (action != RG_RELOCATE && action != RG_MIGRATE) {
if (!node_specified)
printf("Local machine %s %s", actionstr, svcname);
@@ -392,10 +391,6 @@ main(int argc, char **argv)
printf("Member %s %s %s", nodename, actionstr, svcname);
printf("...");
fflush(stdout);
- if (msg_open(MSG_SOCKET, 0, RG_PORT, &ctx, 5) < 0) {
- printf("Could not connect to resource group manager\n");
- return 1;
- }
} else {
if (!svctarget)
printf("Trying to %s %s", actionstr, svcname);
@@ -404,10 +399,14 @@ main(int argc, char **argv)
nodename);
printf("...");
fflush(stdout);
- if (msg_open(MSG_SOCKET, 0, RG_PORT, &ctx, 5) < 0) {
- printf("Could not connect to resource group manager\n");
- return 1;
- }
+ }
+
+again:
+ build_message(&msg, action, svcname, svctarget, fod, 0);
+
+ if (msg_open(MSG_SOCKET, 0, RG_PORT, &ctx, 5) < 0) {
+ printf("Could not connect to resource group manager\n");
+ return 1;
}
if (ctx.type < 0) {
@@ -438,9 +437,19 @@ main(int argc, char **argv)
}
swab_SmMessageSt(&msg);
- printf("%s\n", rg_strerror(msg.sm_data.d_ret));
- if (msg.sm_data.d_ret == RG_ERUN)
+ if (msg.sm_data.d_ret == RG_ERUN) {
+ printf("%s\n", rg_strerror(msg.sm_data.d_ret));
return 0;
+ }
+
+ if (msg.sm_data.d_ret == RG_ENOSERVICE && strcmp(origname, svcname)) {
+ snprintf(realsvcname, sizeof(realsvcname), "vm:%s", origname);
+ svcname = realsvcname;
+ origname = svcname;
+ goto again;
+ }
+
+ printf("%s\n", rg_strerror(msg.sm_data.d_ret));
if (msg.sm_data.d_ret)
return msg.sm_data.d_ret;
9 years, 10 months