#!/bin/sh
#
# $Id: ICP.in,v 1.4 2005/11/03 07:45:51 xunsun Exp $
# 
# Description:	wrapper of OCF RA ICP, based on original heartbeat RA.
#		See OCF RA ICP for more information.
#
# Author:	Xun Sun <xunsun@cn.ibm.com>
# Support:      linux-ha@lists.linux-ha.org
# License:	GNU General Public License (GPL)
# Copyright:	(C) 2005 International Business Machines
#
# An example usage in /etc/ha.d/haresources: 
#       node1  10.0.0.170 LinuxSCSI::0:0 ICP::c0h1::/dev/sdb1 LVM::myvolname
#
# Notice that you will need to get the utility "icpclucon" from the ICP
# support to use this.
#
# See usage() function below for more details...
#

. /etc/ha.d/resource.d//hto-mapfuncs

unset LC_ALL; export LC_ALL
unset LANGUAGE; export LANGUAGE

usage() {
  methods=`ICP_methods`
  methods=`echo $methods | tr ' ' '|'`
  cat <<-! >&1
	usage: $0 <ICP cluster drive ID> <device> {$methods}
	usage: $0 methods

	$0 manages an ICP Vortex clustered host drive.

	The 'start' operation reserves the given host drive.
	The 'stop' operation releses the given host drive.
	The 'status' operation reports whether the host drive is reserved.
	The 'monitor' operation reports whether the host drive is reserved.
	The 'methods' operation reports on the methods $0 supports

	$Id: ICP.in,v 1.4 2005/11/03 07:45:51 xunsun Exp $
	!
  exit 1
}

#
# methods: What methods/operations do we support?
#
ICP_methods() {
  cat <<-!
	start
	stop
	status
	monitor
	methods
	!
}

#
#	'main' starts here...
#
case $# in
  1)	if [ "methods" = "$1" ]; then
		ICP_methods
		exit $?
	fi;;
  3)	;;
  *)	usage;;
esac

# What kind of method was invoked?
case "$3" in
  start|stop|status|monitor)
	;;
  methods)
	ICP_methods
	exit $?;;
  *)
	usage;;
esac

ra_execocf  "rsc_id=ICP_$1" "rsc_type=ICP" "provider=heartbeat" $3 "driveid=$1" "device=$2"
