#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/cspoc/utilities/cli_rmlv.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2003 
# 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 
# @(#)19        1.1  src/43haes/usr/sbin/cluster/cspoc/utilities/cli_rmlv.sh, hacmp.cspoc, 61haes_r714 12/8/03 10:02:35

###############################################################################
#
#   COMPONENT_NAME: CSPOC Command Line Interface
#
# Name:
#   cli_rmlv
#
# Description:
#   Use C-SPOC to run the rmlv command with the given parameters and make the
#   volume group definition known on all cluster nodes
#
# Arguments:
#   Same as for the rmlv command except that '-p' is not supported; 
#   assumed validated by caller
#
#   If '-f' is not supplied, it will be forced
#
#   Setting the environment variable _DEBUG to 1 -> 9 turns on levels of
#   C-SPOC debugging
#
# Return Values:
#   As set by cl_rmlv
#
# Notes:
#   The '-f' flag is passed on cl_rmlv to surpress unnecessary checking.
#   As a consequenc, the operation will proceed even if not all nodes are
#   accessable, and the '-f' will be passed through to the native rmlv
#   command.
#
################################################################################


typeset DEBUG
typeset cl_rmlv_args

#
#   Variables needed by cl_rmlv
#	_NODE_LIST - the list of nodes in the cluster
#	_CSPOC_MODE - working with shared (as opposed to concurrent) volume
#			groups
#	_CSPOC_CALLED_FROM_SMIT - can skip checks on input
#
export _CSPOC_MODE="shared"
export _CSPOC_CALLED_FROM_SMIT="true"

#
#   If a _DEBUG value has been set, pass it through
#
if [[ -n $_DEBUG ]] ; then

    #
    #	The debug level is a number, 1 through 9.  Those values are passed
    #	through.  Anything else is turned into '1'
    #
    integer dbg_level=$_DEBUG
    if (( $dbg_level < 10 && $dbg_level >= 1 )) ; then
	DEBUG="-d $_DEBUG"
    else
	DEBUG="-d 1"
    fi
fi

#
#   Construct the node list.  This is a comma separated, quote delimited list
#   of all the nodes in the cluster.
#
export _NODE_LIST=$(odmget -q "object = VERBOSE_LOGGING" HACMPnode | \
		      grep 'name =' | cut -f2 -d'"' | paste -s -d ',' -)

#
#   The arguments to cl_rmlv are the sme as passed in, with the addition of
#   '-f' to skip prompting
#
if [[ $* != @(*-f*) ]] ; then		# if '-f' isn't there
    cl_rmlv_args="-f $*"		# add it to user specified parameters
else
    cl_rmlv_args=$*
fi

#
#   Invoke the cspoc code to remove the logical volume and make it known on all
#   cluster nodes.  
#
/usr/es/sbin/cluster/sbin/cl_rmlv -cspoc "-f $DEBUG -n $_NODE_LIST" $cl_rmlv_args
return $?
