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