Previous  |  Next  >  
Product: Cluster Server Guides   
Manual: Cluster Server 4.1 Agent Developer's Guide   

Example Script Entry Points for the FileOnOff Resource

The following example shows entry points written in a shell script.


Note   Note    The actual VCS FileOnOff entry points are written in C++, but for this example, shell script is used.

Online Entry Point for FileOnOff

The FileOnOff example entry point is simple. When the agent's online entry point is called by the agent, the entry point expects the name of the resource as the first argument and the value of PathName attribute as the second argument. It then creates the file in the specified path. For our specific FileOnOff example, the file /tmp/test would be created.


#!/bin/sh
# FileOnOff Online script
# Expects ResourceName and PathName
#
VCSHOME="${VCS_HOME:-/opt/VRTSvcs}"
. $VCSHOME/bin/ag_i18n_inc.sh
RESNAME=$1
VCSAG_SET_ENVS $RESNAME
#check if second attribute provided
if [ -z "$2" ]
then
    VCSAG_LOG_MSG "W" "The value for PathName is not specified"
   1020
else
   #Create the file
   touch $2
fi
exit 0;

# No need for exit code. Shell returns 0 if successful
# and 1 if not. Monitor will be called in either case.
# exit code indicates the number of seconds VCS should wait,
# after online entry point completes, before calling the monitor
# entry point to check the resource state.

Monitor Entry Point for FileOnOff

The example FileOnOff monitor entry point accepts the name of the resource and the same ArgList as the first and second arguments and checks if the file exists. If the file exists it returns exit code 110 for online. If the file does not exist the monitor returns 100 for offline. If the state of the file cannot be determined, the monitor returns 99.


#!/bin/sh
# FileOnOff Monitor script
# Expects Resource Name and Pathname
#
VCSHOME="${VCS_HOME:-/opt/VRTSvcs}"
. $VCSHOME/bin/ag_i18n_inc.sh
RESNAME=$1
VCSAG_SET_ENVS $RESNAME
#check if second attribute provided
#Exit with unknown and log error if not provided.
if [ -z "$2" ]
then
    VCSAG_LOG_MSG "W" "The value for PathName is not specified"
   1020
   exit 99
else
   if [ -f $2 ]; then exit 110;
   # Exit online (110) if file exists
   # Exit offline (100) if file does not exist
   else exit 100;
   fi
fi

Offline Entry Point for FileOnOff

The example FileOnOff offline entry point accepts the name of the resource and the same ArgList attribute values and deletes the file specified by PathName.


#!/bin/sh
# FileOnOff Offline script
# Expects ResourceName and Pathname
#
VCSHOME="${VCS_HOME:-/opt/VRTSvcs}"
. $VCSHOME/bin/ag_i18n_inc.sh
RESNAME=$1
VCSAG_SET_ENVS $RESNAME
#check if second attribute provided
if [ -z "$2" ]
then
    VCSAG_LOG_MSG "W" "The value for PathName is not specified"
   1020
else
#remove the file
   /bin/rm –f $2
fi
exit 0;

# No need for exit code, as shell returns 0 if successful
# and 1 if not. Monitor will be called in either case.
# Similar to online - exit code indicates how long VCS should
# wait, after offline completes, before calling monitor for the
# resource.
 ^ Return to Top Previous  |  Next  >  
Product: Cluster Server Guides  
Manual: Cluster Server 4.1 Agent Developer's Guide  
VERITAS Software Corporation
www.veritas.com