#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/lib/ksh93/aix/KLIB_AIX_get_pvids.sh 1.5 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2005,2013 
# 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 
# @(#)67	1.5 src/43haes/lib/ksh93/aix/KLIB_AIX_get_pvids.sh, hacmp, 61haes_r714 6/13/13 08:23:40
#
#=head1 NAME
#
# KLIB_AIX_get_pvids - Determine the pvids associated with a volume group
#
#=head1 SYNOPSIS
#
# vg_pvids=$(KLIB_AIX_get_pvids rootvg)
#
#=head1 DESCRIPTION
#
# Function echo's to stdout the list of PVIDs associated with the specified
# volume group.
#
#=head1 ARGUMENTS
#
# 1: [scalar] volume group name
#
#=head1 RETURN
#
#	None
#
#=head1 COPYRIGHT
#
#(C) COPYRIGHT International Business Machines Corp. 2005
#All Rights Reserved
#
#=cut
#
function KLIB_AIX_get_pvids
{
	. /usr/es/lib/ksh93/func_include

        VG=$1
        typeset hdisk="" pvid="" rvg="" state="" PVIDS=""

    lspv | while read -r hdisk pvid rvg state; do
        if [[ $rvg == $VG ]]; then
            if [[ " $PVIDS " != *\ $pvid\ * ]]; then
                [[ -n $PVIDS ]] && PVIDS="$PVIDS "
                PVIDS="$PVIDS$pvid"
            fi
        fi
    done

        echo $PVIDS
}
