Blame SOURCES/bz1427574-DB2-fix-HADR-DB2-V98-or-later.patch

15862b
From b5d3f7347ff423868d3735df377c649c3e81a12a Mon Sep 17 00:00:00 2001
15862b
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
15862b
Date: Thu, 6 Apr 2017 11:36:44 +0200
15862b
Subject: [PATCH] DB2: fix HADR support for DB2 V98+
15862b
15862b
---
15862b
 heartbeat/db2 | 16 +++++++++-------
15862b
 1 file changed, 9 insertions(+), 7 deletions(-)
15862b
15862b
diff --git a/heartbeat/db2 b/heartbeat/db2
15862b
index c522699..63de315 100755
15862b
--- a/heartbeat/db2
15862b
+++ b/heartbeat/db2
15862b
@@ -650,7 +650,9 @@ db2_hadr_status() {
15862b
     fi
15862b
 
15862b
     echo "$output" |
15862b
-    awk '/^HADR is not active/ {print "Standard/Standalone"; exit; }
15862b
+    awk '/^\s+HADR_(ROLE|STATE) =/ {printf $3"/"}
15862b
+         /^\s+HADR_CONNECT_STATUS =/ {print $3; exit; }
15862b
+         /^HADR is not active/ {print "Standard/Standalone"; exit; }
15862b
          /^Role *State */ {getline; printf "%s/%s\n", $1, $2; exit; }'
15862b
 }
15862b
 
15862b
@@ -680,7 +682,7 @@ db2_monitor() {
15862b
 
15862b
         # set master preference accordingly
15862b
         case "$hadr" in
15862b
-            Primary/*|Standard/*)
15862b
+            PRIMARY/*|Primary/*|Standard/*)
15862b
             # perform  a basic health check
15862b
             CMD="if db2 connect to $db;
15862b
             then 
15862b
@@ -712,11 +714,11 @@ db2_monitor() {
15862b
             ocf_is_ms && master_score -v 10000 -l reboot
15862b
             ;;
15862b
 
15862b
-            Standby/*Peer)
15862b
+            STANDBY/PEER/*|Standby/*Peer)
15862b
             master_score -v 8000 -l reboot
15862b
             ;;
15862b
 
15862b
-            Standby/*)
15862b
+            STANDBY/*|Standby/*)
15862b
             ocf_log warn "DB2 database $instance($db2node)/$db in status $hadr can never be promoted"
15862b
             master_score -D -l reboot
15862b
             ;;
15862b
@@ -755,17 +757,17 @@ db2_promote() {
15862b
             return $OCF_SUCCESS
15862b
             ;;
15862b
 
15862b
-            Primary/Peer)
15862b
+            PRIMARY/PEER/*|PRIMARY/REMOTE_CATCHUP/*|Primary/Peer)
15862b
             # nothing to do, only update pacemaker's view
15862b
             echo MASTER > $STATE_FILE
15862b
             return $OCF_SUCCESS
15862b
             ;;
15862b
 
15862b
-            Standby/Peer)
15862b
+            STANDBY/PEER/CONNECTED|Standby/Peer)
15862b
             # must take over 
15862b
             ;;
15862b
 
15862b
-            Standby/DisconnectedPeer)
15862b
+            STANDBY/PEER/DISCONNECTED|Standby/DisconnectedPeer)
15862b
             # must take over forced 
15862b
             force="by force peer window only"
15862b
             ;;