#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/lib/ksh93/db2/vg/KLIB_DB2_VG_get_vgs.sh 1.4 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2005,2011 
# 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 
# @(#)81	1.4 src/43haes/lib/ksh93/db2/vg/KLIB_DB2_VG_get_vgs.sh, hacmp, 61haes_r714 11/28/11 15:03:05
#
#=head1 NAME
#
# KLIB_DB2_VG_get_vgs - Get a list of volume groups available for the specified node
#
#=head1 SYNOPSIS
#
# . /usr/es/sbin/cluster/sa/db2/etc/db2.disc
# vgs=$(KLIB_DB2_VG_get_vgs "nodeA") || {
#   echo "No volume groups configured on node: nodeA"
# }
#
#=head1 DESCRIPTION
#
# Get a list of volume groups configured on the specified cluster node
#
#=head1 ARGUMENTS
#
#   1: [scalar] cluster node name
#
#=head1 RETURN
#
#   0: volume groups were found for the specified node
#   1: no volume groups were found
#
#=head1 COPYRIGHT
#
#(C) COPYRIGHT International Business Machines Corp. 2005
#All Rights Reserved
#
#=cut
#
function KLIB_DB2_VG_get_vgs
{
	. /usr/es/lib/ksh93/func_include

	node=$1
	lennode=${#node}
	found=1
	((lennode = $lennode + 7))

	for key in ${!AIX_DISKS[*]}; do
		search=$( echo PVIDS_"$node"_ )
		qvalue=${key:0:$lennode}
		if [[ "$qvalue" == "$search" ]]; then
			found=0
			lenkey=${#key}
			OUTVG=${key:$lennode:$lenkey}
			if [[ -n $OUTVG && "$OUTVG" != "None" ]]; then
				echo $OUTVG
			fi
		fi
	done

	return $found
}
