Sun Cluster Data Services Developer's Guide for Solaris OS

Parsing the Function Arguments

The RGM runs all of the callback methods, except Validate, as follows:

method-name -R resource-name -T resource-type-name -G resource-group-name

The method name is the path name of the program that implements the callback method. A data service specifies the path name for each method in the RTR file. These path names are relative to the directory that is specified by the RT_basedir property, also in the RTR file. For example, in the sample data service's RTR file, the base directory and method names are specified as follows:

RT_basedir=/opt/SUNWsample/bin;
Start = dns_svc_start;
Stop =  dns_svc_stop;
...

All callback method arguments are passed as flagged values. The -R argument indicates the name of the resource instance. The -T argument indicates the type of the resource. The -G argument indicates the group into which the resource is configured. See the rt_callbacks(1HA) man page for more information about callback methods.


Note –

The Validate method is called with additional arguments, that is, the property values of the resource and resource group on which it is called. See Handling Property Updates for more information.


Each callback method needs a function to parse the arguments that the function is passed. Because the callbacks are all passed the same arguments, the data service provides a single parse function that is used in all the callbacks in the application.

The following sample shows the parse_args() function that is used for the callback methods in the sample application.

#########################################################################
# Parse program arguments.
#
function parse_args # [args ...]
{
      typeset opt

      while getopts 'R:G:T:' opt
      do
             case "$opt" in
             R)
                  # Name of the DNS resource.
                  RESOURCE_NAME=$OPTARG
                  ;;
             G)
                  # Name of the resource group in which the resource is
                  # configured.
                  RESOURCEGROUP_NAME=$OPTARG
                  ;;
             T)
                  # Name of the resource type.
                  RESOURCETYPE_NAME=$OPTARG
                  ;;
             *)
                  logger -p ${SYSLOG_FACILITY}.err \
                  -t [$RESOURCETYPE_NAME,$RESOURCEGROUP_NAME,$RESOURCE_NAME] \
                  "ERROR: Option $OPTARG unknown"
                  exit 1
                      ;;
             esac
    done
}

Note –

Although the PROBE method in the sample application is user defined (not a Sun Cluster callback method), it is called with the same arguments as the callback methods. Therefore, this method contains a parse function that is identical to the one that is used by the other callback methods.


The parse function is called in MAIN as:

parse_args “$@”