#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r720 src/43haes/usr/sbin/cluster/events/utils/cl_scsipr_diskreplace.sh 1.1 
#  
# 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_diskreplace
#
# Description: THis script is a wrapper to call function
# from file cl_scsipr_event_functions from cspoc utility 
# cl_diskreplace.
# 
# Input : Source disk PVID(disk to be removed from a VG
#         Destination disk PVID(dsik to be added to the VG)
#
# Output: 0 on success
#       : 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

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

typeset Source_PVID=$1
typeset Destination_PVID=$2
typeset VGName=$3

typeset Source_disk=$(lspv -L | grep -w $Source_PVID | awk '{print $1}')
if [ -z "$Source_disk" ]
then
	
	#
	: Unable to get hdisk corresponding to PVID $Source_PVID on node $(get_local_nodename).
	#
	return 1
fi
typeset Destination_disk=$(lspv -L | grep -w $Destination_PVID | awk '{print $1}')
if [ -z "$Destination_disk" ]
then
	
	#
	:  Unable to get hdisk corresponding to PVID $Destination_PVID on node $(get_local_nodename).
	#
	return 1
fi

disk_replace_scsipr $Source_disk $Destination_disk $VGName
if (( $? != 0 ))
then
	return 1
fi



