import resource-agents-4.8.0-13.el9

This commit is contained in:
CentOS Sources 2021-11-04 05:23:14 -04:00 committed by Stepan Oksanichenko
commit 20686d1303
10 changed files with 5727 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
SOURCES/ClusterLabs-resource-agents-e76b7d3a.tar.gz

View File

@ -0,0 +1 @@
b1c1e65d690d94e080319217486f8dcd248b2a2a SOURCES/ClusterLabs-resource-agents-e76b7d3a.tar.gz

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,429 @@
From 6a1e619d46d7ff04b610eb9f6e20ed41ac23b0ab Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 19 Aug 2021 09:37:57 +0200
Subject: [PATCH] tools: add nfsconvert for RHEL-based distros
---
.gitignore | 1 +
configure.ac | 5 +
heartbeat/nfsserver-redhat.sh | 6 +
tools/Makefile.am | 5 +
tools/nfsconvert.in | 324 ++++++++++++++++++++++++++++++++++
5 files changed, 341 insertions(+)
create mode 100644 tools/nfsconvert.in
diff --git a/.gitignore b/.gitignore
index f7277bf04e..ec30a3bb00 100644
--- a/.gitignore
+++ b/.gitignore
@@ -99,6 +99,7 @@ ldirectord/init.d/ldirectord.debian.default
ldirectord/systemd/ldirectord.service
systemd/resource-agents.conf
tools/findif
+tools/nfsconvert
tools/ocf-tester
tools/send_arp
tools/tickle_tcp
diff --git a/configure.ac b/configure.ac
index c125df98f6..058c0f1da7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -787,11 +787,15 @@ case $host_os in
*Linux*|*linux*) sendarp_linux=1;;
esac
+redhat_based=0
+AC_CHECK_FILE(/etc/redhat-release, [redhat_based=1])
+
AC_SUBST(LIBNETLIBS)
AC_SUBST(LIBNETDEFINES)
AM_CONDITIONAL(SENDARP_LINUX, test $sendarp_linux = 1 )
AM_CONDITIONAL(USE_LIBNET, test "x$libnet_version" != "xnone" )
+AM_CONDITIONAL(NFSCONVERT, test $redhat_based = 1 )
dnl ************************************************************************
dnl * Check for netinet/icmp6.h to enable the IPv6addr resource agent
@@ -932,6 +936,7 @@ heartbeat/Makefile \
systemd/Makefile \
systemd/resource-agents.conf \
tools/Makefile \
+ tools/nfsconvert \
tools/ocf-tester \
tools/ocft/Makefile \
tools/ocft/ocft \
diff --git a/heartbeat/nfsserver-redhat.sh b/heartbeat/nfsserver-redhat.sh
index 73a70c186c..aec0966050 100644
--- a/heartbeat/nfsserver-redhat.sh
+++ b/heartbeat/nfsserver-redhat.sh
@@ -1,6 +1,7 @@
NFS_SYSCONFIG="/etc/sysconfig/nfs"
NFS_SYSCONFIG_LOCAL_BACKUP="/etc/sysconfig/nfs.ha.bu"
NFS_SYSCONFIG_AUTOGEN_TAG="AUTOGENERATED by $0 high availability resource-agent"
+NFSCONVERT="$HA_BIN/nfsconvert"
nfsserver_redhat_meta_data() {
cat<<EOF
@@ -168,4 +169,9 @@ set_env_args()
fi
fi
rm -f $tmpconfig
+
+ if [ -e "$NFSCONVERT" ]; then
+ ocf_log debug "Running $NFSCONVERT"
+ $NFSCONVERT
+ fi
}
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 83ff43651d..1309223b48 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -31,6 +31,7 @@ sbin_PROGRAMS =
sbin_PROGRAMS =
sbin_SCRIPTS = ocf-tester
halib_PROGRAMS = findif
+halib_SCRIPTS =
man8_MANS = ocf-tester.8
@@ -52,6 +53,10 @@ halib_PROGRAMS += send_arp
send_arp_SOURCES = send_arp.linux.c
endif
+if NFSCONVERT
+halib_SCRIPTS += nfsconvert
+endif
+
endif
sfex_daemon_SOURCES = sfex_daemon.c sfex.h sfex_lib.c sfex_lib.h
diff --git a/tools/nfsconvert.in b/tools/nfsconvert.in
new file mode 100644
index 0000000000..c58a16a4e6
--- /dev/null
+++ b/tools/nfsconvert.in
@@ -0,0 +1,324 @@
+#!@PYTHON@ -tt
+"""
+Read in the deprecated /etc/sysconfig/nfs file and
+set the corresponding values in nfs.conf
+"""
+
+from __future__ import print_function
+import os
+import sys
+import getopt
+import subprocess
+import configparser
+
+CONF_NFS = '/etc/nfs.conf'
+CONF_IDMAP = '/etc/idmapd.conf'
+SYSCONF_NFS = '/etc/sysconfig/nfs'
+SYSCONF_BACKUP = ".rpmsave"
+CONF_TOOL = '/usr/sbin/nfsconf'
+
+# options for nfsd found in RPCNFSDARGS
+OPTS_NFSD = 'dH:p:rR:N:V:stTuUG:L:'
+LONG_NFSD = ['debug', 'host=', 'port=', 'rdma=', 'nfs-version=', 'no-nfs-version=',
+ 'tcp', 'no-tcp', 'udp', 'no-udp', 'grace-time=', 'lease-time=']
+CONV_NFSD = {'-d': (CONF_NFS, 'nfsd', 'debug', 'all'),
+ '-H': (CONF_NFS, 'nfsd', 'host', ','),
+ '-p': (CONF_NFS, 'nfsd', 'port', '$1'),
+ '-r': (CONF_NFS, 'nfsd', 'rdma', 'nfsrdma'),
+ '-R': (CONF_NFS, 'nfsd', 'rdma', '$1'),
+ '-N': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
+ '-V': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
+ '-t': (CONF_NFS, 'nfsd', 'tcp', '1'),
+ '-T': (CONF_NFS, 'nfsd', 'tcp', '0'),
+ '-u': (CONF_NFS, 'nfsd', 'udp', '1'),
+ '-U': (CONF_NFS, 'nfsd', 'udp', '0'),
+ '-G': (CONF_NFS, 'nfsd', 'grace-time', '$1'),
+ '-L': (CONF_NFS, 'nfsd', 'lease-time', '$1'),
+ '$1': (CONF_NFS, 'nfsd', 'threads', '$1'),
+ '--debug': (CONF_NFS, 'nfsd', 'debug', 'all'),
+ '--host': (CONF_NFS, 'nfsd', 'host', ','),
+ '--port': (CONF_NFS, 'nfsd', 'port', '$1'),
+ '--rdma': (CONF_NFS, 'nfsd', 'rdma', '$1'),
+ '--no-nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
+ '--nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
+ '--tcp': (CONF_NFS, 'nfsd', 'tcp', '1'),
+ '--no-tcp': (CONF_NFS, 'nfsd', 'tcp', '0'),
+ '--udp': (CONF_NFS, 'nfsd', 'udp', '1'),
+ '--no-udp': (CONF_NFS, 'nfsd', 'udp', '0'),
+ '--grace-time': (CONF_NFS, 'nfsd', 'grace-time', '$1'),
+ '--lease-time': (CONF_NFS, 'nfsd', 'lease-time', '$1'),
+ }
+
+# options for mountd found in RPCMOUNTDOPTS
+OPTS_MOUNTD = 'go:d:H:p:N:nrs:t:V:'
+LONG_MOUNTD = ['descriptors=', 'debug=', 'nfs-version=', 'no-nfs-version=',
+ 'port=', 'no-tcp', 'ha-callout=', 'state-directory-path=',
+ 'num-threads=', 'reverse-lookup', 'manage-gids', 'no-udp']
+
+CONV_MOUNTD = {'-g': (CONF_NFS, 'mountd', 'manage-gids', '1'),
+ '-o': (CONF_NFS, 'mountd', 'descriptors', '$1'),
+ '-d': (CONF_NFS, 'mountd', 'debug', '$1'),
+ '-H': (CONF_NFS, 'mountd', 'ha-callout', '$1'),
+ '-p': (CONF_NFS, 'mountd', 'port', '$1'),
+ '-N': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
+ '-V': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
+ '-n': (CONF_NFS, 'nfsd', 'tcp', '0'),
+ '-s': (CONF_NFS, 'mountd', 'stat-directory-path', '$1'),
+ '-t': (CONF_NFS, 'mountd', 'threads', '$1'),
+ '-r': (CONF_NFS, 'mountd', 'reverse-lookup', '1'),
+ '-u': (CONF_NFS, 'nfsd', 'udp', '0'),
+ '--manage-gids': (CONF_NFS, 'mountd', 'manage-gids', '1'),
+ '--descriptors': (CONF_NFS, 'mountd', 'descriptors', '$1'),
+ '--debug': (CONF_NFS, 'mountd', 'debug', '$1'),
+ '--ha-callout': (CONF_NFS, 'mountd', 'ha-callout', '$1'),
+ '--port': (CONF_NFS, 'mountd', 'port', '$1'),
+ '--nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'y'),
+ '--no-nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'n'),
+ '--no-tcp': (CONF_NFS, 'nfsd', 'tcp', '0'),
+ '--state-directory-path': (CONF_NFS, 'mountd', 'state-directory-path', '$1'),
+ '--num-threads': (CONF_NFS, 'mountd', 'threads', '$1'),
+ '--reverse-lookup': (CONF_NFS, 'mountd', 'reverse-lookup', '1'),
+ '--no-udp': (CONF_NFS, 'nfsd', 'udp', '0'),
+ }
+
+# options for statd found in STATDARG
+OPTS_STATD = 'o:p:T:U:n:P:H:L'
+LONG_STATD = ['outgoing-port=', 'port=', 'name=', 'state-directory-path=',
+ 'ha-callout=', 'nlm-port=', 'nlm-udp-port=', 'no-notify']
+CONV_STATD = {'-o': (CONF_NFS, 'statd', 'outgoing-port', '$1'),
+ '-p': (CONF_NFS, 'statd', 'port', '$1'),
+ '-T': (CONF_NFS, 'lockd', 'port', '$1'),
+ '-U': (CONF_NFS, 'lockd', 'udp-port', '$1'),
+ '-n': (CONF_NFS, 'statd', 'name', '$1'),
+ '-P': (CONF_NFS, 'statd', 'state-directory-path', '$1'),
+ '-H': (CONF_NFS, 'statd', 'ha-callout', '$1'),
+ '-L': (CONF_NFS, 'statd', 'no-notify', '1'),
+ '--outgoing-port': (CONF_NFS, 'statd', 'outgoing-port', '$1'),
+ '--port': (CONF_NFS, 'statd', 'port', '$1'),
+ '--name': (CONF_NFS, 'statd', 'name', '$1'),
+ '--state-directory-path': (CONF_NFS, 'statd', 'state-directory-path', '$1'),
+ '--ha-callout': (CONF_NFS, 'statd', 'ha-callout', '$1'),
+ '--nlm-port': (CONF_NFS, 'lockd', 'port', '$1'),
+ '--nlm-udp-port': (CONF_NFS, 'lockd', 'udp-port', '$1'),
+ '--no-notify': (CONF_NFS, 'statd', 'no-notify', '1'),
+ }
+
+# options for sm-notify found in SMNOTIFYARGS
+OPTS_SMNOTIFY = 'dm:np:v:P:f'
+CONV_SMNOTIFY = {'-d': (CONF_NFS, 'sm-notify', 'debug', 'all'),
+ '-m': (CONF_NFS, 'sm-notify', 'retry-time', '$1'),
+ '-n': (CONF_NFS, 'sm-notify', 'update-state', '1'),
+ '-p': (CONF_NFS, 'sm-notify', 'outgoing-port', '$1'),
+ '-v': (CONF_NFS, 'sm-notify', 'outgoing-addr', '$1'),
+ '-f': (CONF_NFS, 'sm-notify', 'force', '1'),
+ '-P': (CONF_NFS, 'statd', 'state-directory-path', '$1'),
+ }
+
+# options for idmapd found in RPCIDMAPDARGS
+OPTS_IDMAPD = 'vp:CS'
+CONV_IDMAPD = {'-v': (CONF_IDMAP, 'general', 'verbosity', '+'),
+ '-p': (CONF_NFS, 'general', 'pipefs-directory', '$1'),
+ '-C': (CONF_IDMAP, 'general', 'client-only', '1'),
+ '-S': (CONF_IDMAP, 'general', 'server-only', '1'),
+ }
+
+# options for gssd found in RPCGSSDARGS
+OPTS_GSSD = 'Mnvrp:k:d:t:T:R:lD'
+CONV_GSSD = {'-M': (CONF_NFS, 'gssd', 'use-memcache', '1'),
+ '-n': (CONF_NFS, 'gssd', 'root_uses_machine_creds', '0'),
+ '-v': (CONF_NFS, 'gssd', 'verbosity', '+'),
+ '-r': (CONF_NFS, 'gssd', 'rpc-verbosity', '+'),
+ '-p': (CONF_NFS, 'general', 'pipefs-directory', '$1'),
+ '-k': (CONF_NFS, 'gssd', 'keytab-file', '$1'),
+ '-d': (CONF_NFS, 'gssd', 'cred-cache-directory', '$1'),
+ '-t': (CONF_NFS, 'gssd', 'context-timeout', '$1'),
+ '-T': (CONF_NFS, 'gssd', 'rpc-timeout', '$1'),
+ '-R': (CONF_NFS, 'gssd', 'preferred-realm', '$1'),
+ '-l': (CONF_NFS, 'gssd', 'limit-to-legacy-enctypes', '0'),
+ '-D': (CONF_NFS, 'gssd', 'avoid-dns', '0'),
+ }
+
+# options for blkmapd found in BLKMAPDARGS
+OPTS_BLKMAPD = ''
+CONV_BLKMAPD = {}
+
+# meta list of all the getopt lists
+GETOPT_MAPS = [('RPCNFSDARGS', OPTS_NFSD, LONG_NFSD, CONV_NFSD),
+ ('RPCMOUNTDOPTS', OPTS_MOUNTD, LONG_MOUNTD, CONV_MOUNTD),
+ ('STATDARG', OPTS_STATD, LONG_STATD, CONV_STATD),
+ ('STATDARGS', OPTS_STATD, LONG_STATD, CONV_STATD),
+ ('SMNOTIFYARGS', OPTS_SMNOTIFY, [], CONV_SMNOTIFY),
+ ('RPCIDMAPDARGS', OPTS_IDMAPD, [], CONV_IDMAPD),
+ ('RPCGSSDARGS', OPTS_GSSD, [], CONV_GSSD),
+ ('BLKMAPDARGS', OPTS_BLKMAPD, [], CONV_BLKMAPD),
+ ]
+
+# any fixups we need to apply first
+GETOPT_FIXUP = {'RPCNFSDARGS': ('--rdma', '--rdma=nfsrdma'),
+ }
+
+# map for all of the single option values
+VALUE_MAPS = {'LOCKD_TCPPORT': (CONF_NFS, 'lockd', 'port', '$1'),
+ 'LOCKD_UDPPORT': (CONF_NFS, 'lockd', 'udp-port', '$1'),
+ 'RPCNFSDCOUNT': (CONF_NFS, 'nfsd', 'threads', '$1'),
+ 'NFSD_V4_GRACE': (CONF_NFS, 'nfsd', 'grace-time', '$1'),
+ 'NFSD_V4_LEASE': (CONF_NFS, 'nfsd', 'lease-time', '$1'),
+ 'MOUNTD_PORT': (CONF_NFS, 'mountd', 'port', '$1'),
+ 'STATD_PORT': (CONF_NFS, 'statd', 'port', '$1'),
+ 'STATD_OUTGOING_PORT': (CONF_NFS, 'statd', 'outgoing-port', '$1'),
+ 'STATD_HA_CALLOUT': (CONF_NFS, 'statd', 'ha-callout', '$1'),
+ 'GSS_USE_PROXY': (CONF_NFS, 'gssd', 'use-gss-proxy', '$1')
+ }
+
+def eprint(*args, **kwargs):
+ """ Print error to stderr """
+ print(*args, file=sys.stderr, **kwargs)
+
+def makesub(param, value):
+ """ Variable substitution """
+ return param.replace('$1', value)
+
+def set_value(value, entry):
+ """ Set a configuration value by running nfsconf tool"""
+ cfile, section, tag, param = entry
+
+ tag = makesub(tag, value)
+ param = makesub(param, value)
+ if param == '+':
+ param = value
+ if param == ',':
+ param = value
+ args = [CONF_TOOL, "--file", cfile, "--set", section, tag, param]
+
+ try:
+ subprocess.check_output(args, stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ print("Error running nfs-conf tool:\n %s" % (e.output.decode()))
+ print("Args: %s\n" % args)
+ raise Exception
+
+def convert_getopt(optname, options, optstring, longopts, conversions):
+ """ Parse option string into seperate config items
+
+ Take a getopt string and a table of conversions
+ parse it all and spit out the converted config
+
+ Keyword arguments:
+ options -- the argv string to convert
+ optstring -- getopt format option list
+ conversions -- table of translations
+ """
+ optcount = 0
+ try:
+ args = options.strip('\"').split()
+ if optname in GETOPT_FIXUP:
+ (k, v) = GETOPT_FIXUP[optname]
+ for i, opt in enumerate(args):
+ if opt == k:
+ args[i] = v
+ elif opt == '--':
+ break
+ optlist, optargs = getopt.gnu_getopt(args, optstring, longopts=longopts)
+ except getopt.GetoptError as err:
+ eprint(err)
+ raise Exception
+
+ setlist = {}
+ for (k, v) in optlist:
+ if k in conversions:
+ # it's already been set once
+ param = conversions[k][3]
+ tag = k + makesub(conversions[k][2], v)
+ if tag in setlist:
+ value = setlist[tag][0]
+ # is it a cummulative entry
+ if param == '+':
+ value = str(int(value) + 1)
+ if param == ',':
+ value += "," + v
+ else:
+ if param == '+':
+ value = "1"
+ elif param == ',':
+ value = v
+ else:
+ value = v
+ setlist[tag] = (value, conversions[k])
+ else:
+ if v:
+ eprint("Ignoring unrecognised option %s=%s in %s" % (k, v, optname))
+ else:
+ eprint("Ignoring unrecognised option %s in %s" % (k, optname))
+
+
+ for v, c in setlist.values():
+ try:
+ set_value(v, c)
+ optcount += 1
+ except Exception:
+ raise
+
+ i = 1
+ for o in optargs:
+ opname = '$' + str(i)
+ if opname in conversions:
+ try:
+ set_value(o, conversions[opname])
+ optcount += 1
+ except Exception:
+ raise
+ else:
+ eprint("Unrecognised trailing arguments")
+ raise Exception
+ i += 1
+
+ return optcount
+
+def map_values():
+ """ Main function """
+ mapcount = 0
+
+ # Lets load the old config
+ with open(SYSCONF_NFS) as cfile:
+ file_content = '[sysconf]\n' + cfile.read()
+ sysconfig = configparser.RawConfigParser()
+ sysconfig.read_string(file_content)
+
+ # Map all the getopt option lists
+ for (name, opts, lopts, conv) in GETOPT_MAPS:
+ if name in sysconfig['sysconf']:
+ try:
+ mapcount += convert_getopt(name, sysconfig['sysconf'][name], opts,
+ lopts, conv)
+ except Exception:
+ eprint("Error whilst converting %s to nfsconf options." % (name))
+ raise
+
+ # Map the single value options
+ for name, opts in VALUE_MAPS.items():
+ if name in sysconfig['sysconf']:
+ try:
+ value = sysconfig['sysconf'][name]
+ set_value(value.strip('\"'), opts)
+ mapcount += 1
+ except Exception:
+ raise
+
+ # All went well, move aside the old file
+ # but dont bother if there were no changes and
+ # an old config file already exists
+ backupfile = SYSCONF_NFS + SYSCONF_BACKUP
+ if mapcount > 0 or not os.path.exists(backupfile):
+ try:
+ os.replace(SYSCONF_NFS, backupfile)
+ except OSError as err:
+ eprint("Error moving old config %s: %s" % (SYSCONF_NFS, err))
+ raise
+
+# Main routine
+try:
+ map_values()
+except Exception as e:
+ eprint(e)
+ eprint("Conversion failed. Please correct the error and try again.")
+ exit(1)

View File

@ -0,0 +1,22 @@
From 1c037b3ac0288509fb2b74fb4a661a504155da15 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 26 Aug 2021 12:27:50 +0200
Subject: [PATCH] nfsnotify: fix default value for "notify_args"
---
heartbeat/nfsnotify.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/heartbeat/nfsnotify.in b/heartbeat/nfsnotify.in
index 851f6ad6b4..fe6d2793ba 100644
--- a/heartbeat/nfsnotify.in
+++ b/heartbeat/nfsnotify.in
@@ -33,7 +33,7 @@
# Parameter defaults
OCF_RESKEY_source_host_default=""
-OCF_RESKEY_notify_args_default="false"
+OCF_RESKEY_notify_args_default=""
: ${OCF_RESKEY_source_host=${OCF_RESKEY_source_host_default}}
: ${OCF_RESKEY_notify_args=${OCF_RESKEY_notify_args_default}}

View File

@ -0,0 +1,12 @@
diff --color -uNr a/heartbeat/aliyun-vpc-move-ip b/heartbeat/aliyun-vpc-move-ip
--- a/heartbeat/aliyun-vpc-move-ip 2021-08-19 09:37:57.000000000 +0200
+++ b/heartbeat/aliyun-vpc-move-ip 2021-08-25 13:38:26.786626079 +0200
@@ -17,7 +17,7 @@
OCF_RESKEY_interface_default="eth0"
OCF_RESKEY_profile_default="default"
OCF_RESKEY_endpoint_default="vpc.aliyuncs.com"
-OCF_RESKEY_aliyuncli_default="detect"
+OCF_RESKEY_aliyuncli_default="/usr/lib/fence-agents/support/aliyun/bin/aliyuncli"
: ${OCF_RESKEY_address=${OCF_RESKEY_address_default}}

View File

@ -0,0 +1,48 @@
diff --color -uNr a/heartbeat/awseip b/heartbeat/awseip
--- a/heartbeat/awseip 2020-12-03 14:31:17.000000000 +0100
+++ b/heartbeat/awseip 2021-02-15 16:47:36.624610378 +0100
@@ -43,7 +43,7 @@
#
# Defaults
#
-OCF_RESKEY_awscli_default="/usr/bin/aws"
+OCF_RESKEY_awscli_default="/usr/lib/fence-agents/support/aws/bin/aws"
OCF_RESKEY_profile_default="default"
OCF_RESKEY_api_delay_default="3"
diff --color -uNr a/heartbeat/awsvip b/heartbeat/awsvip
--- a/heartbeat/awsvip 2020-12-03 14:31:17.000000000 +0100
+++ b/heartbeat/awsvip 2021-02-15 16:47:48.960632484 +0100
@@ -42,7 +42,7 @@
#
# Defaults
#
-OCF_RESKEY_awscli_default="/usr/bin/aws"
+OCF_RESKEY_awscli_default="/usr/lib/fence-agents/support/aws/bin/aws"
OCF_RESKEY_profile_default="default"
OCF_RESKEY_api_delay_default="3"
diff --color -uNr a/heartbeat/aws-vpc-move-ip b/heartbeat/aws-vpc-move-ip
--- a/heartbeat/aws-vpc-move-ip 2020-12-03 14:31:17.000000000 +0100
+++ b/heartbeat/aws-vpc-move-ip 2021-02-15 16:47:55.484644118 +0100
@@ -35,7 +35,7 @@
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
# Defaults
-OCF_RESKEY_awscli_default="/usr/bin/aws"
+OCF_RESKEY_awscli_default="/usr/lib/fence-agents/support/aws/bin/aws"
OCF_RESKEY_profile_default="default"
OCF_RESKEY_region_default=""
OCF_RESKEY_ip_default=""
diff --color -uNr a/heartbeat/aws-vpc-route53.in b/heartbeat/aws-vpc-route53.in
--- a/heartbeat/aws-vpc-route53.in 2020-12-03 14:31:17.000000000 +0100
+++ b/heartbeat/aws-vpc-route53.in 2021-02-15 16:47:59.808651828 +0100
@@ -45,7 +45,7 @@
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
# Defaults
-OCF_RESKEY_awscli_default="/usr/bin/aws"
+OCF_RESKEY_awscli_default="/usr/lib/fence-agents/support/aws/bin/aws"
OCF_RESKEY_profile_default="default"
OCF_RESKEY_hostedzoneid_default=""
OCF_RESKEY_fullname_default=""

View File

@ -0,0 +1,33 @@
diff --color -uNr a/heartbeat/gcp-pd-move.in b/heartbeat/gcp-pd-move.in
--- a/heartbeat/gcp-pd-move.in 2021-08-19 09:37:57.000000000 +0200
+++ b/heartbeat/gcp-pd-move.in 2021-08-25 13:50:54.461732967 +0200
@@ -32,6 +32,7 @@
from ocf import logger
try:
+ sys.path.insert(0, '/usr/lib/fence-agents/support/google')
import googleapiclient.discovery
except ImportError:
pass
diff --color -uNr a/heartbeat/gcp-vpc-move-route.in b/heartbeat/gcp-vpc-move-route.in
--- a/heartbeat/gcp-vpc-move-route.in 2021-08-19 09:37:57.000000000 +0200
+++ b/heartbeat/gcp-vpc-move-route.in 2021-08-25 13:51:17.489797999 +0200
@@ -45,6 +45,7 @@
from ocf import *
try:
+ sys.path.insert(0, '/usr/lib/fence-agents/support/google')
import googleapiclient.discovery
import pyroute2
try:
diff --color -uNr a/heartbeat/gcp-vpc-move-vip.in b/heartbeat/gcp-vpc-move-vip.in
--- a/heartbeat/gcp-vpc-move-vip.in 2021-08-19 09:37:57.000000000 +0200
+++ b/heartbeat/gcp-vpc-move-vip.in 2021-08-25 13:51:35.012847487 +0200
@@ -29,6 +29,7 @@
from ocf import *
try:
+ sys.path.insert(0, '/usr/lib/fence-agents/support/google')
import googleapiclient.discovery
try:
from google.oauth2.service_account import Credentials as ServiceAccountCredentials

View File

@ -0,0 +1,787 @@
diff --color -uNr a/doc/man/Makefile.am b/doc/man/Makefile.am
--- a/doc/man/Makefile.am 2021-08-25 09:51:53.037906134 +0200
+++ b/doc/man/Makefile.am 2021-08-25 09:48:44.578408475 +0200
@@ -97,6 +97,8 @@
ocf_heartbeat_ManageRAID.7 \
ocf_heartbeat_ManageVE.7 \
ocf_heartbeat_NodeUtilization.7 \
+ ocf_heartbeat_nova-compute-wait.7 \
+ ocf_heartbeat_NovaEvacuate.7 \
ocf_heartbeat_Pure-FTPd.7 \
ocf_heartbeat_Raid1.7 \
ocf_heartbeat_Route.7 \
diff --color -uNr a/heartbeat/Makefile.am b/heartbeat/Makefile.am
--- a/heartbeat/Makefile.am 2021-08-25 09:51:53.038906137 +0200
+++ b/heartbeat/Makefile.am 2021-08-25 09:48:44.588408501 +0200
@@ -29,6 +29,8 @@
ocfdir = $(OCF_RA_DIR_PREFIX)/heartbeat
+ospdir = $(OCF_RA_DIR_PREFIX)/openstack
+
dtddir = $(datadir)/$(PACKAGE_NAME)
dtd_DATA = ra-api-1.dtd metadata.rng
@@ -50,6 +52,9 @@
send_ua_SOURCES = send_ua.c IPv6addr_utils.c
send_ua_LDADD = $(LIBNETLIBS)
+osp_SCRIPTS = nova-compute-wait \
+ NovaEvacuate
+
ocf_SCRIPTS = AoEtarget \
AudibleAlarm \
ClusterMon \
diff --color -uNr a/heartbeat/nova-compute-wait b/heartbeat/nova-compute-wait
--- a/heartbeat/nova-compute-wait 1970-01-01 01:00:00.000000000 +0100
+++ b/heartbeat/nova-compute-wait 2021-08-25 09:50:14.626646141 +0200
@@ -0,0 +1,345 @@
+#!/bin/sh
+#
+#
+# nova-compute-wait agent manages compute daemons.
+#
+# Copyright (c) 2015
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Further, this software is distributed without any warranty that it is
+# free of the rightful claim of any third person regarding infringement
+# or the like. Any license provided herein, whether implied or
+# otherwise, applies only to this software file. Patent licenses, if
+# any, provided herein do not apply to combinations of this program with
+# other software, or any other product whatsoever.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+#
+
+#######################################################################
+# Initialization:
+
+
+###
+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
+. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
+###
+
+: ${__OCF_ACTION=$1}
+
+#######################################################################
+
+meta_data() {
+ cat <<END
+<?xml version="1.0"?>
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
+<resource-agent name="nova-compute-wait" version="1.0">
+<version>1.0</version>
+
+<longdesc lang="en">
+OpenStack Nova Compute Server.
+</longdesc>
+<shortdesc lang="en">OpenStack Nova Compute Server</shortdesc>
+
+<parameters>
+
+<parameter name="auth_url" unique="0" required="1">
+<longdesc lang="en">
+Deprecated option not in use
+</longdesc>
+<shortdesc lang="en">Deprecated</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="username" unique="0" required="1">
+<longdesc lang="en">
+Deprecated option not in use
+</longdesc>
+<shortdesc lang="en">Deprecated</shortdesc>
+</parameter>
+
+<parameter name="password" unique="0" required="1">
+<longdesc lang="en">
+Deprecated option not in use
+</longdesc>
+<shortdesc lang="en">Deprecated</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="tenant_name" unique="0" required="1">
+<longdesc lang="en">
+Deprecated option not in use
+</longdesc>
+<shortdesc lang="en">Deprecated</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="domain" unique="0" required="0">
+<longdesc lang="en">
+DNS domain in which hosts live, useful when the cluster uses short names and nova uses FQDN
+</longdesc>
+<shortdesc lang="en">DNS domain</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="endpoint_type" unique="0" required="0">
+<longdesc lang="en">
+Deprecated option not in use
+</longdesc>
+<shortdesc lang="en">Deprecated</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="no_shared_storage" unique="0" required="0">
+<longdesc lang="en">
+Deprecated option not in use
+</longdesc>
+<shortdesc lang="en">Deprecated</shortdesc>
+<content type="boolean" default="0" />
+</parameter>
+
+<parameter name="evacuation_delay" unique="0" required="0">
+<longdesc lang="en">
+How long to wait for nova to finish evacuating instances elsewhere
+before starting nova-compute. Only used when the agent detects
+evacuations might be in progress.
+
+You may need to increase the start timeout when increasing this value.
+</longdesc>
+<shortdesc lang="en">Delay to allow evacuations time to complete</shortdesc>
+<content type="integer" default="120" />
+</parameter>
+
+</parameters>
+
+<actions>
+<action name="start" timeout="600" />
+<action name="stop" timeout="300" />
+<action name="monitor" timeout="20" interval="10" depth="0"/>
+<action name="validate-all" timeout="20" />
+<action name="meta-data" timeout="5" />
+</actions>
+</resource-agent>
+END
+}
+
+#######################################################################
+
+# don't exit on TERM, to test that lrmd makes sure that we do exit
+trap sigterm_handler TERM
+sigterm_handler() {
+ ocf_log info "They use TERM to bring us down. No such luck."
+ return
+}
+
+nova_usage() {
+ cat <<END
+usage: $0 {start|stop|monitor|validate-all|meta-data}
+
+Expects to have a fully populated OCF RA-compliant environment set.
+END
+}
+
+nova_start() {
+ build_unfence_overlay
+
+ state=$(attrd_updater -p -n evacuate -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
+ if [ "x$state" = x ]; then
+ : never been fenced
+
+ elif [ "x$state" = xno ]; then
+ : has been evacuated, however it could have been 1s ago
+ ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
+ sleep ${OCF_RESKEY_evacuation_delay}
+
+ else
+ while [ "x$state" != "xno" ]; do
+ ocf_log info "Waiting for pending evacuations from ${NOVA_HOST}"
+ state=$(attrd_updater -p -n evacuate -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
+ sleep 5
+ done
+
+ ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
+ sleep ${OCF_RESKEY_evacuation_delay}
+ fi
+
+ touch "$statefile"
+
+ return $OCF_SUCCESS
+}
+
+nova_stop() {
+ rm -f "$statefile"
+ return $OCF_SUCCESS
+}
+
+nova_monitor() {
+ if [ ! -f "$statefile" ]; then
+ return $OCF_NOT_RUNNING
+ fi
+
+ return $OCF_SUCCESS
+}
+
+nova_notify() {
+ return $OCF_SUCCESS
+}
+
+build_unfence_overlay() {
+ fence_options=""
+
+ if [ -z "${OCF_RESKEY_auth_url}" ]; then
+ candidates=$(/usr/sbin/stonith_admin -l ${NOVA_HOST})
+ for candidate in ${candidates}; do
+ pcs stonith show $d | grep -q fence_compute
+ if [ $? = 0 ]; then
+ ocf_log info "Unfencing nova based on: $candidate"
+ fence_auth=$(pcs stonith show $candidate | grep Attributes: | sed -e s/Attributes:// -e s/-/_/g -e 's/[^ ]\+=/OCF_RESKEY_\0/g' -e s/passwd/password/g)
+ eval "export $fence_auth"
+ break
+ fi
+ done
+ fi
+
+ # Copied from NovaEvacuate
+ if [ -z "${OCF_RESKEY_auth_url}" ]; then
+ ocf_exit_reason "auth_url not configured"
+ exit $OCF_ERR_CONFIGURED
+ fi
+
+ fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}"
+
+ if [ -z "${OCF_RESKEY_username}" ]; then
+ ocf_exit_reason "username not configured"
+ exit $OCF_ERR_CONFIGURED
+ fi
+
+ fence_options="${fence_options} -l ${OCF_RESKEY_username}"
+
+ if [ -z "${OCF_RESKEY_password}" ]; then
+ ocf_exit_reason "password not configured"
+ exit $OCF_ERR_CONFIGURED
+ fi
+
+ fence_options="${fence_options} -p ${OCF_RESKEY_password}"
+
+ if [ -z "${OCF_RESKEY_tenant_name}" ]; then
+ ocf_exit_reason "tenant_name not configured"
+ exit $OCF_ERR_CONFIGURED
+ fi
+
+ fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
+
+ if [ -n "${OCF_RESKEY_domain}" ]; then
+ fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
+ fi
+
+ if [ -n "${OCF_RESKEY_region_name}" ]; then
+ fence_options="${fence_options} \
+ --region-name ${OCF_RESKEY_region_name}"
+ fi
+
+ if [ -n "${OCF_RESKEY_insecure}" ]; then
+ if ocf_is_true "${OCF_RESKEY_insecure}"; then
+ fence_options="${fence_options} --insecure"
+ fi
+ fi
+
+ if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
+ if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
+ fence_options="${fence_options} --no-shared-storage"
+ fi
+ fi
+
+ if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
+ case ${OCF_RESKEY_endpoint_type} in
+ adminURL|publicURL|internalURL)
+ ;;
+ *)
+ ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type}" \
+ "not valid. Use adminURL or publicURL or internalURL"
+ exit $OCF_ERR_CONFIGURED
+ ;;
+ esac
+ fence_options="${fence_options} -e ${OCF_RESKEY_endpoint_type}"
+ fi
+
+ mkdir -p /run/systemd/system/openstack-nova-compute.service.d
+ cat<<EOF>/run/systemd/system/openstack-nova-compute.service.d/unfence-20.conf
+[Service]
+ExecStartPost=/sbin/fence_compute ${fence_options} -o on -n ${NOVA_HOST}
+EOF
+}
+
+nova_validate() {
+ rc=$OCF_SUCCESS
+
+ check_binary crudini
+ check_binary nova-compute
+ check_binary fence_compute
+
+ if [ ! -f /etc/nova/nova.conf ]; then
+ ocf_exit_reason "/etc/nova/nova.conf not found"
+ exit $OCF_ERR_CONFIGURED
+ fi
+
+ # Is the state directory writable?
+ state_dir=$(dirname $statefile)
+ touch "$state_dir/$$"
+ if [ $? != 0 ]; then
+ ocf_exit_reason "Invalid state directory: $state_dir"
+ return $OCF_ERR_ARGS
+ fi
+ rm -f "$state_dir/$$"
+
+ NOVA_HOST=$(crudini --get /etc/nova/nova.conf DEFAULT host 2>/dev/null)
+ if [ $? = 1 ]; then
+ short_host=$(uname -n | awk -F. '{print $1}')
+ if [ "x${OCF_RESKEY_domain}" != x ]; then
+ NOVA_HOST=${short_host}.${OCF_RESKEY_domain}
+ else
+ NOVA_HOST=$(uname -n)
+ fi
+ fi
+
+ if [ $rc != $OCF_SUCCESS ]; then
+ exit $rc
+ fi
+ return $rc
+}
+
+statefile="${HA_RSCTMP}/${OCF_RESOURCE_INSTANCE}.active"
+
+: ${OCF_RESKEY_evacuation_delay=120}
+case $__OCF_ACTION in
+meta-data) meta_data
+ exit $OCF_SUCCESS
+ ;;
+usage|help) nova_usage
+ exit $OCF_SUCCESS
+ ;;
+esac
+
+case $__OCF_ACTION in
+start) nova_validate; nova_start;;
+stop) nova_stop;;
+monitor) nova_validate; nova_monitor;;
+notify) nova_notify;;
+validate-all) exit $OCF_SUCCESS;;
+*) nova_usage
+ exit $OCF_ERR_UNIMPLEMENTED
+ ;;
+esac
+rc=$?
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
+exit $rc
+
diff --color -uNr a/heartbeat/NovaEvacuate b/heartbeat/NovaEvacuate
--- a/heartbeat/NovaEvacuate 1970-01-01 01:00:00.000000000 +0100
+++ b/heartbeat/NovaEvacuate 2021-08-25 09:50:23.780670326 +0200
@@ -0,0 +1,400 @@
+#!/bin/bash
+#
+# Copyright 2015 Red Hat, Inc.
+#
+# Description: Manages evacuation of nodes running nova-compute
+#
+# Authors: Andrew Beekhof
+#
+# Support: openstack@lists.openstack.org
+# License: Apache Software License (ASL) 2.0
+#
+
+
+#######################################################################
+# Initialization:
+
+###
+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
+. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
+###
+
+: ${__OCF_ACTION=$1}
+
+#######################################################################
+
+meta_data() {
+ cat <<END
+<?xml version="1.0"?>
+<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
+<resource-agent name="NovaEvacuate" version="1.0">
+<version>1.0</version>
+
+<longdesc lang="en">
+Facility for tacking a list of compute nodes and reliably evacuating the ones that fence_evacuate has flagged.
+</longdesc>
+<shortdesc lang="en">Evacuator for OpenStack Nova Compute Server</shortdesc>
+
+<parameters>
+
+<parameter name="auth_url" unique="0" required="1">
+<longdesc lang="en">
+Authorization URL for connecting to keystone in admin context
+</longdesc>
+<shortdesc lang="en">Authorization URL</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="username" unique="0" required="1">
+<longdesc lang="en">
+Username for connecting to keystone in admin context
+</longdesc>
+<shortdesc lang="en">Username</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="password" unique="0" required="1">
+<longdesc lang="en">
+Password for connecting to keystone in admin context
+</longdesc>
+<shortdesc lang="en">Password</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="tenant_name" unique="0" required="1">
+<longdesc lang="en">
+Tenant name for connecting to keystone in admin context.
+Note that with Keystone V3 tenant names are only unique within a domain.
+</longdesc>
+<shortdesc lang="en">Tenant name</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="domain" unique="0" required="0">
+<longdesc lang="en">
+DNS domain in which hosts live, useful when the cluster uses short names and nova uses FQDN
+</longdesc>
+<shortdesc lang="en">DNS domain</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="endpoint_type" unique="0" required="0">
+<longdesc lang="en">
+Nova API location (internal, public or admin URL)
+</longdesc>
+<shortdesc lang="en">Nova API location (internal, public or admin URL)</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="region_name" unique="0" required="0">
+<longdesc lang="en">
+Region name for connecting to nova.
+</longdesc>
+<shortdesc lang="en">Region name</shortdesc>
+<content type="string" default="" />
+</parameter>
+
+<parameter name="insecure" unique="0" required="0">
+<longdesc lang="en">
+Explicitly allow client to perform "insecure" TLS (https) requests.
+The server's certificate will not be verified against any certificate authorities.
+This option should be used with caution.
+</longdesc>
+<shortdesc lang="en">Allow insecure TLS requests</shortdesc>
+<content type="boolean" default="0" />
+</parameter>
+
+<parameter name="no_shared_storage" unique="0" required="0">
+<longdesc lang="en">
+Indicate that nova storage for instances is not shared across compute
+nodes. This must match the reality of how nova storage is configured!
+Otherwise VMs could end up in error state upon evacuation. When
+storage is non-shared, instances on dead hypervisors will be rebuilt
+from their original image or volume, so anything on ephemeral storage
+will be lost.
+</longdesc>
+<shortdesc lang="en">Disable shared storage recovery for instances</shortdesc>
+<content type="boolean" default="0" />
+</parameter>
+
+<parameter name="verbose" unique="0" required="0">
+<longdesc lang="en">
+Enable extra logging from the evacuation process
+</longdesc>
+<shortdesc lang="en">Enable debug logging</shortdesc>
+<content type="boolean" default="0" />
+</parameter>
+
+<parameter name="evacuate_delay" unique="0" required="0">
+<longdesc lang="en">
+Allows delaying the nova evacuate API call, e.g. to give a storage array time to clean
+up eventual locks/leases.
+</longdesc>
+<shortdesc lang="en">Nova evacuate delay</shortdesc>
+<content type="integer" default="0" />
+</parameter>
+
+</parameters>
+
+<actions>
+<action name="start" timeout="20" />
+<action name="stop" timeout="20" />
+<action name="monitor" timeout="600" interval="10" depth="0"/>
+<action name="validate-all" timeout="20" />
+<action name="meta-data" timeout="5" />
+</actions>
+</resource-agent>
+END
+}
+
+#######################################################################
+
+# don't exit on TERM, to test that lrmd makes sure that we do exit
+trap sigterm_handler TERM
+sigterm_handler() {
+ ocf_log info "They use TERM to bring us down. No such luck."
+ return
+}
+
+evacuate_usage() {
+ cat <<END
+usage: $0 {start|stop|monitor|validate-all|meta-data}
+
+Expects to have a fully populated OCF RA-compliant environment set.
+END
+}
+
+evacuate_stop() {
+ rm -f "$statefile"
+ return $OCF_SUCCESS
+}
+
+evacuate_start() {
+ touch "$statefile"
+ # Do not invole monitor here so that the start timeout can be low
+ return $?
+}
+
+update_evacuation() {
+ attrd_updater -p -n evacuate -Q -N ${1} -U ${2}
+ arc=$?
+ if [ ${arc} != 0 ]; then
+ ocf_log warn "Can not set evacuation state of ${1} to ${2}: ${arc}"
+ fi
+ return ${arc}
+}
+
+handle_evacuations() {
+ while [ $# -gt 0 ]; do
+ node=$1
+ state=$2
+ shift; shift;
+ need_evacuate=0
+
+ case $state in
+ "")
+ ;;
+ no)
+ ocf_log debug "$node is either fine or already handled"
+ ;;
+ yes) need_evacuate=1
+ ;;
+ *@*)
+ where=$(echo $state | awk -F@ '{print $1}')
+ when=$(echo $state | awk -F@ '{print $2}')
+ now=$(date +%s)
+
+ if [ $(($now - $when)) -gt 60 ]; then
+ ocf_log info "Processing partial evacuation of $node by" \
+ "$where at $when"
+ need_evacuate=1
+ else
+ # Give some time for any in-flight evacuations to either
+ # complete or fail Nova won't react well if there are two
+ # overlapping requests
+ ocf_log info "Deferring processing partial evacuation of" \
+ "$node by $where at $when"
+ fi
+ ;;
+ esac
+
+ if [ $need_evacuate = 1 ]; then
+ fence_agent="fence_compute"
+
+ if have_binary fence_evacuate; then
+ fence_agent="fence_evacuate"
+ fi
+
+ if [ ${OCF_RESKEY_evacuate_delay} != 0 ]; then
+ ocf_log info "Delaying nova evacuate by $OCF_RESKEY_evacuate_delay seconds"
+ sleep ${OCF_RESKEY_evacuate_delay}
+ fi
+
+ ocf_log notice "Initiating evacuation of $node with $fence_agent"
+ $fence_agent ${fence_options} -o status -n ${node}
+ if [ $? = 1 ]; then
+ ocf_log info "Nova does not know about ${node}"
+ # Dont mark as no because perhaps nova is unavailable right now
+ continue
+ fi
+
+ update_evacuation ${node} "$(uname -n)@$(date +%s)"
+ if [ $? != 0 ]; then
+ return $OCF_SUCCESS
+ fi
+
+ $fence_agent ${fence_options} -o off -n $node
+ rc=$?
+
+ if [ $rc = 0 ]; then
+ update_evacuation ${node} no
+ ocf_log notice "Completed evacuation of $node"
+ else
+ ocf_log warn "Evacuation of $node failed: $rc"
+ update_evacuation ${node} yes
+ fi
+ fi
+ done
+
+ return $OCF_SUCCESS
+}
+
+evacuate_monitor() {
+ if [ ! -f "$statefile" ]; then
+ return $OCF_NOT_RUNNING
+ fi
+
+ handle_evacuations $(
+ attrd_updater -n evacuate -A \
+ 2> >(grep -v "attribute does not exist" 1>&2) |
+ sed 's/ value=""/ value="no"/' |
+ tr '="' ' ' |
+ awk '{print $4" "$6}'
+ )
+ return $OCF_SUCCESS
+}
+
+evacuate_validate() {
+ rc=$OCF_SUCCESS
+ fence_options=""
+
+ if ! have_binary fence_evacuate; then
+ check_binary fence_compute
+ fi
+
+ # Is the state directory writable?
+ state_dir=$(dirname $statefile)
+ touch "$state_dir/$$"
+ if [ $? != 0 ]; then
+ ocf_exit_reason "Invalid state directory: $state_dir"
+ return $OCF_ERR_ARGS
+ fi
+ rm -f "$state_dir/$$"
+
+ if [ -z "${OCF_RESKEY_auth_url}" ]; then
+ ocf_exit_reason "auth_url not configured"
+ exit $OCF_ERR_CONFIGURED
+ fi
+
+ fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}"
+
+ if [ -z "${OCF_RESKEY_username}" ]; then
+ ocf_exit_reason "username not configured"
+ exit $OCF_ERR_CONFIGURED
+ fi
+
+ fence_options="${fence_options} -l ${OCF_RESKEY_username}"
+
+ if [ -z "${OCF_RESKEY_password}" ]; then
+ ocf_exit_reason "password not configured"
+ exit $OCF_ERR_CONFIGURED
+ fi
+
+ fence_options="${fence_options} -p ${OCF_RESKEY_password}"
+
+ if [ -z "${OCF_RESKEY_tenant_name}" ]; then
+ ocf_exit_reason "tenant_name not configured"
+ exit $OCF_ERR_CONFIGURED
+ fi
+
+ fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
+
+ if [ -n "${OCF_RESKEY_domain}" ]; then
+ fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
+ fi
+
+ if [ -n "${OCF_RESKEY_region_name}" ]; then
+ fence_options="${fence_options} \
+ --region-name ${OCF_RESKEY_region_name}"
+ fi
+
+ if [ -n "${OCF_RESKEY_insecure}" ]; then
+ if ocf_is_true "${OCF_RESKEY_insecure}"; then
+ fence_options="${fence_options} --insecure"
+ fi
+ fi
+
+ if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
+ if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
+ fence_options="${fence_options} --no-shared-storage"
+ fi
+ fi
+
+ if [ -n "${OCF_RESKEY_verbose}" ]; then
+ if ocf_is_true "${OCF_RESKEY_verbose}"; then
+ fence_options="${fence_options} --verbose"
+ fi
+ fi
+
+ if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
+ case ${OCF_RESKEY_endpoint_type} in
+ adminURL|publicURL|internalURL)
+ ;;
+ *)
+ ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type}" \
+ "not valid. Use adminURL or publicURL or internalURL"
+ exit $OCF_ERR_CONFIGURED
+ ;;
+ esac
+ fence_options="${fence_options} -e ${OCF_RESKEY_endpoint_type}"
+ fi
+
+ if [ $rc != $OCF_SUCCESS ]; then
+ exit $rc
+ fi
+ return $rc
+}
+
+statefile="${HA_RSCTMP}/${OCF_RESOURCE_INSTANCE}.active"
+
+case $__OCF_ACTION in
+ start)
+ evacuate_validate
+ evacuate_start
+ ;;
+ stop)
+ evacuate_stop
+ ;;
+ monitor)
+ evacuate_validate
+ evacuate_monitor
+ ;;
+ meta-data)
+ meta_data
+ exit $OCF_SUCCESS
+ ;;
+ usage|help)
+ evacuate_usage
+ exit $OCF_SUCCESS
+ ;;
+ validate-all)
+ exit $OCF_SUCCESS
+ ;;
+ *)
+ evacuate_usage
+ exit $OCF_ERR_UNIMPLEMENTED
+ ;;
+esac
+rc=$?
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
+exit $rc

1056
SPECS/resource-agents.spec Normal file

File diff suppressed because it is too large Load Diff