Blame SOURCES/bz1411225-oraasm.patch

15862b
From 70030ab28f81609292cfbb3c7b34f3f033b09c57 Mon Sep 17 00:00:00 2001
15862b
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
15862b
Date: Thu, 23 Mar 2017 10:50:45 +0100
15862b
Subject: [PATCH] oraasm: new resource agent for Oracle ASM Disk Groups
15862b
15862b
---
15862b
 doc/man/Makefile.am   |   1 +
15862b
 heartbeat/Makefile.am |   1 +
15862b
 heartbeat/oraasm      | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++
15862b
 3 files changed, 181 insertions(+)
15862b
 create mode 100755 heartbeat/oraasm
15862b
15862b
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
15862b
index 43a3f70..f5f64c8 100644
15862b
--- a/doc/man/Makefile.am
15862b
+++ b/doc/man/Makefile.am
15862b
@@ -122,6 +122,7 @@ man_MANS	       = ocf_heartbeat_AoEtarget.7 \
15862b
                           ocf_heartbeat_nfsnotify.7 \
15862b
                           ocf_heartbeat_nfsserver.7 \
15862b
                           ocf_heartbeat_nginx.7 \
15862b
+                          ocf_heartbeat_oraasm.7 \
15862b
                           ocf_heartbeat_oracle.7 \
15862b
                           ocf_heartbeat_oralsnr.7 \
15862b
                           ocf_heartbeat_pgsql.7 \
15862b
diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
15862b
index 91d4090..229db71 100644
15862b
--- a/heartbeat/Makefile.am
15862b
+++ b/heartbeat/Makefile.am
15862b
@@ -119,6 +119,7 @@ ocf_SCRIPTS	     =  AoEtarget		\
15862b
 			named			\
15862b
 			nfsnotify		\
15862b
 			nfsserver		\
15862b
+			oraasm			\
15862b
 			oracle			\
15862b
 			oralsnr			\
15862b
 			pingd			\
