[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH] rgmanager: Backport upstream fixes for SAPDatabase agent



This patch is specific to the RHEL5 branches and was
provided by Frank Danapfel based on his work with the
upstream version of the SAPDatabase agent.

Resolves: rhbz#747352

Signed-off-by: Lon Hohberger <lhh redhat com>
---
 rgmanager/src/resources/SAPDatabase |   95 ++++++++++++++++++++---------------
 1 files changed, 54 insertions(+), 41 deletions(-)

diff --git a/rgmanager/src/resources/SAPDatabase b/rgmanager/src/resources/SAPDatabase
index 3be8c8e..eccc1a8 100644
--- a/rgmanager/src/resources/SAPDatabase
+++ b/rgmanager/src/resources/SAPDatabase
@@ -80,12 +80,12 @@ meta_data() {
 <?xml version="1.0"?>
 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
 <resource-agent name="SAPDatabase">
-<version>1.92.1</version>
+<version>1.93</version>
 
 <longdesc lang="en">
 Resource script for SAP databases. It manages a SAP database of any type as an HA resource.
 </longdesc>
-<shortdesc lang="en">SAP database resource agent</shortdesc>
+<shortdesc lang="en">Manages any SAP database (based on Oracle, MaxDB, or DB2)</shortdesc>
 
 <parameters>
  <parameter name="SID" unique="1" required="1" primary="1">
@@ -201,26 +201,27 @@ do_exit() {
 # listener_start: Start the given listener
 #
 listener_start() {
-  orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
-  rc=$OCF_SUCCESS
+  local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
+  local lrc=$OCF_SUCCESS
+  local output
   output=`echo "lsnrctl start $NETSERVICENAME" | su - $orasid 2>&1`
   if [ $? -eq 0 ]
   then
     ocf_log info "Oracle Listener $NETSERVICENAME started: $output"
-    rc=$OCF_SUCCESS
+    lrc=$OCF_SUCCESS
   else
     ocf_log err "Oracle Listener $NETSERVICENAME start failed: $output"
-    rc=$OCF_ERR_GENERIC
+    lrc=$OCF_ERR_GENERIC
   fi
-  return $rc
+  return $lrc
 }
 
 #
 # listener_stop: Stop the given listener
 #
 listener_stop() {
-  orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
-  rc=$OCF_SUCCESS
+  local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
+  local lrc=$OCF_SUCCESS
   if
       listener_status
   then
@@ -228,84 +229,89 @@ listener_stop() {
   else
       return $OCF_SUCCESS
   fi
+  local output
   output=`echo "lsnrctl stop $NETSERVICENAME" | su - $orasid 2>&1`
   if [ $? -eq 0 ]
   then
     ocf_log info "Oracle Listener $NETSERVICENAME stopped: $output"
   else
     ocf_log err "Oracle Listener $NETSERVICENAME stop failed: $output"
-    rc=$OCF_ERR_GENERIC
+    lrc=$OCF_ERR_GENERIC
   fi
-  return $rc
+  return $lrc
 }
 
 #
 # listener_status: is the given listener running?
 #
 listener_status() {
-  orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
+  local lrc=$OCF_SUCCESS
+  local orasid="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
   # Note: ps cuts off it's output at column $COLUMNS, so "ps -ef" can not be used here
   # as the output might be to long.
-  cnt=`ps efo args --user $orasid | grep $NETSERVICENAME | grep -c tnslsnr`
+  local cnt=`ps efo args --user $orasid | grep $NETSERVICENAME | grep -c tnslsnr`
   if [ $cnt -eq 1 ]
   then
-    rc=$OCF_SUCCESS
+    lrc=$OCF_SUCCESS
   else
     ocf_log info "listener process not running for $NETSERVICENAME for $SID"
-    rc=$OCF_ERR_GENERIC
+    lrc=$OCF_ERR_GENERIC
   fi
-  return $rc
+  return $lrc
 }
 
 #
 # x_server_start: Start the given x_server
 #
 x_server_start() {
-  rc=$OCF_SUCCESS
+  local rc=$OCF_SUCCESS
+  local output
   output=`echo "x_server start" | su - $sidadm 2>&1`
   if [ $? -eq 0 ]
   then
     ocf_log info "MaxDB x_server start: $output"
-    rc=$OCF_SUCCESS
+    lrc=$OCF_SUCCESS
   else
     ocf_log err "MaxDB x_server start failed: $output"
-    rc=$OCF_ERR_GENERIC
+    lrc=$OCF_ERR_GENERIC
   fi
-  return $rc
+  return $lrc
 }
 
 #
 # x_server_stop: Stop the x_server
 #
 x_server_stop() {
-  rc=$OCF_SUCCESS
+  local lrc=$OCF_SUCCESS
+  local output
   output=`echo "x_server stop" | su - $sidadm 2>&1`
   if [ $? -eq 0 ]
   then
     ocf_log info "MaxDB x_server stop: $output"
   else
     ocf_log err "MaxDB x_server stop failed: $output"
-    rc=$OCF_ERR_GENERIC
+    lrc=$OCF_ERR_GENERIC
   fi
-  return $rc
+  return $lrc
 }
 
 #
 # x_server_status: is the x_server running?
 #
 x_server_status() {
-  sdbuser=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
+  local lrc=$OCF_SUCCESS
+  local sdbuser=`grep "^SdbOwner" /etc/opt/sdb | awk -F'=' '{print $2}'`
   # Note: ps cuts off it's output at column $COLUMNS, so "ps -ef" can not be used here
   # as the output might be to long.
-  cnt=`ps efo args --user $sdbuser | grep -c vserver`
+  local cnt=`ps efo args --user $sdbuser | grep -c vserver`
   if [ $cnt -ge 1 ]
   then
-    rc=$OCF_SUCCESS
+    lrc=$OCF_SUCCESS
   else
     ocf_log info "x_server process not running"
-    rc=$OCF_ERR_GENERIC
+    lrc=$OCF_ERR_GENERIC
   fi
-  return $rc
+  return $lrc
 }
 
 #
@@ -340,9 +346,14 @@ su - $sidadm -c $TEMPFILE
 retcode=$?
 rm -f $TEMPFILE
 
+if [ $retcode -ne 0 ]; then
+   ocf_log err "Failed to stop database, return code $retcode"
+fi
+
 if [ $retcode -eq 0 ]; then
   sapdatabase_status
   if [ $? -ne $OCF_NOT_RUNNING ]; then
+    ocf_log crit "Database did not actually stop!"
     retcode=1
   fi
 fi
@@ -439,9 +450,7 @@ $SRVMGRDBA_EXE /NOLOG >> $LOG << !
 connect / as sysdba
 shutdown abort
 startup mount
-WHENEVER SQLERROR EXIT SQL.SQLCODE
-WHENEVER OSERROR EXIT FAILURE
-alter database recover automatic database;
+alter database end backup;
 alter database open;
 exit
 !
@@ -560,7 +569,7 @@ sapuserexit() {
     if [ -x "$VALUE" ]
     then
       ocf_log info "Calling userexit ${NAME} with customer script file ${VALUE}"
-      eval "$VALUE" >& /dev/null
+      "$VALUE" >/dev/null 2>&1
       ocf_log info "Exiting userexit ${NAME} with customer script file ${VALUE}, returncode: $?"
     else
       ocf_log warn "Attribute ${NAME} is set to ${VALUE}, but this file is not executable"
@@ -662,7 +671,12 @@ sapdatabase_stop() {
 #
 sapdatabase_monitor() {
   strict=$1
-  rc=$OCF_SUCCESS
+
+  sapdatabase_status
+  rc=$?
+  if [ $rc -ne $OCF_SUCCESS ]; then
+    return $rc
+  fi
 
   case $DBTYPE in
     ADA) x_server_status 
@@ -675,8 +689,7 @@ sapdatabase_monitor() {
 
   if [ $strict -eq 0 ]
   then
-    sapdatabase_status
-    rc=$?
+    return $rc
   else
     if [ $DBJ2EE_ONLY -eq 0 ]
     then
@@ -720,7 +733,7 @@ sapdatabase_monitor() {
 
       if [ -n "$EXECMD" ]
       then
-        output=`eval ${JAVA_HOME}/bin/java -cp $MYCP $EXECMD`
+        output=`${JAVA_HOME}/bin/java -cp $MYCP $EXECMD 2> /dev/null`
         if [ $? -le 0 ]
         then
           rc=$OCF_SUCCESS
@@ -755,9 +768,9 @@ sapdatabase_status() {
          SUSER="ora`echo $SID | tr '[:upper:]' '[:lower:]'`"
          SNUM=4
          ;;
-    DB6) SEARCH="db2[a-z][a-z][a-z][a-z][a-z]"
+    DB6) SEARCH="db2[a-z][a-z][a-z]"
          SUSER="db2`echo $SID | tr '[:upper:]' '[:lower:]'`"
-         SNUM=5
+         SNUM=2
          ;;
   esac
 
@@ -768,7 +781,7 @@ sapdatabase_status() {
   then
     rc=$OCF_SUCCESS
   else
-    # ocf_log info "Database Instance $SID is not running on `hostname`"
+    ocf_log err "Database Instance $SID is not running on `hostname`"
     rc=$OCF_NOT_RUNNING
   fi
   return $rc
@@ -876,7 +889,7 @@ if [ -z "$OCF_RESKEY_DBTYPE" ]; then
   ocf_log err "Please set OCF_RESKEY_DBTYPE to the database vendor specific tag (ORA,ADA,DB6)!"
   do_exit $OCF_ERR_ARGS
 fi
-DBTYPE=`echo "$OCF_RESKEY_DBTYPE" | tr '[a-z]' '[A-Z]'`
+DBTYPE=`echo "$OCF_RESKEY_DBTYPE" | tr "[a-z]" "[A-Z]"`
 
 # optional OCF parameters, we try to guess which directories are correct
 EXESTARTDB="startdb"
@@ -947,7 +960,7 @@ then
   then
     BOOTSTRAP="$OCF_RESKEY_DIR_BOOTSTRAP"
   else
-    BOOTSTRAP=`echo /usr/sap/$SID/*/j2ee/cluster/bootstrap | head -1`
+    BOOTSTRAP=`ls -1d /usr/sap/$SID/*/j2ee/cluster/bootstrap | head -1`
   fi
 
   if [ -n "$OCF_RESKEY_DIR_SECSTORE" ]
-- 
1.7.3.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]