#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r720 src/43haes/usr/sbin/cluster/events/utils/cl_scsipr_extendvg.sh 1.2 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2015 
# 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_scsipr_extendvg
#
# Description: This script is a wrapper to call function from file
# cl_scsipr_event_functions from cspoc utility cl_extenvg.
# As cl_extenvg uses clrsh, it directl can not call functions.
# This file will just call a function.
# 
# Input: None
#
# Output: 0 on succes
#         1 on failure
#
############################################################
export PATH=$(/usr/es/sbin/cluster/utilities/cl_get_path all)

#####################################
#  MAIN
#
#####################################

# Including file containing SCSIPR functions
. /usr/es/sbin/cluster/events/utils/cl_scsipr_event_functions

# This function will register and reserve the new disks being added to the 
# Volume Group

[[ "$VERBOSE_LOGGING" == "high" ]] && set -x

typeset PVIDs=$@

for id in $PVIDs
do
    typeset hdisk=$(lspv -L | grep -w $id | awk '{print $1}')
    if [ -z "$hdisk" ]
    then
        
        #
        : Unable to get hdisk corresponding to PVID $id on node $(get_local_nodename).
        #
        exit 1
    fi
    cl_scsipr_Reg_Res $hdisk
    if (( $? != 0 ))
    then
        dspmsg -s 33 cspoc.cat 6 "ERROR: Failed to register and reserve disk %1$s using SCSI persistent reserve from node %2$s." $hdisk $(get_local_nodename)
        exit 1
    fi
done