15862b
diff --git a/heartbeat/oraasm b/heartbeat/oraasm
15862b
new file mode 100755
15862b
index 0000000..22b88ea
15862b
--- /dev/null
15862b
+++ b/heartbeat/oraasm
15862b
@@ -0,0 +1,179 @@
15862b
+#!/bin/sh
15862b
+#
15862b
+#  License:      GNU General Public License (GPL)
15862b
+#  (c) 2017 O. Albrigtsen
15862b
+#           and Linux-HA contributors
15862b
+#
15862b
+# -----------------------------------------------------------------------------
15862b
+#      O C F    R E S O U R C E    S C R I P T   S P E C I F I C A T I O N
15862b
+# -----------------------------------------------------------------------------
15862b
+#
15862b
+# NAME
15862b
+#       oraasm : OCF resource agent script for Oracle ASM
15862b
+#
15862b
+
15862b
+# Initialization:
15862b
+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
15862b
+. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
15862b
+
15862b
+# Defaults
15862b
+OCF_RESKEY_user_default="grid"
15862b
+
15862b
+: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
15862b
+
15862b
+
15862b
+oraasm_usage() {
15862b
+	cat <
15862b
+    usage: $0 (start|stop|validate-all|meta-data|help|usage|monitor)
15862b
+    $0 manages a Oracle ASM Disk Group as an OCF HA resource.
15862b
+    The 'start' operation starts the instance.
15862b
+    The 'stop' operation stops the instance.
15862b
+    The 'status' operation reports whether the instance is running
15862b
+    The 'monitor' operation reports whether the instance seems to be working
15862b
+    The 'validate-all' operation reports whether the parameters are valid
15862b
+END
15862b
+}
15862b
+
15862b
+oraasm_meta_data() {
15862b
+	cat <
15862b
+
15862b
+
15862b
+<resource-agent name="oraasm">
15862b
+<version>0.75</version>
15862b
+
15862b
+<longdesc lang="en">OCF Resource script for Oracle ASM. It uses the ohasd init-script to manage a Oracle ASM Disk Group as a HA resource.</longdesc>
15862b
+<shortdesc lang="en">Oracle ASM resource agent</shortdesc>
15862b
+
15862b
+<parameters>
15862b
+
15862b
+<parameter name="user">
15862b
+    <longdesc lang="en">Oracle Grid user</longdesc>
15862b
+    <shortdesc lang="en">Oracle Grid user</shortdesc>
15862b
+    <content type="string" default="${OCF_RESKEY_user_default}" />
15862b
+</parameter>
15862b
+
15862b
+<parameter name="diskgroup" required="1">
15862b
+    <longdesc lang="en">
15862b
+The name of the Oracle Disk Group.
15862b
+If not specified, then the Disk Group along with its home should be listed in /etc/oratab.
15862b
+    </longdesc>
15862b
+    <shortdesc lang="en">Oracle Disk Group</shortdesc>
15862b
+    <content type="string" default="" />
15862b
+</parameter>
15862b
+
15862b
+<parameter name="home" unique="0">
15862b
+<longdesc lang="en">The Oracle Grid home directory</longdesc>
15862b
+<shortdesc lang="en">home</shortdesc>
15862b
+<content type="string" default="" />
15862b
+</parameter>
15862b
+
15862b
+</parameters>
15862b
+
15862b
+<actions>
15862b
+<action name="start" timeout="60" />
15862b
+<action name="stop" timeout="60" />
15862b
+<action name="status" timeout="30" />
15862b
+<action name="monitor" depth="0" timeout="30" interval="10" />
15862b
+<action name="validate-all" timeout="5" />
15862b
+<action name="meta-data" timeout="5" />
15862b
+</actions>
15862b
+</resource-agent>
15862b
+END
15862b
+}
15862b
+
15862b
+oraasm_methods() {
15862b
+	cat <<-!
15862b
+	start
15862b
+	stop
15862b
+	status
15862b
+	monitor
15862b
+	validate-all
15862b
+	methods
15862b
+	meta-data
15862b
+	usage
15862b
+	!
15862b
+}
15862b
+
15862b
+oraasm_getconfig() {
15862b
+	[ x = "x$OCF_RESKEY_home" ] &&
15862b
+		OCF_RESKEY_home=`awk -F: "/^+$OCF_RESKEY_diskgroup:/"'{print $2}' /etc/oratab`
15862b
+	PATH="$OCF_RESKEY_home/bin:$PATH"
15862b
+
15862b
+	ORA_ENVF=`mktemp`
15862b
+	cat << EOF > $ORA_ENVF
15862b
+PATH="$OCF_RESKEY_home/bin:$PATH"
15862b
+EOF
15862b
+	chmod 644 $ORA_ENVF
15862b
+	trap "rm -f $ORA_ENVF" EXIT
15862b
+}
15862b
+
15862b
+oraasm_start() {
15862b
+	# if resource is already running, no need to continue code after this.
15862b
+	if oraasm_monitor; then
15862b
+		ocf_log info "Oracle ASM is already running"
15862b
+		return $OCF_SUCCESS
15862b
+	fi
15862b
+
15862b
+	ocf_run -q /etc/init.d/ohasd start
15862b
+
15862b
+	while ! oraasm_monitor; do
15862b
+		sleep 1
15862b
+	done
15862b
+
15862b
+	return $OCF_SUCCESS
15862b
+}
15862b
+
15862b
+oraasm_stop() {
15862b
+	oraasm_monitor
15862b
+	if [ $? -ne $OCF_SUCCESS ]; then
15862b
+		# Currently not running. Nothing to do.
15862b
+		ocf_log info "Oracle ASM is already stopped"
15862b
+
15862b
+		return $OCF_SUCCESS
15862b
+	fi
15862b
+
15862b
+	ocf_run -q /etc/init.d/ohasd stop
15862b
+
15862b
+	# Wait for process to stop
15862b
+	while oraasm_monitor; do
15862b
+		sleep 1
15862b
+	done
15862b
+
15862b
+	return $OCF_SUCCESS
15862b
+}
15862b
+
15862b
+oraasm_monitor() {
15862b
+	su - $OCF_RESKEY_user -c ". $ORA_ENVF; crsctl check has | grep -q \"CRS-4638\""
15862b
+	case "$?" in
15862b
+		0)
15862b
+			rc=$OCF_SUCCESS
15862b
+			;;
15862b
+		1)
15862b
+			rc=$OCF_NOT_RUNNING
15862b
+			ocf_log info "Oracle ASM is not running"
15862b
+			;;
15862b
+		*)
15862b
+			rc=$OCF_ERR_GENERIC
15862b
+			;;
15862b
+	esac
15862b
+	return $rc
15862b
+}
15862b
+
15862b
+oraasm_status() {
15862b
+	rc=$(oraasm_monitor)
15862b
+	return $rc
15862b
+}
15862b
+
15862b
+oraasm_validate_all() {
15862b
+	if [ x = "x$OCF_RESKEY_home" ]; then
15862b
+		ocf_exit_reason "home not set"
15862b
+		return $OCF_ERR_CONFIGURED
15862b
+	fi
15862b
+}
15862b
+
15862b
+
15862b
+OCF_REQUIRED_PARAMS="user diskgroup"
15862b
+OCF_REQUIRED_BINARIES="/etc/init.d/ohasd crsctl"
15862b
+ocf_rarun $*
15862b
+
15862b
+# vim:tabstop=4:shiftwidth=4:textwidth=0:wrapmargin=0