#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r721 src/43haes/usr/sbin/cluster/events/utils/cl_scsipr_recover_rg.sh 1.3 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2015,2016 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG ####################################################################### # Name: cl_scsi_recover_rg # # Description: This script register and reserve the Volume Group/Groups # which are part of resource group given as input. # This is to recover a resource group from error state(caused because # SCSI Persistent registration failed) in a active cluster. # # Input: Resource Group name # # Output: None ####################################################################### export PATH=$(/usr/es/sbin/cluster/utilities/cl_get_path all) # Include files SCSIPR functions. . /usr/es/sbin/cluster/events/utils/cl_scsipr_event_functions typeset RG=$1 if [[ -z $RG ]] then cl_dspmsg scripts.cat 575 "Invalid arguments\n" exit 1 fi if LC_ALL=C lssrc -ls clstrmgrES 2>&1 | grep "Current state:" | egrep -q -v "ST_INIT|NOT_CONFIGURED" then typeset localNodename=$(get_local_nodename) if (( $? != 0 )) then cl_dspmsg scripts.cat 10055 "ERROR: Couldn't determine local nodename. Please ensure the cluster\n\ topology has been successfully synchronized.\n" exit 1 fi # Get all the nodes where given RG is in ERROR state typeset nodes_data="" nodes_data=$(LC_ALL=C clRGinfo -s $RG | grep "ERROR") if (( $? != 0 )) then cl_dspmsg scripts.cat 10642 "ERROR: Resource Group %1$s is not currently in ERROR state on any of the cluster node.\n\ This command must be run when the resource group is in\n\ ERROR state due to failure of registering SCSI persistent reserves.\n" $RG exit 1 else typeset nodes=$( LC_ALL=C clRGinfo -s $RG | grep "ERROR" | cut -f3 -d:) if [[ -z $nodes ]] then cl_dspmsg scripts.cat 10648 "ERROR: Unable to retrieve list of configured cluster nodes.\n" exit 1 fi fi typeset scsipr_enabled="" scsipr_enabled=$(clodmget -q "policy=scsi" -f value -n HACMPsplitmerge) if [[ -z $scsipr_enabled ]] then cl_dspmsg scripts.cat 10650 "ERROR: There was an error reading the configuration,\n\ for Quarantine Policy as Disk Fencing from ODM.\n" exit 1 fi if [[ $scsipr_enabled == Yes ]] then for node in $nodes do # Get the PR_key of the Node. typeset PR_Key=$(clpr_obtain_prkey $node) if (( $? != 0 )) then cl_dspmsg scripts.cat 10644 "ERROR: Failed to generate the persistent reserve key for node %1$s.\n\ Hence, failed to recover the resource group %2$s from error state.\n" $localNodename $RG exit 1 fi typeset VG_list=$(clodmget -q "name like *VOLUME_GROUP and group=$RG" -f value -n HACMPresource) if [[ -n $VG_list ]] then typeset VG="" for VG in $VG_list do # Check if Volume Group is SCSI Persistent Reserve Type 7H capable cl_rsh $node /usr/es/sbin/cluster/events/utils/clpr_verifycap_vg $VG rc_cap=$? if (( $rc_cap == 1 )) then cl_dspmsg scripts.cat 10645 "ERROR: Volume Group %1$s is not SCSI Persistent Reserve Type 7H capable.\n" $VG exit 1 elif (( $rc_cap == 0 )) then # Volume group is SCSIPR Type 7H capable. # Verifying the PR Key of Node. cl_rsh $node /usr/es/sbin/cluster/events/utils/clpr_verifyKey_vg $VG $PR_Key if (( $? != 0 )) then # PR Key of this node is not registered. # Try registerting and reserving this VG. cl_rsh $node /usr/es/sbin/cluster/events/utils/cl_scsipr_dare_reg_res $VG if (( $? != 0 )) then cl_dspmsg scripts.cat 10646 "ERROR: Failed recovering the Resource Group %1$s from ERROR state.\n\ As registration failed for one or more disks of Volume Group %2$s.\n" $RG $VG exit 1 fi fi else cl_dspmsg scripts.cat 10641 "ERROR: Failed to determine if Volume Group %1$s is SCSI Persistent Type 7H capable.\n\ Hence, failed to recover Resource Group %2$s from ERROR state.\n" $VG $RG exit 1 fi done else cl_dspmsg scripts.cat 10647 "There are no Volume Groups in Resource Group %1$s." $RG exit 0 fi done fi else cl_dspmsg scripts.cat 10649 "Cluster services are not active on node %1$s.\n\ This script must only be used when a resource group goes to ERROR state,\n\ and cluster services are running.\n" $localNodename fi exit 0