Home | History | Annotate | Download | only in sczbt
      1 #
      2 # CDDL HEADER START
      3 #
      4 # The contents of this file are subject to the terms of the
      5 # Common Development and Distribution License (the License).
      6 # You may not use this file except in compliance with the License.
      7 #
      8 # You can obtain a copy of the license at usr/src/CDDL.txt
      9 # or http://www.opensolaris.org/os/licensing.
     10 # See the License for the specific language governing permissions
     11 # and limitations under the License.
     12 #
     13 # When distributing Covered Code, include this CDDL HEADER in each
     14 # file and include the License file at usr/src/CDDL.txt.
     15 # If applicable, add the following below this CDDL HEADER, with the
     16 # fields enclosed by brackets [] replaced with your own identifying
     17 # information: Portions Copyright [yyyy] [name of copyright owner]
     18 #
     19 # CDDL HEADER END
     20 #
     21 
     22 #
     23 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     24 # Use is subject to license terms.
     25 #
     26 # ident	"@(#)functions.ksh	1.11	08/04/15 SMI"
     27 #
     28 
     29 # define variables
     30 
     31 validate_options()
     32 {
     33         debug_message "Function: validate_options - Begin"
     34 	${SET_DEBUG}
     35 
     36         #
     37         # Ensure all options are set
     38         #
     39 	rc_validate_options=0
     40 
     41         for i in RESOURCE RESOURCEGROUP PARDIR
     42         do
     43                 case ${i} in
     44                         RESOURCE)
     45                         if [ -z ${RESOURCE} ]; then
     46                                 # SCMSGS
     47                                 # @explanation
     48                                 # The option is not specified in the start,
     49                                 # stop or probe command.
     50                                 # @user_action
     51                                 # Make sure that the appropriate config file
     52                                 # is correct and reregister the resource.
     53                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
     54                                 "Function: validate_options - %s Option %s not set" \
     55                                 "${MYNAME}" "-R"
     56                                 rc_validate_options=1
     57                         fi;;
     58 
     59                         RESOURCEGROUP)
     60                         if [ -z ${RESOURCEGROUP} ]; then
     61                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
     62                                 "Function: validate_options - %s Option %s not set" \
     63                                 "${MYNAME}" "-G"
     64                                 rc_validate_options=1
     65                         fi;;
     66 
     67                         PARDIR)
     68                         if [ -z ${PARDIR} ]; then
     69                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
     70                                 "Function: validate_options - %s Option %s not set" \
     71                                 "${MYNAME}" "-P"
     72                                 rc_validate_options=1
     73 			else
     74 				# construct the variable PARFILE
     75 				PARFILE=${PARDIR}/sczbt_${RESOURCE}
     76                         fi;;
     77 
     78                 esac
     79         done
     80 
     81 	debug_message "Function: validate_options returns ${rc_validate_options} - End"
     82 	return ${rc_validate_options}
     83 }
     84 
     85 validate()
     86 {
     87 	#
     88 	# Validate sczbt
     89 	#
     90 	
     91         debug_message "Function: validate - Begin"
     92 	${SET_DEBUG}
     93 
     94 	rc_validate=0
     95 
     96         #
     97         # Validate that prameter file exists and is syntactically correct
     98         #
     99 
    100 	if ! val_parfile ${PARFILE} "Zonename Zonebootopt Milestone" ${PARDIR}
    101 	then
    102 		debug_message "Function: validate - End"
    103 		rc_validate=1
    104 		return ${rc_validate}
    105 	fi
    106 
    107        # test the semantic of the parameters
    108 
    109        . ${PARFILE}
    110 
    111 	for i in `/bin/cat ${PARFILE} | /bin/grep -v "^#"| /bin/grep -v "^ "| /bin/nawk -F= '{print $1}'`
    112         do
    113                 case ${i} in
    114 
    115                         Zonename)
    116 			
    117 			# test the Zonename
    118 
    119 			# is the zone name specified
    120 
    121 			if [ -z ${Zonename} ]; then
    122                                 # SCMSGS
    123                                 # @explanation
    124                                 # The variable Zonename does not contain a
    125                                 # value.
    126                                 # @user_action
    127                                 # Review the components configuration file and
    128 				# make sure the variable Zonename is properly
    129 				# defined.
    130                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
    131                                   "Function: validate - Zone name not set in %s" \
    132                                   "${PARFILE}"
    133                 		rc_validate=1
    134 			else
    135 				debug_message "Function: validate - Zone name (${Zonename}) set"
    136 			fi
    137 
    138 			# is the current zone state valid 
    139 
    140 			get_zone_state ${Zonename}
    141 
    142 			if [ "${ZONE_STATE}" = "installed" -o "${ZONE_STATE}" = "ready" -o "${ZONE_STATE}" = "running" ]
    143 			then
    144 				debug_message "Function: validate - ${Zonename} state is ${ZONE_STATE}"
    145 			else
    146                                 # SCMSGS
    147                                 # @explanation
    148                                 # The referenced zone is not in the state
    149                                 # installed, ready or running.
    150                                 # @user_action
    151                                 # Make sure that the referenced zone name is
    152                                 # configured properly. Check if you have done
    153                                 # a zlogin -C. Make sure that the name in the
    154                                 # appropriate config file is correct.
    155                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
    156                                   "Function: validate - %s state is %s" \
    157                                   "${Zonename}" "${ZONE_STATE}"
    158                 		rc_validate=1
    159 			fi
    160 
    161 			# is the autobooot set to false
    162 
    163 			if ! ${ZONECFG} -z ${Zonename} info | /bin/grep autoboot| /bin/grep false >/dev/null 2>&1
    164 			then
    165                                 # SCMSGS
    166                                 # @explanation
    167                                 # The referenced zone is configured with
    168                                 # autoboot = true. This option needs to be
    169                                 # set to false.
    170                                 # @user_action
    171                                 # Configure the autoboot variable of the
    172                                 # configured zone to false. You need to run
    173                                 # the zoncfg command to complete this task.
    174                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
    175                                   "Function: validate - %s configured with autoboot true, it needs to be false" \
    176                                   "${Zonename}"
    177                 		rc_validate=1
    178 			else
    179 				debug_message "Function: validate - ${Zonename} configured with autoboot false"
    180                         fi;;
    181 
    182 			Zonebrand)
    183 
    184 			# verify supported zone brand
    185 
    186 			case ${Zonebrand} in
    187 				native)
    188 					debug_message "Function: validate - Zonebrand configured as ${Zonebrand}"
    189 					ZONE_BRAND=`${ZONECFG} -z ${Zonename} info | /bin/grep "^brand:" | /bin/awk '{print $2}'`
    190 					if [ -n "${ZONE_BRAND}" ]; then
    191 						if [ "${ZONE_BRAND}" = "native" ]; then
    192 							debug_message "Function: validate - Zonebrand verified as being ${ZONE_BRAND}"
    193 						else
    194 							# SCMSGS
    195 							# @explanation
    196 							# Zonebrand is set to
    197 							# "native". But the
    198 							# Zone is configured
    199 							# as a different brand
    200 							# type (i.e. lx)
    201 							# according to zonecfg
    202 							# info.
    203 							# @user_action
    204 							# Review the components
    205 							# configuration file and
    206 							# make sure the variable
    207 							# Zonebrand defines the
    208 							# actual zone brand
    209 							# type for the Zone.
    210 							scds_syslog -p daemon.err \
    211 							  -t $(syslog_tag) -m \
    212 							  "Function: validate - Zonebrand for zone %s is configured as native, but the zone is configured as brand type %s." \
    213 							  "${Zonename}" "${ZONE_BRAND}"
    214 							rc_validate=1
    215 						fi
    216 					fi;;
    217 
    218 				lx)
    219 					debug_message "Function: validate - Zonebrand configured as ${Zonebrand}"
    220 					if [ "`/usr/bin/uname -p`" != "i386" ]; then
    221 							# SCMSGS
    222 							# @explanation
    223 							# The lx brand for zones
    224 							# is only supported on
    225 							# the i386 platform.
    226 							# @user_action
    227 							# Review the components
    228 							# configuration file and
    229 							# make sure the variable
    230 							# Zonebrand defines "lx"
    231 							# only on a i386 system.
    232 							scds_syslog -p daemon.err \
    233 							  -t $(syslog_tag) -m \
    234 							  "Function: validate - Zonebrand for zone %s is configured as %s on a non-i386 system. It is only supported on i386 systems." \
    235 							  "${Zonename}" "${Zonebrand}"
    236 							rc_validate=1
    237 					else
    238 						ZONE_BRAND=`${ZONECFG} -z ${Zonename} info | /bin/grep "^brand:" | /bin/awk '{print $2}'`
    239 						if [ "${ZONE_BRAND}" = "lx" ]; then
    240 							debug_message "Function: validate - Zonebrand verified as being ${ZONE_BRAND}"
    241 						else
    242 							# SCMSGS
    243 							# @explanation
    244 							# Zonebrand is set to
    245 							# "lx". But the
    246 							# Zone is not configured
    247 							# as brand type lx
    248 							# according to zonecfg
    249 							# info.
    250 							# @user_action
    251 							# Review the components
    252 							# configuration file and
    253 							# make sure the variable
    254 							# Zonebrand defines "lx"
    255 							# only for a Zone that
    256 							# got really setup with
    257 							# brand type "lx".
    258 							scds_syslog -p daemon.err \
    259 							  -t $(syslog_tag) -m \
    260 							  "Function: validate - Zonebrand for zone %s is configured as lx, but the zone is configured as brand type %s." \
    261 							  "${Zonename}" "${ZONE_BRAND}"
    262 							rc_validate=1
    263 						fi
    264 					fi;;
    265 
    266 				solaris8|solaris9)
    267 					debug_message "Function: validate - Zonebrand configured as ${Zonebrand}"
    268 					if [ "`/usr/bin/uname -p`" != "sparc" ]; then
    269 							# SCMSGS
    270 							# @explanation
    271 							# The solaris8 and
    272 							# solaris9 brand for
    273 							# zones is only
    274 							# supported on the
    275 							# sparc platform.
    276 							# @user_action
    277 							# Review the components
    278 							# configuration file and
    279 							# make sure the variable
    280 							# Zonebrand defines
    281 							# "solaris8" or
    282 							# "solaris9" only on a
    283 							# sparc system.
    284 							scds_syslog -p daemon.err \
    285 							  -t $(syslog_tag) -m \
    286 							  "Function: validate - Zonebrand for zone %s is configured as %s on a non-sparc system. It is only supported on sparc systems." \
    287 							  "${Zonename}" "${Zonebrand}"
    288 							rc_validate=1
    289 					else
    290 						ZONE_BRAND=`${ZONECFG} -z ${Zonename} info | /bin/grep "^brand:" | /bin/awk '{print $2}'`
    291 						if [ "${ZONE_BRAND}" = "${Zonebrand}" ]; then
    292 							debug_message "Function: validate - Zonebrand verified as being ${ZONE_BRAND}"
    293 						else
    294 							# SCMSGS
    295 							# @explanation
    296 							# Zonebrand is set to
    297 							# "solaris8" or
    298 							# "solaris9". But the
    299 							# Zone is not configured
    300 							# as brand type solaris8
    301 							# or solaris9
    302 							# according to zonecfg
    303 							# info.
    304 							# @user_action
    305 							# Review the components
    306 							# configuration file and
    307 							# make sure the variable
    308 							# Zonebrand defines
    309 							# "solaris8" or
    310 							# "solaris9" only for a
    311 							# Zone that got really
    312 							# setup with brand type
    313 							# "solaris8" or
    314 							# "solaris9".
    315 							scds_syslog -p daemon.err \
    316 							  -t $(syslog_tag) -m \
    317 							  "Function: validate - Zonebrand for zone %s is configured as %s, but the zone is configured as brand type %s." \
    318 							  "${Zonename}" "${Zonebrand}" "${ZONE_BRAND}"
    319 							rc_validate=1
    320 						fi
    321 					fi;;
    322 
    323 				*)
    324 						# SCMSGS
    325 						# @explanation
    326 						# Currently Zonebrand can only
    327 						# be set to "native", "lx" or
    328 						# "solaris8".
    329 						# @user_action
    330 						# Review the components
    331 						# configuration file and make
    332 						# sure the variable Zonebrand
    333 						# defines either "native", "lx"
    334 						# or "solaris8".
    335 						scds_syslog -p daemon.err \
    336 						  -t $(syslog_tag) -m \
    337 						  "Function: validate - Zonebrand for zone %s is configured as %s. Valid values are native, lx, solaris8 and solaris9." \
    338 						  "${Zonename}" "${Zonebrand}"
    339 						rc_validate=1;;
    340 			esac;;
    341 
    342                         Zonebootopt)
    343 
    344 			# test the Zones boot options
    345 
    346 			# is the Zone boot option specified and a supported one
    347 
    348 			if [ ! -z ${Zonebootopt} ] && [ "${Zonebootopt}" != "-s" ]; then
    349 
    350 	                        # SCMSGS
    351 	                        # @explanation
    352 	                        # The specified boot option is not allowed.
    353 	                        # @user_action
    354 	                        # Consult the manpage of zoneadm which boot
    355 	                        # options are allowed and specify one of
    356 	                        # them.
    357 	                        scds_syslog -p daemon.err -t $(syslog_tag) -m \
    358 	                          "Function: validate - %s invalid boot option [%s]" \
    359 	                          "${Zonename}" "${Zonebootopt}"
    360 	                	rc_validate=1
    361 			else
    362 				debug_message "Function: validate - ${Zonename} boot option (${Zonebootopt})"
    363                         fi;;
    364 
    365                         Milestone)
    366 
    367 			# test the smf service which indicate that the zone is online
    368 
    369 			# is the Milestone specified
    370 
    371 			if [ -z ${Milestone} ]; then
    372                                 # SCMSGS
    373                                 # @explanation
    374                                 # The Milestone variable is not set in the
    375                                 # parameter file sczbt_<resource name>.
    376                                 # @user_action
    377                                 # Set the Milestone variable in the parameter
    378                                 # file sczbt_<resource name>.
    379                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
    380                                   "Function: validate - Milestone not set in %s" \
    381                                   "${PARFILE}"
    382                 		rc_validate=1
    383 			else
    384 				debug_message "Function: validate - Milestone (${Milestone}) set"
    385 			fi;;
    386 
    387 			LXrunlevel)
    388 
    389 			# verify that LXrunlevel is setup if Zonebrand="lx"
    390 
    391 			if [ -z "${LXrunlevel}" ] && [ "${Zonebrand}" = "lx" ]; then
    392 				# SCMSGS
    393 				# @explanation
    394                                 # The LXrunlevel variable is not set in the
    395                                 # parameter file sczbt_<resource name>.
    396                                 # @user_action
    397                                 # Set the LXrunlevel variable in the parameter
    398                                 # file sczbt_<resource name>.
    399                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
    400                                   "Function: validate - LXrunlevel not set in %s" \
    401                                   "${PARFILE}"
    402                 		rc_validate=1
    403 			else
    404 				debug_message "Function: validate - LXrunlevel (${LXrunlevel}) set"
    405 			fi;;
    406 
    407 			SLrunlevel)
    408 
    409 			# verify that SLrunlevel is setup if Zonebrand is set
    410 			# to "solaris8" or "solaris9"
    411 
    412 			if [ -z "${SLrunlevel}" ] && [ "${Zonebrand}" = "solaris8" -o "${Zonebrand}" = "solaris9" ]; then
    413 				# SCMSGS
    414 				# @explanation
    415                                 # The SLrunlevel variable is not set in the
    416                                 # parameter file sczbt_<resource name>.
    417                                 # @user_action
    418                                 # Set the SLrunlevel variable in the parameter
    419                                 # file sczbt_<resource name>.
    420                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
    421                                   "Function: validate - SLrunlevel not set in %s" \
    422                                   "${PARFILE}"
    423                 		rc_validate=1
    424 			else
    425 				debug_message "Function: validate - SLrunlevel (${SLrunlevel}) set"
    426 			fi;;
    427 
    428 		esac
    429 	done
    430 
    431 	# validates the Zonepath
    432 
    433 	# get the zone path
    434 
    435 	get_zonepath ${Zonename}
    436 
    437 	# is the Zonepath a directory
    438 
    439 	if [ ! -d ${Zonepath} ]; then
    440                 # SCMSGS
    441                 # @explanation
    442                 # The zone path extracted from the zones configuration is not
    443                 # present or not a directory.
    444                 # @user_action
    445                 # Make sure that the filesystem for the zone path is mounted.
    446                 # Consider using a SUNW.HAStoragePlus resource. If already used,
    447 		# check if the resource dependency to it is in place.
    448                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
    449                   "Function: validate - Zonepath %s needs to be a directory" \
    450                   "${Zonepath}" 
    451                 rc_validate=1
    452 	else
    453 		debug_message "Function: validate - Zonepath ${Zonepath} is a directory"
    454 	fi
    455 
    456 	# Validate that we are in the global zone
    457 
    458 	val_in_global
    459 	if [ ${?} -ne 0 ]; then
    460 		rc_validate=1
    461 	fi 
    462 
    463 	# Get list of configured SUNW.LogicalHostname resources
    464 	LH_LIST=`${SCHA_RESOURCE_GET} -O NETWORK_RESOURCES_USED -R ${RESOURCE} -G ${RESOURCEGROUP}`
    465 
    466 	# Check if ip-type=exclusive is set for the Zone. In that case
    467 	# ${LH_LIST} must be empty, since assigning an IP by setting the zone
    468 	# flag to the Zone does only work if ip-type=shared.
    469 	IPTYPE=`${ZONECFG} -z ${Zonename} info | /bin/grep "^ip-type:" | /bin/awk '{print $2}'`
    470 
    471 	if [ "${IPTYPE}" = "exclusive" ] && [ -n "${LH_LIST}" ]
    472 	then
    473 		# SCMSGS
    474 		# @explanation
    475 		# The configured non-global zone has set ip-type=exclusive
    476 		# within its zone config, and the resource was configured
    477 		# to depend on a SUNW.LogicalHostname resource. It is not
    478 		# possible to assign the IP address from this
    479 		# SUNW.LogicalHostname resource for the non-global zone if
    480 		# ip-type=exclusive is set.
    481 		# @user_action
    482 		# Either set ip-type=shared for the non-global zone config,
    483 		# or remove the dependency to the SUNW.LogicalHostname resource.
    484 		scds_syslog -p daemon.err -t $(syslog_tag) -m \
    485 			"Function: validate - Zone %s is configured with ip-type=exclusive, and the sczbt resource is dependand on a SUNW.LogicalHostname resource. This combination does not work." \
    486 			"${Zonename}"
    487 		rc_validate=1
    488 	fi
    489 
    490 	# Check if any IPMP_HOST_IP has been configured with the Zone
    491 
    492 	for LH in ${LH_LIST}
    493 	do
    494 		get_ipmp_state ${LH}
    495 
    496 		# Test if the IPMP_HOST_IP has been configured within the Zone
    497 	
    498 		ZONE_NET_INFO=/tmp/${RESOURCE}_zoneinfo.txt
    499 
    500 		echo info net | ${ZONECFG} -z ${Zonename} > ${ZONE_NET_INFO}
    501 
    502 		for j in ${IPMP_HOST_IP}
    503 		do
    504 			for i in `/bin/grep address ${ZONE_NET_INFO} | /bin/awk '{print $2}' | /bin/awk -F/ '{print $1}'`
    505 			do
    506 				if [ "${i}" = "${j}" ]
    507 				then
    508 					# SCMSGS
    509 					# @explanation
    510 					# There is an IP address conflict
    511 					# between the SUNW.LogicalHostname
    512 					# resource and the configured zone.
    513 					# @user_action
    514 					# Remove the IP address from the zones
    515 					# configuration with the zonecfg
    516 					# command.
    517 					scds_syslog -p daemon.err -t $(syslog_tag) -m \
    518        			  	  	  "Function: validate - %s configured with address %s, please remove the address using zonecfg" \
    519 			  	  	  "${Zonename}" "${j}" 
    520 					rc_validate=1
    521 				fi
    522 			done
    523 		done
    524 
    525 		# Test if the IPMP_HOST has been configured within the Zone
    526 
    527 		for j in ${IPMP_HOST}
    528 		do
    529 			for i in `/bin/grep address ${ZONE_NET_INFO} | /bin/awk '{print $2}' | /bin/awk -F/ '{print $1}'`
    530 			do
    531 				if [ "${i}" = "${j}" ]
    532 				then
    533 					scds_syslog -p daemon.err -t $(syslog_tag) -m \
    534        			  	  	  "Function: validate - %s configured with address %s, please remove the address using zonecfg" \
    535 			  	  	  "${Zonename}" "${j}" 
    536 					rc_validate=1
    537 				fi
    538 			done
    539 		done
    540 
    541 		# Test if another zone is already using this IPMP_HOST_IP
    542 
    543 		for ADAPTER in ${ADAPTER_LIST}
    544 		do
    545 			for i in `${IFCONFIG} -a | /bin/grep ${ADAPTER} | /bin/awk -F: '{print $2}' | /bin/grep -v flags`
    546 			do
    547 				IPMP_ADAPTER_IP=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w inet | /bin/awk '{print $2}'`
    548 
    549 				for j in ${IPMP_HOST_IP}
    550 				do
    551 					if [ "${IPMP_ADAPTER_IP}" = "${j}" ]
    552 					then
    553 						if ${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w zone > /dev/null
    554 						then
    555 							ZONE_ADAPTER=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w zone | /bin/awk '{print $2}'`
    556 	
    557 							# SCMSGS
    558 							# @explanation
    559 							# The logical host is
    560 							# used in another zone
    561 							# already. A logical
    562 							# host can not be used
    563 							# in two zones at the
    564 							# same time.
    565 							# @user_action
    566 							# Resolve the
    567 							# conflicting IP address
    568 							# configuration for
    569 							# your zones.
    570 							scds_syslog -p daemon.err -t $(syslog_tag) -m \
    571 							  "Function: validate - %s (%s) already in use on %s:%s for %s, please resolve this conflict" \
    572 							  "${LH}" "${j}" "${ADAPTER}" "${i}" "${ZONE_ADAPTER}"
    573 							rc_validate=1
    574 						fi
    575 					fi
    576 				done
    577 			done
    578 		done
    579 	done
    580 
    581 	# Check Zonebootopt="-s" has Milestone=single-user
    582 	
    583 	if [ "${Zonebootopt}" = "-s" ] 
    584 	then
    585 		case ${Zonebrand} in
    586 		   native)
    587 			if ! echo ${Milestone} | /bin/grep single-user > /dev/null
    588 			then
    589 				# SCMSGS
    590 				# @explanation
    591 				# The Zoneboot variable is set to -s. Every
    592 				# milestone other than single-user is invalid.
    593 				# @user_action
    594 				# Correct the milestone in the paramter file
    595 				# sczbt_<resource name>. You need to specify
    596 				# single user together with the boot option -s.
    597 				scds_syslog -p daemon.err -t $(syslog_tag) -m \
    598 				  "Function: validate - Milestone (%s) is invalid with Zonebootopt=%s, needs single-user" \
    599 				  "${Milestone}" "${Zonebootopt}"
    600 				rc_validate=1
    601 			fi;;
    602 
    603 		   lx)
    604 			if [ "${LXrunlevel}" != "unknown" ]
    605 			then
    606 				# SCMSGS
    607 				# @explanation
    608 				# The Zoneboot variable is set to -s. Every
    609 				# LXrunlevel other than "unknown" is invalid.
    610 				# @user_action
    611 				# Correct the LXrunlevel variable in the
    612 				# paramter file sczbt_<resource name>. You need
    613 				# to specify "unknown" together with the boot
    614 				# option -s.
    615 				scds_syslog -p daemon.err -t $(syslog_tag) -m \
    616 				  "Function: validate - LXrunlevel (%s) is invalid with Zonebootopt=%s, needs single-user" \
    617 				  "${LXrunlevel}" "${Zonebootopt}"
    618 				rc_validate=1
    619 			fi;;
    620 
    621 		   solaris8|solaris9)
    622 			if [ "${SLrunlevel}" != "S" ]
    623 			then
    624 				# SCMSGS
    625 				# @explanation
    626 				# The Zoneboot variable is set to -s. Every
    627 				# SLrunlevel other than "S" is invalid.
    628 				# @user_action
    629 				# Correct the SLrunlevel variable in the
    630 				# paramter file sczbt_<resource name>. You need
    631 				# to specify "S" together with the boot
    632 				# option -s.
    633 				scds_syslog -p daemon.err -t $(syslog_tag) -m \
    634 				  "Function: validate - SLrunlevel (%s) is invalid with Zonebootopt=%s, needs single-user" \
    635 				  "${SLrunlevel}" "${Zonebootopt}"
    636 				rc_validate=1
    637 			fi;;
    638 
    639 		esac
    640 	fi
    641 
    642 	# Check that lofs is not excluded, first check if an exclude lofs in in /etc/system
    643 
    644 	if /bin/grep -w exclude /etc/system | /bin/grep lofs >/dev/null 2>&1
    645 	then
    646 	
    647 	# if yes check if it is commented out
    648 
    649 		if ! /bin/grep -w exclude /etc/system |/bin/grep lofs | /bin/egrep "^\*|^ +\*|^#|^ +|	+#|^	+\*" >/dev/null 2>&1
    650 		then
    651    			# SCMSGS
    652    			# @explanation
    653    			# The kernel module for the lofs filesystem is still
    654 			# excluded in /etc/system.
    655    			# @user_action
    656    			# Place a &star; in front of the exlude: lofs line and
    657    			# reboot the node.
    658    			scds_syslog -p daemon.err -t $(syslog_tag) -m \
    659 			  "Function: validate - exclude: lofs found in /etc/system" 
    660 			rc_validate=1
    661 		else
    662 			debug_message "Function: validate - exclude: lofs commented out in /etc/system"
    663 		fi
    664 	else
    665 		debug_message "Function: validate - No exclude: lofs found in /etc/system"
    666 	fi
    667 
    668 	if [ -n "${Mounts}" ]
    669 	then
    670 		for i in ${Mounts}
    671 		do
    672 			directory=
    673 			localdir=
    674 
    675 			if echo ${i} | /bin/grep : >/dev/null 2>&1
    676 			then
    677 				echo ${i} | /bin/awk -F: '{ print NF,$1,$2 }' | read field_count val1 val2
    678 
    679 				case ${field_count} in
    680 					2)	# Support <global zone directory>:<local zone directory>
    681 					  	# Support <global zone directory>:<mount options>
    682 					  	directory=${val1}
    683 
    684 						if echo ${val2} | /bin/grep / > /dev/null 2>&1
    685 						then
    686 							localdir=${Zonepath}/root${val2}
    687 						else
    688 							localdir=${Zonepath}/root${val1}
    689 						fi
    690 						;;
    691 					3)	# Support <global zone directory>:<local zone directory>:<mount options>
    692 					  	# Support <global zone directory>:<local zone directory>:
    693 						directory=${val1}
    694 						localdir=${Zonepath}/root${val2}
    695 						;;
    696 					*)	scds_syslog -p daemon.err -t $(syslog_tag) -m \
    697 						   "Function: validate - Mounts=%s is invalid" 
    698 						   "${Mounts}"
    699 						rc_validate=1
    700 						;;
    701 				esac
    702 			else
    703 				# Support just <global zone directory> without any further entries
    704 				directory=${i}
    705 				localdir=${Zonepath}/root${i}
    706 			fi
    707 
    708 			if [ ! -d ${directory} ]
    709 			then
    710 	   			# SCMSGS
    711 	   			# @explanation
    712 	   			# The directory used as a mountpoint in the
    713 	   			# global zone is missing.
    714 	   			# @user_action
    715 	   			# Create the mountpoint in the global zone.
    716 	   			scds_syslog -p daemon.err -t $(syslog_tag) -m \
    717 				  "Function: validate - Global zones mountpoint %s does not exist" \
    718 				  "${directory}"
    719 				rc_validate=1
    720 			else
    721 				debug_message "Function: validate - mountpoint ${directory} exists in the global zone"
    722 			fi
    723 	
    724 			if [ ! -d ${localdir} ]
    725 			then
    726 	   			# SCMSGS
    727 	   			# @explanation
    728 	   			# The directory used as a mountpoint in the
    729 	   			# non-global zone is missing.
    730 	   			# @user_action
    731 	   			# Create the mountpoint in the non-global zone.
    732 	   			scds_syslog -p daemon.err -t $(syslog_tag) -m \
    733 				  "Function: validate - Non-global zones mountpoint %s does not exist" \
    734 				  "${localdir}"
    735 				rc_validate=1
    736 			else
    737 				debug_message "Function: validate - mountpoint ${localdir} exists in the non-global zone"
    738 			fi
    739 	
    740 		done
    741 	fi
    742 
    743 	debug_message "Function: validate - End"
    744 	return ${rc_validate}
    745 }
    746 
    747 lofs_mounts()
    748 {
    749         debug_message "Function: lofs_mount - Begin"
    750 	${SET_DEBUG}
    751 
    752 	lofs_mounts_rc=0
    753 
    754 	if [ "${Zonebrand}" = "native" ]; then
    755 		# wait until svc:/system/filesystem/minimal:default gets online
    756 		get_svc_state ${Zonename} svc:/system/filesystem/minimal:default
    757 
    758 		while [ "${SVC_STATE}" != "online" ]
    759 		do
    760 			debug_message "wait until svc:/system/filesystem/minimal:default gets online in zone ${Zonename}"
    761 			sleep 2
    762 			get_svc_state ${Zonename} svc:/system/filesystem/minimal:default
    763 		done
    764 	fi
    765 
    766 	# start with the mounts
    767 
    768 	get_zonepath ${Zonename}
    769 
    770 	for i in ${Mounts}
    771 	do
    772 		source=
    773 		target=
    774 		mountopt=
    775 
    776 		if echo ${i} | /bin/grep : >/dev/null 2>&1
    777 		then
    778 			echo ${i} | /bin/awk -F: '{ print NF,$1,$2,$3 }' | read field_count val1 val2 val3
    779 
    780 			case ${field_count} in
    781 				2)	# Support <global zone directory>:<local zone directory>
    782 				  	# Support <global zone directory>:<mount options>
    783 				  	source=${val1}
    784 
    785 					if echo ${val2} | /bin/grep / > /dev/null 2>&1
    786 					then
    787 						target=${Zonepath}/root${val2}
    788 					else
    789 						target=${Zonepath}/root${val1}
    790 						[ ${val2} ] && mountopt="-o ${val2}"
    791 					fi
    792 					;;
    793 				3)	# Support <global zone directory>:<local zone directory>:<mount options>
    794 				  	# Support <global zone directory>:<local zone directory>:
    795 					source=${val1}
    796 					target=${Zonepath}/root${val2}
    797 					[ ${val3} ] && mountopt="-o ${val3}"
    798 					;;
    799 				*)	scds_syslog -p daemon.err -t $(syslog_tag) -m \
    800 					   "Function: validate - Mounts=%s is invalid" 
    801 					   "${Mounts}"
    802 					;;
    803 			esac
    804 		else
    805 			# Support just <global zone directory> without any further entries
    806 			source=${i}
    807 			target=${Zonepath}/root${i}
    808 		fi
    809 
    810 		debug_message "Function: lofs_mounts - will mount ${source} to ${target} with the options ${mountopt}"
    811 
    812 		if /usr/sbin/mount -F lofs ${mountopt} ${source} ${target} >>${LOGFILE} 2>&1
    813 		then 
    814 	   		# SCMSGS
    815 	   		# @explanation
    816 	   		# The mount of the directory into the root path of the
    817 	   		# non-global zone was successful.
    818 	   		# @user_action
    819 	   		# None.
    820 	   		scds_syslog -p daemon.notice -t $(syslog_tag) -m \
    821 			  "Function: lofsmount - Non-global zones mount from %s to %s with options %s successful" \
    822 			  "${source}" "${target}" "${mountopt}"
    823 		else
    824 	   		# SCMSGS
    825 	   		# @explanation
    826 	   		# The mount of the directory into the root path of the
    827 	   		# non-global zone failed.
    828 	   		# @user_action
    829 	   		# Watch the verbose error message in the zones start
    830 	   		# messages and fix the issue with appropriate methods.
    831 	   		scds_syslog -p daemon.err -t $(syslog_tag) -m \
    832 			  "Function: lofsmount - Non-global zones mount from %s to %s with options %s failed" \
    833 			  "${source}" "${target}" "${mountopt}"
    834 			lofs_mount_rc=1
    835 		fi
    836 	done
    837 	
    838         debug_message "Function: lofs_mount - End"
    839 	return ${lofs_mount_rc}
    840 }
    841 
    842 get_zonepath()
    843 {
    844         debug_message "Function: get_zonepath - Begin"
    845 	${SET_DEBUG}
    846 
    847 	myzone=${1}
    848 	Zonepath=`${ZONECFG} -z ${myzone} info | /bin/grep ^zonepath: | /bin/awk '{print $2}'`
    849 
    850         debug_message "Function: zonepath - End"
    851 }
    852 
    853 get_ipmp_hosts()
    854 {
    855         debug_message "Function: get_ipmp_hosts - Begin"
    856 	${SET_DEBUG}
    857 
    858 	LH=$1
    859 
    860 	IPMP_HOST=`${SCHA_RESOURCE_GET} -O Extension -R ${LH} -G ${RESOURCEGROUP} HostnameList | /bin/tail +2`
    861 	IPMP_HOST_IP=`/bin/getent hosts ${IPMP_HOST} | /bin/awk '{print $1}'`
    862 
    863         debug_message "Function: get_ipmp_hosts - End"
    864 }
    865 
    866 get_ipmp_state()
    867 {
    868 	# Retreive IPMP information for each Network_resources_used entry
    869 
    870         debug_message "Function: get_ipmp_state - Begin"
    871 	${SET_DEBUG}
    872 
    873 	LH=$1
    874 
    875 	get_ipmp_hosts ${LH}
    876 
    877 	NODEID=`${CLINFO} -n`
    878 	
    879 	# Get the correct IPMP group, i.e. <IPMP>@${NODEID}
    880 
    881 	IPMP_LIST=`${SCHA_RESOURCE_GET} -O Extension -R ${LH} -G ${RESOURCEGROUP} NetIfList | /bin/tail +2`
    882 
    883 	for i in ${IPMP_LIST}
    884 	do
    885 		if [ `echo ${i} | /bin/awk -F@ '{print $2}'` -eq "${NODEID}" ]
    886 		then
    887 			IPMP_GROUP=`echo ${i} | /bin/awk -F@ '{print $1}'`
    888 		fi
    889 	done
    890 		
    891 	# Get the Online IPMP adapter list for that IPMP Group
    892 
    893 	LOCALNODENAME=`${SCHA_CLUSTER_GET} -O NODENAME_LOCAL`
    894 
    895 	ADAPTER_LIST=`/bin/env LC_ALL=POSIX ${SCSTAT} -i -h ${LOCALNODENAME} | /bin/grep " ${IPMP_GROUP} " | /bin/grep Online | /bin/awk '{print $6}'`
    896 
    897         debug_message "Function: get_ipmp_state - End"
    898 }
    899 
    900 start_sczbt()
    901 {
    902 	#
    903 	# Start sczbt
    904 	#
    905 
    906         debug_message "Function: start_sczbt - Begin"
    907 	${SET_DEBUG}
    908 
    909 	# If the zone is of brand type "solaris8" or "solaris9" and if the
    910 	# platform changed from where the zone was previously started,
    911 	# the s8_p2v or s9_p2v script needs to get called prior boot to make
    912 	# sure that any platform specific libraries are properly setup within
    913 	# the zone rootpath.
    914 	# The script needs to run only once per new platform. The file
    915 	# .platform.orig stores the platform names for which the s8_p2v or
    916 	# s9_p2v script had already run. Only if a new platform gets introduced
    917 	# into the cluster, the s8_p2v or s9_p2v script gets called on that
    918 	# node again.
    919 	if [ "${Zonebrand}" = "solaris8" -o "${Zonebrand}" = "solaris9" ]; then
    920 
    921 		case ${Zonebrand} in
    922 			solaris8)
    923 				P2V_SCRIPT=/usr/lib/brand/solaris8/s8_p2v
    924 				;;
    925 			solaris9)
    926 				P2V_SCRIPT=/usr/lib/brand/solaris9/s9_p2v
    927 				;;
    928 		esac
    929 
    930 		get_zonepath ${Zonename}
    931 
    932 		myplatform=`/bin/uname -i`
    933 		myplatformfile=${Zonepath}/root/.platform.orig
    934 		need_p2v=true
    935 
    936 		# if there is no .platform.orig file or if the current
    937 		# platform is not contained, s8_p2v needs to run
    938 		if [ -f ${myplatformfile} ]; then
    939 
    940 			if /usr/bin/grep "^${myplatform}$" ${myplatformfile} > /dev/null 2>&1
    941 			then
    942 				need_p2v=false
    943 			fi
    944 		fi
    945 		
    946 		if [ -x "${P2V_SCRIPT}" -a "${need_p2v}" = "true" ]; then
    947 			${P2V_SCRIPT} ${Zonename} >${LOGFILE} 2>&1
    948 			if [ $? -ne 0 ]; then
    949 				# SCMSGS
    950 				# @explanation
    951 				# Unable to perform platform specific
    952 				# setup for the solaris8 or solaris9 zone.
    953 				# @user_action
    954 				# Disable the resource and manually run
    955 				# '/usr/lib/brand/solaris8/s8_p2v 
    956 				# <zonename>' for solaris8 or
    957 				# '/usr/lib/brand/solaris9/s9_p2v <zonename>'
    958 				# for solaris9 on the node where the start
    959 				# failed. Correct any errors reported, then
    960 				# restart the resource.
    961 				scds_syslog -p daemon.err -t $(syslog_tag) -m \
    962 					"Function: start_sczbt - Running command %s %s failed. Unable to start zone." \
    963 					"${P2V_SCRIPT}" "${Zonename}"
    964 				rc_start_command=1
    965 				return 1
    966 			fi
    967 
    968 			# Only update the file if it is not a symbolic link.
    969 			# Otherwise it would be a security issue.
    970 			if [ ! -h ${myplatformfile} ]; then
    971 				# Add platform to the .platform.orig file
    972 				echo ${myplatform} >> ${myplatformfile}
    973 			fi
    974 		fi
    975 
    976 		# Only update the file if it is not a symbolic link.
    977 		# Otherwise it would be a security issue.
    978 		if [ ! -h ${Zonepath}/root/.host.orig ]; then
    979 			# This update is necessary to make sure the
    980 			# solaris8 or solaris9 zone can get booted without
    981 			# manual intervention.
    982 			/usr/bin/hostid > ${Zonepath}/root/.host.orig
    983 		fi
    984 	fi
    985 
    986 	# boot the zone
    987 	${ZONEADM} -z ${Zonename} boot ${Zonebootopt} >>${LOGFILE} 2>&1
    988 
    989 	rc_start_command=${?}
    990 
    991         # disable the pmf tag and run a sleep in the background, to assure, that there will be a valid pmftag during the start phase
    992 
    993         START_TIMEOUT=`${SCHA_RESOURCE_GET} -O START_TIMEOUT -R ${RESOURCE} -G ${RESOURCEGROUP}`
    994         sleep ${START_TIMEOUT} &
    995 
    996         ${PMFADM} -s ${RESOURCEGROUP},${RESOURCE},0.svc
    997 
    998 	# mount the requested loopbakcmount to the local zone
    999 
   1000 	if ! lofs_mounts
   1001 	then
   1002 		rc_start_command=1
   1003 	fi
   1004 
   1005 	# assign zone flag to registered interfaces of the SUNW.LogicalHostname resources
   1006 
   1007 	if [ "${LH_LIST}" ]
   1008 	then
   1009 		for LH in ${LH_LIST}
   1010 		do
   1011 			get_ipmp_state ${LH}
   1012 
   1013 			# Place the IPMP ADAPTER into the local zone
   1014 
   1015 			for ADAPTER in ${ADAPTER_LIST}
   1016 			do
   1017 				for j in ${IPMP_HOST_IP}
   1018 				do
   1019 					for i in `${IFCONFIG} -a | /bin/grep ${ADAPTER} | /bin/awk -F: '{print $2}' | /bin/grep -v flags`
   1020 					do
   1021 						IPMP_ADAPTER_IP=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w inet | /bin/awk '{print $2}'`
   1022 		
   1023 						if [ "${IPMP_ADAPTER_IP}" = "${j}" ]
   1024 						then
   1025 							if ! ${IFCONFIG} ${ADAPTER}:${i} zone ${Zonename}
   1026 							then
   1027 								rc_start_command=1
   1028 							fi
   1029 		
   1030 		   					# SCMSGS
   1031 		   					# @explanation
   1032 		   					# The interface of the
   1033 		   					# logical host
   1034 		   					# resource is placed
   1035 		   					# by the start command
   1036 		   					# into the referenced
   1037 		   					# zone.
   1038 		   					# @user_action
   1039 		   					# None.
   1040 		   					scds_syslog -p daemon.notice -t $(syslog_tag) -m \
   1041 					  	  	  "Function: start_sczbt - logical interface %s:%s placed into %s" \
   1042 						  	  "${ADAPTER}" "${i}" "${Zonename}"
   1043 						fi
   1044 					done
   1045 				done
   1046 			done
   1047 		done
   1048 	fi
   1049 		
   1050 	debug_message "Function: start_sczbt - End"
   1051 	return ${rc_start_command}
   1052 }
   1053 
   1054 stop_sczbt()
   1055 {
   1056 	#
   1057 	# Stop sczbt
   1058 	#
   1059 
   1060         debug_message "Function: stop_sczbt - Begin"
   1061 	${SET_DEBUG}
   1062 
   1063 	rc_stop_command=0
   1064 
   1065 	# RETRIEVE STOP_TIMEOUT
   1066 	STOP_TIMEOUT=`${SCHA_RESOURCE_GET} -O STOP_TIMEOUT -R ${RESOURCE} -G ${RESOURCEGROUP}`
   1067 
   1068 	# 60 % of the STOP_TIMEOUT can be spend on waiting for normal shutdown
   1069 	MAX_STOP_TIMEOUT=`expr ${STOP_TIMEOUT} \* 60 \/ 100`
   1070 
   1071 	# 15 % of the STOP_TIMEOUT can be spend on waiting for clear_zone()
   1072 	CLEAR_STOP_TIMEOUT=`expr ${STOP_TIMEOUT} \* 15 \/ 100`
   1073 
   1074 	# reset SECONDS to zero
   1075 	SECONDS=0
   1076 
   1077 	# Place the IPMP ADAPTER back into the global zone
   1078 	LH_LIST=`${SCHA_RESOURCE_GET} -O NETWORK_RESOURCES_USED -R ${RESOURCE} -G ${RESOURCEGROUP}`
   1079 
   1080 	if [ "${LH_LIST}" ]
   1081 	then
   1082 		for LH in ${LH_LIST}
   1083 		do
   1084 			get_ipmp_state ${LH}
   1085 
   1086 			for ADAPTER in ${ADAPTER_LIST}
   1087 			do
   1088 				for j in ${IPMP_HOST_IP}
   1089 				do
   1090 					for i in `${IFCONFIG} -a | /bin/grep ${ADAPTER} | /bin/awk -F: '{print $2}' | /bin/grep -v flags`
   1091 					do
   1092 						# For each ${ADAPTER}:${i} check "${IPMP_ADAPTER_IP}" = "${j}" , ${j} is one of the list of ip addresses
   1093 						# If there's a match, then for each ${ADAPTER}:${i} check the zone flag = "${Zonename}"
   1094 						# If there's a match then place the ${ADAPTER}:${i} back into the global zone
   1095 		
   1096 						IPMP_ADAPTER_IP=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w inet | /bin/awk '{print $2}'`
   1097 		
   1098 						if [ "${IPMP_ADAPTER_IP}" = "${j}" ]
   1099 						then
   1100 							if ${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w zone > /dev/null
   1101 							then
   1102 								ZONE_ADAPTER=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w zone | /bin/awk '{print $2}'`
   1103 		
   1104 								if [ "${ZONE_ADAPTER}" = "${Zonename}" ]
   1105 								then
   1106 									${IFCONFIG} ${ADAPTER}:${i} -zone
   1107 		
   1108 									# SCMSGS
   1109 									# @explanation
   1110 									# The
   1111 									# interface
   1112 									# of
   1113 									# the
   1114 									# associated
   1115 									# logical
   1116 									# host
   1117 									# is
   1118 									# placed
   1119 									# back
   1120 									# into
   1121 									# the
   1122 									# global
   1123 									# zone
   1124 									# by
   1125 									# the
   1126 									# stop
   1127 									# command
   1128 									# of
   1129 									# the
   1130 									# sczbt
   1131 									# component.
   1132 									# @user_action
   1133 									# None
   1134 									scds_syslog -p daemon.notice -t $(syslog_tag) -m \
   1135 									  "Function: stop_sczbt - Logical interface %s:%s placed into the global zone" \
   1136 									  "${ADAPTER}" "${i}"
   1137 								fi
   1138 							fi
   1139 						fi
   1140 					done
   1141 				done
   1142 			done
   1143 		done
   1144 	fi
   1145 
   1146 	# bring down the zone
   1147 	debug_message "Function: stop_sczbt - Shuting down non-global zone ${Zonename}"
   1148 	case ${Zonebrand} in
   1149 		native|solaris8|solaris9)
   1150 			${ZLOGIN} ${Zonename} /usr/sbin/shutdown -y -g0 -i0 >${LOGFILE} 2>&1
   1151 			;;
   1152 		lx)
   1153 			${ZLOGIN} ${Zonename} /sbin/shutdown -h now >${LOGFILE} 2>&1
   1154 			;;
   1155 	esac
   1156 
   1157 	#
   1158 	# run a test loop to determine if the zone reached state "installed"
   1159 	# or if the timeout for proper shutdown is exceeded
   1160 	#
   1161 	while  [ ${SECONDS} -lt ${MAX_STOP_TIMEOUT} ]
   1162 	do
   1163 		# check if the zone reached state "installed"
   1164 		get_zone_state ${Zonename}
   1165 		debug_message "Function: stop_sczbt - ${Zonename} state is ${ZONE_STATE}, time passed while waiting for shutdown: ${SECONDS}"
   1166 		if [ "${ZONE_STATE}" = "installed" ]; then
   1167 		   SECONDS=${MAX_STOP_TIMEOUT}
   1168 		else
   1169 		   # wait 4 seconds
   1170 		   sleep 4
   1171 		fi
   1172 	done
   1173 
   1174 	#
   1175 	# bring the zone down at all costs if the shutdown has exceeded
   1176 	# its time limit and did not reach state "installed"
   1177 	#
   1178 
   1179 	if [ "${ZONE_STATE}" != "installed" ]; then
   1180 
   1181 		debug_message "Function: stop_sczbt - Halting non-global zone ${Zonename}"
   1182 
   1183 		#
   1184 		# According to
   1185 		# http://docs.sun.com/app/docs/doc/819-2450/6n4o5mde2?a=view
   1186 		# zoneadm halt will bring down all processes running within
   1187 		# the non-global zone, devices are unconfigured, network
   1188 		# interfaces are unplumbed, file systems are unmounted, and the
   1189 		# kernel data structures are destroyed.
   1190 		#
   1191 		# However, processes running within the global zone could
   1192 		# block a non-global zones file system (e.g. a backup app),
   1193 		# for that reason after the first zoneadm halt got issued,
   1194 		# but the non-global zone did not yet reach state "installed",
   1195 		# the clear_zone script will get called. It will try to kill
   1196 		# any processes blocking the non-global zones file systems
   1197 		# from the global zone.
   1198 		#
   1199 		# Afterwards zoneadm halt is called a second time to bring
   1200 		# the non-global zone into state "installed. If this is
   1201 		# not possible, an error message indicates the need for
   1202 		# manual intervention through the systems administrator
   1203 		# in order to cleanup the non-global zone.
   1204 		# 
   1205 		${ZONEADM} -z ${Zonename} halt >>${LOGFILE} 2>&1
   1206 		rc_stop_command=$?
   1207 
   1208 		get_zone_state ${Zonename}
   1209 
   1210 		debug_message "Function: stop_sczbt - ${Zonename} state is ${ZONE_STATE}"
   1211 
   1212 		if [ "${ZONE_STATE}" != "installed" ]; then
   1213 			SECONDS=0
   1214 			get_zonepath ${Zonename}
   1215 			/usr/cluster/bin/hatimerun -t ${CLEAR_STOP_TIMEOUT} /opt/SUNWsczone/sczbt/bin/clear_zone ${Zonepath} ${RESOURCEGROUP} ${RESOURCE} >>${LOGFILE}
   1216 			debug_message "Function: stop_sczbt - ${Zonename} state is ${ZONE_STATE}, time passed while waiting for clear_zone: ${SECONDS}"
   1217 
   1218 			# give some time to let killed processes finish
   1219 			sleep 2
   1220 
   1221 			debug_message "Function: stop_sczbt - Halting non-global zone ${Zonename} again"
   1222 			${ZONEADM} -z ${Zonename} halt >>${LOGFILE} 2>&1
   1223 			rc_stop_command=$?
   1224 
   1225 			get_zone_state ${Zonename}
   1226 			if [ "${ZONE_STATE}" != "installed" ]; then
   1227 				# SCMSGS
   1228 				# @explanation
   1229 				# The non-global zones shutdown command did not
   1230 				# complete in time or zoneadm halt was not able
   1231 				# to bring the non-global zone into state
   1232 				# "installed". In order to prevent failed
   1233 				# starts of the non-global zone on this
   1234 				# node, manual cleanup is necessary.
   1235 				# @user_action
   1236 				# Follow the Solaris System Administrator Guide
   1237 				# for Zones to bring the non-global zone into
   1238 				# state "installed" before trying to restart
   1239 				# the resource on this node.
   1240 				scds_syslog -p daemon.err -t $(syslog_tag) -m \
   1241 				 "Function: stop_sczbt - Manual intervention needed for non-global zone %s - unable to get into state installed." \
   1242 				 "${Zonename}"
   1243 			else
   1244 				debug_message "Function: stop_sczbt - ${Zonename} state is ${ZONE_STATE}"
   1245 				echo "Successfully halted the non-global zone ${Zonename}, it is in state ${ZONE_STATE}" >>${LOGFILE} 2>&1
   1246 				# SCMSGS
   1247 				# @explanation
   1248 				# The second zoneadm halt was able to get the
   1249 				# non-global zone into state "installed".
   1250 				# @user_action
   1251 				# None
   1252 				scds_syslog -p daemon.notice -t $(syslog_tag) -m \
   1253 				 "Function: stop_sczbt - The non-global zone %s was successfully halted and reached state %s" \
   1254 				 "${Zonename}" "${ZONE_STATE}"
   1255 			fi
   1256 		fi
   1257 	fi
   1258 
   1259         # Send a kill to any pids under the PMFtag
   1260         ${PMFADM} -s ${RESOURCEGROUP},${RESOURCE},0.svc KILL 2> /dev/null
   1261 	
   1262 	debug_message "Function: stop_sczbt - End"
   1263 	return ${rc_stop_command}
   1264 }
   1265 
   1266 check_sczbt()
   1267 {
   1268 	# 
   1269 	# Probe sczbt
   1270 	#
   1271 
   1272         debug_message "Function: check_sczbt - Begin"
   1273 	${SET_DEBUG}
   1274 
   1275 	rc_check_sczbt=0
   1276 
   1277 	# check if start program is running
   1278 
   1279 	if /bin/pgrep -z global -f "start_sczbt -R ${RESOURCE} " >/dev/null 2>&1
   1280 	then
   1281 		debug_message "Function: check_sczbt - Start program is still running "
   1282 		rc_check_sczbt=100
   1283 		return ${rc_check_sczbt}
   1284 	fi
   1285 
   1286 	# do a reduced check as long as the gds_svc_start is running otherwise do an extensive check
   1287 
   1288 	if /bin/pgrep -z global -f "gds_svc_start .*-R ${RESOURCE} " >/dev/null 2>&1
   1289 	then
   1290 
   1291 		# check if the scheduler is running
   1292 	
   1293 		if ! /bin/pgrep -z ${Zonename} zsched>/dev/null 2>&1
   1294 		then
   1295 			rc_check_sczbt=100
   1296 			debug_message "Function: check_sczbt - Early end"
   1297 			return ${rc_check_sczbt}
   1298 		fi
   1299 	
   1300 		# check if zone service is online 
   1301 
   1302 		case ${Zonebrand} in
   1303 		   native)
   1304 			get_svc_state ${Zonename} ${Milestone}
   1305 
   1306 			if [ "${SVC_STATE}" != "online"  -a  "${SVC_STATE}" != "degraded" ]
   1307 			then
   1308 				rc_check_sczbt=100
   1309 				debug_message "Function: check_sczbt - ${Zonename} milestone (${Milestone}) state is ${SVC_STATE}"
   1310 				return ${rc_check_sczbt}
   1311 			fi;;
   1312 		   lx)
   1313 			if get_lx_state ${Zonename}
   1314 			then
   1315 				if [ "${LX_STATE}" != "${LXrunlevel}" ]
   1316 				then
   1317 					rc_check_sczbt=100
   1318 					debug_message "Function: check_sczbt - ${Zonename} runlevel (${LXrunlevel}) state is ${LX_STATE}"
   1319 					return ${rc_check_sczbt}
   1320 				fi
   1321 			else
   1322 				rc_check_sczbt=100
   1323 				debug_message "Function: check_sczbt - runlevel did not return successfully (return code ${rc_get_lx_state}) for the non-global zone {Zonename}"
   1324 				return ${rc_check_sczbt}
   1325 			fi;;
   1326 
   1327 		   solaris8|solaris9)
   1328 			if get_solaris_legacy_state ${Zonename}
   1329 			then
   1330 				if [ "${SOLARIS_LEGACY_STATE}" != "${SLrunlevel}" ]
   1331 				then
   1332 					rc_check_sczbt=100
   1333 					debug_message "Function: check_sczbt - ${Zonename} runlevel (${SLrunlevel}) state is ${SOLARIS_LEGACY_STATE}"
   1334 					return ${rc_check_sczbt}
   1335 				fi
   1336 			else
   1337 				rc_check_sczbt=100
   1338 				debug_message "Function: check_sczbt - runlevel did not return successfully (return code ${rc_get_solaris_legacy_state}) for the non-global zone {Zonename}"
   1339 				return ${rc_check_sczbt}
   1340 			fi;;
   1341 		esac
   1342 
   1343 	else
   1344 
   1345 		# check if the scheduler is running
   1346 
   1347 		if ! /bin/pgrep -z ${Zonename} zsched>/dev/null 2>&1
   1348 		then
   1349 	             	# SCMSGS
   1350 	             	# @explanation
   1351 	             	# The zsched prcess of the referenced zone is not
   1352 	             	# running. The zone is not operable.
   1353 	             	# @user_action
   1354 	             	# None. The resource will be restarted or the resource
   1355 	             	# group will be failed over.
   1356 	             	scds_syslog -p daemon.err -t $(syslog_tag) -m \
   1357 	               		"Function: check_sczbt - Zone scheduler for %s not running" \
   1358 				"${Zonename}" 
   1359 			rc_check_sczbt=100
   1360 			debug_message "Function: check_sczbt - Early end"
   1361 			return ${rc_check_sczbt}
   1362 		fi
   1363 	
   1364 		# check if the ip addresses of the logical hoists are online
   1365 		
   1366 		LH_LIST=`${SCHA_RESOURCE_GET} -O NETWORK_RESOURCES_USED -R ${RESOURCE} -G ${RESOURCEGROUP}`
   1367 
   1368 		if [ "${LH_LIST}" ]
   1369 		then
   1370 
   1371 			ip_config=`${IFCONFIG} -a`
   1372 
   1373 			for LH in ${LH_LIST}
   1374 			do
   1375    				get_ipmp_hosts ${LH}
   1376 
   1377 				for i in ${IPMP_HOST_IP}
   1378 				do
   1379 					if ! echo ${ip_config} | /bin/grep -w ${i} >/dev/null 2>&1
   1380 	   				then
   1381 		             			# SCMSGS
   1382 		             			# @explanation
   1383 		             			# The referenced zones ip
   1384 		             			# address is unplumbed.
   1385 		             			# @user_action
   1386 		             			# None. The resource will be
   1387 		             			# restarted or the resource
   1388 		             			# group will be failed over.
   1389 		             			scds_syslog -p daemon.err -t $(syslog_tag) -m \
   1390 		               				"Function: check_sczbt - Zones %s ip address %s is not running" \
   1391 							"${Zonename}" "${i}"
   1392 	         				rc_check_sczbt=201
   1393 						debug_message "Function: check_sczbt - immediate failover"
   1394 						
   1395 						return ${rc_check_sczbt}
   1396 	   				fi
   1397 				done
   1398 			done
   1399 		fi
   1400 
   1401 		# check if zone service is online if not try for 60 percent of the probe timout
   1402 
   1403 		# RETRIEVE PROBE_TIMEOUT
   1404 
   1405 		PROBE_TIMEOUT=`${SCHA_RESOURCE_GET} -O Extension -R ${RESOURCE} -G ${RESOURCEGROUP} PROBE_TIMEOUT |tail -1`
   1406 
   1407 		# 60 % OF THE PROBE_TIMEOUT CAN BE SPEND ON WAITING
   1408 
   1409 		MAX_PROBE_TIMEOUT=`expr ${PROBE_TIMEOUT} \* 60 \/ 100`
   1410 		SECONDS=0
   1411 
   1412 		# test for 60 percent of the probe timeoput if the zone is online
   1413 		case ${Zonebrand} in
   1414 		   native)
   1415 			while [ ${SECONDS} -lt ${MAX_PROBE_TIMEOUT} ]
   1416 			do
   1417 				get_svc_state ${Zonename} ${Milestone}
   1418 
   1419 				if [ "${SVC_STATE}" != "online" -a "${SVC_STATE}" != "degraded" ]
   1420 				then
   1421        			      		# SCMSGS
   1422        			      		# @explanation
   1423        			      		# The milestone is not online or degraded. The
   1424        			      		# state is checked again in 5 seconds.
   1425        			      		# @user_action
   1426        			      		# None.
   1427        			      		scds_syslog -p daemon.err -t $(syslog_tag) -m \
   1428        		        			"Function: check_sczbt - %s Milestone [%s] not online, try again in 5 seconds" \
   1429 						"${Zonename}" "${Milestone}"
   1430 					rc_check_sczbt=100
   1431 					sleep 5
   1432 				else
   1433 					SECONDS=${MAX_PROBE_TIMEOUT}
   1434 					rc_check_sczbt=0
   1435 				fi
   1436 			done;;
   1437 
   1438 		   lx)
   1439 			while [ ${SECONDS} -lt ${MAX_PROBE_TIMEOUT} ]
   1440 			do
   1441 				if get_lx_state ${Zonename}
   1442 				then
   1443 					if [ "${LX_STATE}" != "${LXrunlevel}" ]
   1444 					then
   1445 						# SCMSGS
   1446 						# @explanation
   1447 						# The runlevel is not equal to the
   1448 						# configured LXrunlevel. The state is
   1449 						# checked again in 5 seconds.
   1450 						# @user_action
   1451 						# None.
   1452 						scds_syslog -p daemon.err -t $(syslog_tag) -m \
   1453 							"Function: check_sczbt - %s runlevel [%s] not online, runlevel is %s, try again in 5 seconds" \
   1454 							"${Zonename}" "${LXrunlevel}" "${LX_STATE}"
   1455 						rc_check_sczbt=100
   1456 						sleep 5
   1457 					else
   1458 						SECONDS=${MAX_PROBE_TIMEOUT}
   1459 						rc_check_sczbt=0
   1460 					fi
   1461 				else
   1462 					# SCMSGS
   1463 					# @explanation
   1464 					# The runlevel command did not run
   1465 					# successfully in the configured
   1466 					# non-global zone. The state is
   1467 					# checked again in 5 seconds.
   1468 					# @user_action
   1469 					# None.
   1470 					scds_syslog -p daemon.err -t $(syslog_tag) -m \
   1471 						"Function: check_sczbt - runlevel did not run successfully (return code %s) in the non-global zone %s, try again in 5 seconds" \
   1472 						"${rc_get_lx_state}" "${Zonename}"
   1473 					rc_check_sczbt=100
   1474 					sleep 5
   1475 				fi
   1476 			done;;
   1477 
   1478 		   solaris8|solaris9)
   1479 			while [ ${SECONDS} -lt ${MAX_PROBE_TIMEOUT} ]
   1480 			do
   1481 				if get_solaris_legacy_state ${Zonename}
   1482 				then
   1483 					if [ "${SOLARIS_LEGACY_STATE}" != "${SLrunlevel}" ]
   1484 					then
   1485 						# SCMSGS
   1486 						# @explanation
   1487 						# The legacy runlevel is not
   1488 						# equal to the configured
   1489 						# SLrunlevel. The state is
   1490 						# checked again in 5 seconds.
   1491 						# @user_action
   1492 						# None.
   1493 						scds_syslog -p daemon.err -t $(syslog_tag) -m \
   1494 							"Function: check_sczbt - %s legacy runlevel [%s] not online, runlevel is %s, try again in 5 seconds" \
   1495 							"${Zonename}" "${SLrunlevel}" "${SOLARIS_LEGACY_STATE}"
   1496 						rc_check_sczbt=100
   1497 						sleep 5
   1498 					else
   1499 						SECONDS=${MAX_PROBE_TIMEOUT}
   1500 						rc_check_sczbt=0
   1501 					fi
   1502 				else
   1503 					# SCMSGS
   1504 					# @explanation
   1505 					# The who -r command did not run
   1506 					# successfully in the configured
   1507 					# non-global zone. The state is
   1508 					# checked again in 5 seconds.
   1509 					# @user_action
   1510 					# None.
   1511 					scds_syslog -p daemon.err -t $(syslog_tag) -m \
   1512 						"Function: check_sczbt - who -r did not run successfully (return code %s) in the non-global zone %s, try again in 5 seconds" \
   1513 						"${rc_get_solaris_legacy_state}" "${Zonename}"
   1514 					rc_check_sczbt=100
   1515 					sleep 5
   1516 				fi
   1517 			done;;
   1518 
   1519 		esac
   1520 	fi
   1521 
   1522 	debug_message "Function: check_sczbt - End"
   1523 	return ${rc_check_sczbt}
   1524 }
   1525