--- /dev/null Tue Jan 22 20:55:28 2008 +++ new/usr/src/cmd/ha-services/gds-agents/ids/ids_register.ksh Tue Jan 22 20:55:28 2008 @@ -0,0 +1,143 @@ +#!/usr/bin/ksh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the License). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/CDDL.txt +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/CDDL.txt. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets [] replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" +# +# DO NOT EDIT THIS FILE + +IDSDIR=/opt/SUNWscids/ + +typeset opt + +while getopts 'f:' opt +do + case "$opt" in + f) MYCONFIG=${OPTARG};; + *) /usr/bin/echo "ERROR: ${MYNAME} Option ${OPTARG} unknown" + /usr/bin/echo "Usage: ${MYNAME} -f " + exit 1;; + esac +done + +[ -z "${MYCONFIG}" ] && MYCONFIG=/opt/SUNWscids/util/ids_config + +. ${MYCONFIG} + +if [ -z ${RS_ZONE} ] +then + +/usr/cluster/bin/clrs create -g ${RG} -t SUNW.gds \ +-p Start_command="/opt/SUNWscids/bin/control_ids \ +-R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ +-S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' start ids " \ +-p Stop_command="/opt/SUNWscids/bin/control_ids \ +-R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ +-S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' stop ids " \ +-p Probe_command="/opt/SUNWscids/bin/control_ids \ +-R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ +-S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' probe ids " \ +-p Validate_command="/opt/SUNWscids/bin/control_ids \ +-R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \ +-S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' validate ids " \ +-p Port_list=23/tcp -p Stop_signal=9 \ +-y Resource_dependencies=${HAS_RS},${LH_RS} \ +${RS} + +else + # Process a failover zone registration + # + # 1. Validate ${START_TIMEOUT} and ${STOP_TIMEOUT} + # 2. Get the failover zone's pfile and determine failover zone name + # 3. Build a temporary sczsmf_config file + # 4. zlogin to the failover zone execute ids_smf_register + # - Creates the SMF manifest using parameter values + # - Validate and import the SMF manifest into the SMF repository + # 5. Register a SC sczsmf resource to enable/disable the SMF instance + + RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}` + rc=$? + + if [ "${rc}" -eq 0 ] + then + /usr/bin/printf "Sun Cluster resource ${RS} already exists\n" + /usr/bin/printf "Cleanup resource before retrying\n" + exit 1 + fi + + if ! [ "${START_TIMEOUT}" -ge 0 ] 2> /dev/null + then + /usr/bin/printf "START_TIMEOUT value is not an integer\n" + exit 1 + fi + + if ! [ "${STOP_TIMEOUT}" -ge 0 ] 2> /dev/null + then + /usr/bin/printf "STOP_TIMEOUT value is not an integer\n" + exit 1 + fi + + ZONEPFILE=`/usr/cluster/bin/clrs show -p Start_command ${RS_ZONE} | /usr/bin/grep -w Start_command | \ + /usr/bin/awk '{ if ($7 == "-P") print $8 }'` + + if [ ! -d "${ZONEPFILE}" ] + then + /usr/bin/printf "Unable to retrieve zone parameter file directory\n" + exit 1 + else + ZONE=`/usr/bin/grep Zonename= ${ZONEPFILE}/sczbt_${RS_ZONE} | /usr/bin/awk -F= '{print $2}' | /usr/xpg4/bin/tr -d '"' ` + fi + + SERVICE_TAG=svc:/application/sczone-agents:${RS} + + /usr/bin/cat > /var/tmp/${RS}_smf_config <<-EOF +RS=${RS} +RG=${RG} +SCZBT_RS=${RS_ZONE} +ZONE=${ZONE} +SERVICE=${SERVICE_TAG} +RECURSIVE=true +STATE=true +SERVICE_PROBE="/opt/SUNWscids/bin/control_ids probe ids ${SERVICE_TAG}" +EOF + + TMP_WORK_CONFIG=/var/tmp/${RS}_tmp_work_config + /usr/bin/cat ${MYCONFIG} | /usr/sbin/zlogin ${ZONE} /usr/bin/cat - \> ${TMP_WORK_CONFIG} + + # Remove an existing FMRI in the zone if it already exists + ${IDSDIR}/util/ids_smf_remove -z ${ZONE} -f ${SERVICE_TAG} 2>/dev/null + + # Create and register the ${SERVICE_TAG} + if /usr/sbin/zlogin ${ZONE} ${IDSDIR}/util/ids_smf_register ${TMP_WORK_CONFIG} + then + if /opt/SUNWsczone/sczsmf/util/sczsmf_register -f /var/tmp/${RS}_smf_config + then + /usr/bin/printf "Registration of ${RS} succeeded\n" + else + /usr/bin/printf "Registration of ${RS} failed\n" + exit 1 + fi + fi +fi + +exit 0