Skip Navigation Links | |
Exit Print View | |
![]() |
Oracle Solaris Cluster Data Services Developer's Guide Oracle Solaris Cluster 4.0 |
1. Overview of Resource Management
3. Resource Management API Reference
6. Data Service Development Library
8. Sample DSDL Resource Type Implementation
9. Oracle Solaris Cluster Agent Builder
12. Cluster Reconfiguration Notification Protocol
A. Sample Data Service Code Listings
Resource Type Registration File Listing
Monitor_start Method Code Listing
Monitor_stop Method Code Listing
Monitor_check Method Code Listing
B. DSDL Sample Resource Type Code Listings
C. Requirements for Non-Cluster-Aware Applications
D. Document Type Definitions for the CRNP
This method verifies the existence of the directory that is pointed to by the Confdir property. The RGM calls this method when the data service is created. The RGM also calls this method when the cluster administrator updates the data service properties. The Monitor_check method calls this method whenever the fault monitor fails over the data service to a new node.
Example A-9 dns_validate Method
#!/bin/ksh # Validate method for HA-DNS. # This method validates the Confdir property of the resource. The Validate # method gets called in two scenarios. When the resource is being created and # when a resource property is getting updated. When the resource is being # created, this method gets called with the -c flag and all the system-defined # and extension properties are passed as command-line arguments. When a resource # property is being updated, the Validate method gets called with the -u flag, # and only the property/value pair of the property being updated is passed as a # command-line argument. # # ex: When the resource is being created command args will be # # dns_validate -c -R <..> -G <...> -T <..> -r <sysdef-prop=value>... # -x <extension-prop=value>.... -g <resourcegroup-prop=value>.... # # when the resource property is being updated # # dns_validate -u -R <..> -G <...> -T <..> -r <sys-prop_being_updated=value> # OR # dns_validate -u -R <..> -G <...> -T <..> -x <extn-prop_being_updated=value> #pragma ident “@(#)dns_validate 1.1 12/01/24 ” ############################################################################### # Parse program arguments. # function parse_args # [args ...] { typeset opt while getopts `cur:x:g:R:T:G:X:' 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 ;; X) # Per-node extension property setting. The format of the # option argument is "propertyname{nodeid}=propertyvalue". # For example, there might be two -X options with the following # arguments: # myprop{1}=myvalue # myprop{2}=othervalue # representing the setting of property 'myprop' on nodes 1 # and 2. If the property value is set in a non-global zone # 'zoneA' of the global cluster, the format is: # myprop{1:zoneA}=myvalue # In most cases, the -X arguments can be ignored. Instead # use the -x argument to get the property setting for the # local node. ;; r) #The method is not accessing any system defined #properties, so this is a no-op. ;; g) # The method is not accessing any resource group # properties, so this is a no-op. ;; c) # Indicates the Validate method is being called while # creating the resource, so this flag is a no-op. ;; u) # Indicates the updating of a property when the # resource already exists. If the update is to the # Confdir property then Confdir should appear in the # command-line arguments. If it does not, the method must # look for it specifically using scha_resource_get. UPDATE_PROPERTY=1 ;; x) # Extension property list. Separate the property and # value pairs using “=” as the separator. PROPERTY=`echo $OPTARG | awk -F= `{print $1}'` VAL=echo $OPTARG | awk -F= `{print $2}'` # If the Confdir extension property is found on the # command line, note its value. if [ $PROPERTY == “Confdir” ]; then CONFDIR=$VAL CONFDIR_FOUND=1 fi ;; *) logger -p ${SYSLOG_FACILITY}.err \ -t [$SYSLOG_TAG] \ “ERROR: Option $OPTARG unknown” exit 1 ;; esac done } ############################################################################### # MAIN # ############################################################################### export PATH=/bin:/usr/bin:/usr/cluster/bin:/usr/sbin:/usr/proc/bin:$PATH # Obtain the syslog facility to use to log messages. SYSLOG_FACILITY=`scha_cluster_get -O SYSLOG_FACILITY` # Set the Value of CONFDIR to null. Later, this method retrieves the value # of the Confdir property from the command line or using scha_resource_get. CONFDIR=”” UPDATE_PROPERTY=0 CONFDIR_FOUND=0 # Parse the arguments that have been passed to this method. parse_args “$@” # If the validate method is being called due to the updating of properties # try to retrieve the value of the Confdir extension property from the command # line. Otherwise, obtain the value of Confdir using scha_resource_get. if ( (( $UPDATE_PROPERTY == 1 )) && (( CONFDIR_FOUND == 0 )) ); then config_info=scha_resource_get -O Extension -R $RESOURCE_NAME \ -G $RESOURCEGROUP_NAME Confdir` CONFDIR=`echo $config_info | awk `{print $2}'` fi # Verify that the Confdir property has a value. If not there is a failure # and exit with status 1. if [[ -z $CONFDIR ]]; then logger -p ${SYSLOG_FACILITY}.err \ “${ARGV0} Validate method for resource “$RESOURCE_NAME “ failed” exit 1 fi # Now validate the actual Confdir property value. # Check if $CONFDIR is accessible. if [ ! -d $CONFDIR ]; then logger -p ${SYSLOG_FACILITY}.err -t [$SYSLOG_TAG] \ “${ARGV0} Directory $CONFDIR missing or not mounted” exit 1 fi # Check that the named.conf file is present in the Confdir directory. if [ ! -s $CONFDIR/named.conf ]; then logger -p ${SYSLOG_FACILITY}.err -t [$SYSLOG_TAG] \ “${ARGV0} File $CONFDIR/named.conf is missing or empty” exit 1 fi # Log a message indicating that the Validate method was successful. logger -p ${SYSLOG_FACILITY}.info -t [$SYSLOG_TAG] \ “${ARGV0} Validate method for resource “$RESOURCE_NAME \ “ completed successfully” exit 0