#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/cspoc/utilities/cl_list_log_lvs.sh 1.3 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2009,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 
# @(#)85        1.3  src/43haes/usr/sbin/cluster/cspoc/utilities/cl_list_log_lvs.sh, hacmp.cspoc, 61haes_r714 11/28/11 15:05:08
###############################################################################
#
#   COMPONENT_NAME: CSPOC Command Line Interface
#
# Name:
#   cl_list_log_lvs
#
# Description:
#   Given the name of a volume group, and a log type (jfs or jfs2) find all
#   log logical volumes in that volume group of that type.
#
# Arguments:
#   Log type, 'jfs' or 'jfs2'
#   Volume group name, assumed known on some cluster nodes
#
# Return Values:
#   Available log logical volumes of the given type (jfslog or jfs2log) 
#   written to stdout preceeded by a header
#
################################################################################

[[ $VERBOSE_LOGGING == high ]] && set -x
[[ $VERBOSE_LOGGING == high ]] && version='1.3 $Source: 61haes_r711 43haes/usr/sbin/cluster/cspoc/utilities/cl_list_log_lvs.sh 1$'

log_lvtype=${1}log	#   jfs or jfs2 log
VG_name=$2		#   Volume group name
some_found=FALSE
export ODMDIR=/etc/objrepos

#
:   Look for all the $log_lvtype logical volumes in the given volume group
#
/usr/es/sbin/cluster/sbin/cl_lsvg -l $VG_name | tail +3 | cut -f2 -d':' | \
    while read lvname lvtype rest ; do
	if [[ $lvtype == $log_lvtype ]]
	then
	    if [[ $some_found == FALSE ]]
	    then
		#
		:   First time headers.  '#' makes the line non-selectable
		#
		print "#    "$(dspmsg -s 49 cspoc.cat 40 "Select a $log_lvtype logical volume from the list below" $log_lvtype)
		print "#    "$(dspmsg -s 49 cspoc.cat 41 "Or leave blank to have a new one chosen automatically")
		some_found=TRUE
	    fi
	    #
	    :	Display the $log_lvtype logical volume 
	    #
	    print $lvname
	fi
    done

if [[ $some_found == FALSE ]]
then
    #
    :	No logical volumes of type $log_lvtype were found
    #
    print "#    "$(dspmsg -s 49 cspoc.cat 42 "Volume group $VG_name has no $log_lvtype logical volumes" $VG_name $log_lvtype)
    print "#    "$(dspmsg -s 49 cspoc.cat 43 "Leave blank to have a new one chosen automatically")
fi
