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 "%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 `/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) 
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 `/bin/grep address ${ZONE_NET_INFO} | /bin/awk '{print $2}' | /bin/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 `/bin/grep address ${ZONE_NET_INFO} | /bin/awk '{print $2}' | /bin/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 | /bin/grep ${ADAPTER} | /bin/awk -F: '{print $2}' | /bin/grep -v flags`
539                         do
540                                 IPMP_ADAPTER_IP=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w inet | /bin/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} | /bin/grep -w zone > /dev/null
547                                                 then
548                                                         ZONE_ADAPTER=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w zone | /bin/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} | /bin/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 /bin/grep -w exclude /etc/system | /bin/grep lofs >/dev/null 2>&1
638         then
639         
640         # if yes check if it is commented out
641 
642                 if ! /bin/grep -w exclude /etc/system |/bin/grep lofs | /bin/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 &star; 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} | /bin/grep : >/dev/null 2>&1
669                         then
670                                 echo ${i} | /bin/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} | /bin/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} | /bin/grep : >/dev/null 2>&1
770                 then
771                         echo ${i} | /bin/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} | /bin/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 | /bin/grep ^zonepath: | /bin/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 | /bin/tail +2`
854         IPMP_HOST_IP=`/bin/getent hosts ${IPMP_HOST} | /bin/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 | /bin/tail +2`
875 
876         for i in ${IPMP_LIST}
877         do
878                 if [ `echo ${i} | /bin/awk -F@ '{print $2}'` -eq "${NODEID}" ]
879                 then
880                         IPMP_GROUP=`echo ${i} | /bin/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=`/bin/env LC_ALL=POSIX ${SCSTAT} -i -h ${LOCALNODENAME} | /bin/grep " ${IPMP_GROUP} " | /bin/grep Online | /bin/awk '{print $6}'`
889 
890         debug_message "Function: get_ipmp_state - End"
891 }
892 
893 start_sczbt()
894 {
895         #
896         # Start sczbt
897         #
898 
899         debug_message "Function: start_sczbt - Begin"
900         ${SET_DEBUG}
901 
902         # If the zone is of brand type "solaris8" and if the platform changed 
903         # from where the zone was previously started, the s8_p2v script needs 
904         # to get called prior boot to make sure that any platform specific 
905         # libraries are properly setup within the zone rootpath. 

906         # The script needs to run only once per new platform. The file
907         # .platform.orig stores the platform names for which the s8_p2v script 
908         # had already run. Only if a new platform gets introduced into the 
909         # cluster, the s8_p2v script gets called on that node again. 
910         if [ "${Zonebrand}" = "solaris8" ]; then 

911 









912                 get_zonepath ${Zonename}
913 
914                 myplatform=`/bin/uname -i`
915                 myplatformfile=${Zonepath}/root/.platform.orig
916                 need_s8_p2v=true 
917 
918                 # if there is no .platform.orig file or if the current
919                 # platform is not contained, s8_p2v needs to run
920                 if [ -f ${myplatformfile} ]; then
921 
922                         if /usr/bin/grep "^${myplatform}$" ${myplatformfile} > /dev/null 2>&1
923                         then
924                                 need_s8_p2v=false 
925                         fi
926                 fi
927                 
928                 if [ -x /usr/lib/brand/solaris8/s8_p2v -a "${need_s8_p2v}" = "true" ]; then 
929                         /usr/lib/brand/solaris8/s8_p2v ${Zonename} >${LOGFILE} 2>&1 
930                         if [ $? -ne 0 ]; then
931                                 # SCMSGS
932                                 # @explanation
933                                 # Unable to perform platform specific
934                                 # setup for the solaris8 zone. 
935                                 # @user_action
936                                 # Disable the resource and manually run
937                                 # the /usr/lib/brand/solaris8/s8_p2v 
938                                 # <zonename> command on the node where 
939                                 # the start failed. Correct any errors 
940                                 # reported, then restart the resource. 


941                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
942                                         "Function: start_sczbt - Running command /usr/lib/brand/solaris8/s8_p2v %s failed. Unable to start zone." \ 
943                                         "${Zonename}" 
944                                 rc_start_command=1
945                                 return 1
946                         fi
947 
948                         # Only update the file if it is not a symbolic link.
949                         # Otherwise it would be a security issue.
950                         if [ ! -h ${myplatformfile} ]; then
951                                 # Add platform to the .platform.orig file
952                                 echo ${myplatform} >> ${myplatformfile}
953                         fi
954                 fi
955 
956                 # Only update the file if it is not a symbolic link.
957                 # Otherwise it would be a security issue.
958                 if [ ! -h ${Zonepath}/root/.host.orig ]; then
959                         # This update is necessary to make sure the
960                         # solaris8 zone can get booted without manual 
961                         # intervention. 
962                         /usr/bin/hostid > ${Zonepath}/root/.host.orig
963                 fi
964         fi
965 
966         # boot the zone
967         ${ZONEADM} -z ${Zonename} boot ${Zonebootopt} >>${LOGFILE} 2>&1
968 
969         rc_start_command=${?}
970 
971         # disable the pmf tag and run a sleep in the background, to assure, that there will be a valid pmftag during the start phase
972 
973         START_TIMEOUT=`${SCHA_RESOURCE_GET} -O START_TIMEOUT -R ${RESOURCE} -G ${RESOURCEGROUP}`
974         sleep ${START_TIMEOUT} &
975 
976         ${PMFADM} -s ${RESOURCEGROUP},${RESOURCE},0.svc
977 
978         # mount the requested loopbakcmount to the local zone
979 
980         if ! lofs_mounts
981         then
982                 rc_start_command=1
983         fi
984 
985         # assign zone flag to registered interfaces of the SUNW.LogicalHostname resources
986 
987         if [ "${LH_LIST}" ]
988         then
989                 for LH in ${LH_LIST}
990                 do
991                         get_ipmp_state ${LH}
992 
993                         # Place the IPMP ADAPTER into the local zone
994 
995                         for ADAPTER in ${ADAPTER_LIST}
996                         do
997                                 for j in ${IPMP_HOST_IP}
998                                 do
999                                         for i in `${IFCONFIG} -a | /bin/grep ${ADAPTER} | /bin/awk -F: '{print $2}' | /bin/grep -v flags`
1000                                         do
1001                                                 IPMP_ADAPTER_IP=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w inet | /bin/awk '{print $2}'`
1002                 
1003                                                 if [ "${IPMP_ADAPTER_IP}" = "${j}" ]
1004                                                 then
1005                                                         if ! ${IFCONFIG} ${ADAPTER}:${i} zone ${Zonename}
1006                                                         then
1007                                                                 rc_start_command=1
1008                                                         fi
1009                 
1010                                                         # SCMSGS
1011                                                         # @explanation
1012                                                         # The interface of the
1013                                                         # logical host
1014                                                         # resource is placed
1015                                                         # by the start command
1016                                                         # into the referenced
1017                                                         # zone.
1018                                                         # @user_action
1019                                                         # None.
1020                                                         scds_syslog -p daemon.notice -t $(syslog_tag) -m \
1021                                                           "Function: start_sczbt - logical interface %s:%s placed into %s" \
1022                                                           "${ADAPTER}" "${i}" "${Zonename}"
1023                                                 fi
1024                                         done
1025                                 done
1026                         done
1027                 done
1028         fi
1029                 
1030         debug_message "Function: start_sczbt - End"
1031         return ${rc_start_command}
1032 }
1033 
1034 stop_sczbt()
1035 {
1036         #
1037         # Stop sczbt
1038         #
1039 
1040         debug_message "Function: stop_sczbt - Begin"
1041         ${SET_DEBUG}
1042 
1043         rc_stop_command=0
1044 
1045         # RETRIEVE STOP_TIMEOUT
1046         STOP_TIMEOUT=`${SCHA_RESOURCE_GET} -O STOP_TIMEOUT -R ${RESOURCE} -G ${RESOURCEGROUP}`
1047 
1048         # 60 % of the STOP_TIMEOUT can be spend on waiting for normal shutdown
1049         MAX_STOP_TIMEOUT=`expr ${STOP_TIMEOUT} \* 60 \/ 100`
1050 
1051         # 15 % of the STOP_TIMEOUT can be spend on waiting for clear_zone()
1052         CLEAR_STOP_TIMEOUT=`expr ${STOP_TIMEOUT} \* 15 \/ 100`
1053 
1054         # reset SECONDS to zero
1055         SECONDS=0
1056 
1057         # Place the IPMP ADAPTER back into the global zone
1058         LH_LIST=`${SCHA_RESOURCE_GET} -O NETWORK_RESOURCES_USED -R ${RESOURCE} -G ${RESOURCEGROUP}`
1059 
1060         if [ "${LH_LIST}" ]
1061         then
1062                 for LH in ${LH_LIST}
1063                 do
1064                         get_ipmp_state ${LH}
1065 
1066                         for ADAPTER in ${ADAPTER_LIST}
1067                         do
1068                                 for j in ${IPMP_HOST_IP}
1069                                 do
1070                                         for i in `${IFCONFIG} -a | /bin/grep ${ADAPTER} | /bin/awk -F: '{print $2}' | /bin/grep -v flags`
1071                                         do
1072                                                 # For each ${ADAPTER}:${i} check "${IPMP_ADAPTER_IP}" = "${j}" , ${j} is one of the list of ip addresses
1073                                                 # If there's a match, then for each ${ADAPTER}:${i} check the zone flag = "${Zonename}"
1074                                                 # If there's a match then place the ${ADAPTER}:${i} back into the global zone
1075                 
1076                                                 IPMP_ADAPTER_IP=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w inet | /bin/awk '{print $2}'`
1077                 
1078                                                 if [ "${IPMP_ADAPTER_IP}" = "${j}" ]
1079                                                 then
1080                                                         if ${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w zone > /dev/null
1081                                                         then
1082                                                                 ZONE_ADAPTER=`${IFCONFIG} ${ADAPTER}:${i} | /bin/grep -w zone | /bin/awk '{print $2}'`
1083                 
1084                                                                 if [ "${ZONE_ADAPTER}" = "${Zonename}" ]
1085                                                                 then
1086                                                                         ${IFCONFIG} ${ADAPTER}:${i} -zone
1087                 
1088                                                                         # SCMSGS
1089                                                                         # @explanation
1090                                                                         # The
1091                                                                         # interface
1092                                                                         # of
1093                                                                         # the
1094                                                                         # associated
1095                                                                         # logical
1096                                                                         # host
1097                                                                         # is
1098                                                                         # placed
1099                                                                         # back
1100                                                                         # into
1101                                                                         # the
1102                                                                         # global
1103                                                                         # zone
1104                                                                         # by
1105                                                                         # the
1106                                                                         # stop
1107                                                                         # command
1108                                                                         # of
1109                                                                         # the
1110                                                                         # sczbt
1111                                                                         # component.
1112                                                                         # @user_action
1113                                                                         # None
1114                                                                         scds_syslog -p daemon.notice -t $(syslog_tag) -m \
1115                                                                           "Function: stop_sczbt - Logical interface %s:%s placed into the global zone" \
1116                                                                           "${ADAPTER}" "${i}"
1117                                                                 fi
1118                                                         fi
1119                                                 fi
1120                                         done
1121                                 done
1122                         done
1123                 done
1124         fi
1125 
1126         # bring down the zone
1127         debug_message "Function: stop_sczbt - Shuting down non-global zone ${Zonename}"
1128         if [ "${Zonebrand}" = "native" -o "${Zonebrand}" = "solaris8" ]; then 

1129                 ${ZLOGIN} ${Zonename} /usr/sbin/shutdown -y -g0 -i0 >${LOGFILE} 2>&1
1130         else 
1131                 # we must be an "lx" brand 
1132                 ${ZLOGIN} ${Zonename} /sbin/shutdown -h now >${LOGFILE} 2>&1
1133         fi 

1134 
1135         #
1136         # run a test loop to determine if the zone reached state "installed"
1137         # or if the timeout for proper shutdown is exceeded
1138         #
1139         while  [ ${SECONDS} -lt ${MAX_STOP_TIMEOUT} ]
1140         do
1141                 # check if the zone reached state "installed"
1142                 get_zone_state ${Zonename}
1143                 debug_message "Function: stop_sczbt - ${Zonename} state is ${ZONE_STATE}, time passed while waiting for shutdown: ${SECONDS}"
1144                 if [ "${ZONE_STATE}" = "installed" ]; then
1145                    SECONDS=${MAX_STOP_TIMEOUT}
1146                 else
1147                    # wait 4 seconds
1148                    sleep 4
1149                 fi
1150         done
1151 
1152         #
1153         # bring the zone down at all costs if the shutdown has exceeded
1154         # its time limit and did not reach state "installed"
1155         #
1156 
1157         if [ "${ZONE_STATE}" != "installed" ]; then
1158 
1159                 debug_message "Function: stop_sczbt - Halting non-global zone ${Zonename}"
1160 
1161                 #
1162                 # According to
1163                 # http://docs.sun.com/app/docs/doc/819-2450/6n4o5mde2?a=view
1164                 # zoneadm halt will bring down all processes running within
1165                 # the non-global zone, devices are unconfigured, network
1166                 # interfaces are unplumbed, file systems are unmounted, and the
1167                 # kernel data structures are destroyed.
1168                 #
1169                 # However, processes running within the global zone could
1170                 # block a non-global zones file system (e.g. a backup app),
1171                 # for that reason after the first zoneadm halt got issued,
1172                 # but the non-global zone did not yet reach state "installed",
1173                 # the clear_zone script will get called. It will try to kill
1174                 # any processes blocking the non-global zones file systems
1175                 # from the global zone.
1176                 #
1177                 # Afterwards zoneadm halt is called a second time to bring
1178                 # the non-global zone into state "installed. If this is
1179                 # not possible, an error message indicates the need for
1180                 # manual intervention through the systems administrator
1181                 # in order to cleanup the non-global zone.
1182                 # 
1183                 ${ZONEADM} -z ${Zonename} halt >>${LOGFILE} 2>&1
1184                 rc_stop_command=$?
1185 
1186                 get_zone_state ${Zonename}
1187 
1188                 debug_message "Function: stop_sczbt - ${Zonename} state is ${ZONE_STATE}"
1189 
1190                 if [ "${ZONE_STATE}" != "installed" ]; then
1191                         SECONDS=0
1192                         get_zonepath ${Zonename}
1193                         /usr/cluster/bin/hatimerun -t ${CLEAR_STOP_TIMEOUT} /opt/SUNWsczone/sczbt/bin/clear_zone ${Zonepath} ${RESOURCEGROUP} ${RESOURCE} >>${LOGFILE}
1194                         debug_message "Function: stop_sczbt - ${Zonename} state is ${ZONE_STATE}, time passed while waiting for clear_zone: ${SECONDS}"
1195 
1196                         # give some time to let killed processes finish
1197                         sleep 2
1198 
1199                         debug_message "Function: stop_sczbt - Halting non-global zone ${Zonename} again"
1200                         ${ZONEADM} -z ${Zonename} halt >>${LOGFILE} 2>&1
1201                         rc_stop_command=$?
1202 
1203                         get_zone_state ${Zonename}
1204                         if [ "${ZONE_STATE}" != "installed" ]; then
1205                                 # SCMSGS
1206                                 # @explanation
1207                                 # The non-global zones shutdown command did not
1208                                 # complete in time or zoneadm halt was not able
1209                                 # to bring the non-global zone into state
1210                                 # "installed". In order to prevent failed
1211                                 # starts of the non-global zone on this
1212                                 # node, manual cleanup is necessary.
1213                                 # @user_action
1214                                 # Follow the Solaris System Administrator Guide
1215                                 # for Zones to bring the non-global zone into
1216                                 # state "installed" before trying to restart
1217                                 # the resource on this node.
1218                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
1219                                  "Function: stop_sczbt - Manual intervention needed for non-global zone %s - unable to get into state installed." \
1220                                  "${Zonename}"
1221                         else
1222                                 debug_message "Function: stop_sczbt - ${Zonename} state is ${ZONE_STATE}"
1223                                 echo "Successfully halted the non-global zone ${Zonename}, it is in state ${ZONE_STATE}" >>${LOGFILE} 2>&1
1224                                 # SCMSGS
1225                                 # @explanation
1226                                 # The second zoneadm halt was able to get the
1227                                 # non-global zone into state "installed".
1228                                 # @user_action
1229                                 # None
1230                                 scds_syslog -p daemon.notice -t $(syslog_tag) -m \
1231                                  "Function: stop_sczbt - The non-global zone %s was successfully halted and reached state %s" \
1232                                  "${Zonename}" "${ZONE_STATE}"
1233                         fi
1234                 fi
1235         fi
1236 
1237         # Send a kill to any pids under the PMFtag
1238         ${PMFADM} -s ${RESOURCEGROUP},${RESOURCE},0.svc KILL 2> /dev/null
1239         
1240         debug_message "Function: stop_sczbt - End"
1241         return ${rc_stop_command}
1242 }
1243 
1244 check_sczbt()
1245 {
1246         # 
1247         # Probe sczbt
1248         #
1249 
1250         debug_message "Function: check_sczbt - Begin"
1251         ${SET_DEBUG}
1252 
1253         rc_check_sczbt=0
1254 
1255         # check if start program is running
1256 
1257         if /bin/pgrep -z global -f "start_sczbt -R ${RESOURCE} " >/dev/null 2>&1
1258         then
1259                 debug_message "Function: check_sczbt - Start program is still running "
1260                 rc_check_sczbt=100
1261                 return ${rc_check_sczbt}
1262         fi
1263 
1264         # do a reduced check as long as the gds_svc_start is running otherwise do an extensive check
1265 
1266         if /bin/pgrep -z global -f "gds_svc_start .*-R ${RESOURCE} " >/dev/null 2>&1
1267         then
1268 
1269                 # check if the scheduler is running
1270         
1271                 if ! /bin/pgrep -z ${Zonename} zsched>/dev/null 2>&1
1272                 then
1273                         rc_check_sczbt=100
1274                         debug_message "Function: check_sczbt - Early end"
1275                         return ${rc_check_sczbt}
1276                 fi
1277         
1278                 # check if zone service is online 
1279 
1280                 case ${Zonebrand} in
1281                    native)
1282                         get_svc_state ${Zonename} ${Milestone}
1283 
1284                         if [ "${SVC_STATE}" != "online"  -a  "${SVC_STATE}" != "degraded" ]
1285                         then
1286                                 rc_check_sczbt=100
1287                                 debug_message "Function: check_sczbt - ${Zonename} milestone (${Milestone}) state is ${SVC_STATE}"
1288                                 return ${rc_check_sczbt}
1289                         fi;;
1290                    lx)
1291                         if get_lx_state ${Zonename}
1292                         then
1293                                 if [ "${LX_STATE}" != "${LXrunlevel}" ]
1294                                 then
1295                                         rc_check_sczbt=100
1296                                         debug_message "Function: check_sczbt - ${Zonename} runlevel (${LXrunlevel}) state is ${LX_STATE}"
1297                                         return ${rc_check_sczbt}
1298                                 fi
1299                         else
1300                                 rc_check_sczbt=100
1301                                 debug_message "Function: check_sczbt - runlevel did not return successfully (return code ${rc_get_lx_state}) for the non-global zone {Zonename}"
1302                                 return ${rc_check_sczbt}
1303                         fi;;
1304 
1305                    solaris8) 
1306                         if get_solaris_legacy_state ${Zonename}
1307                         then
1308                                 if [ "${SOLARIS_LEGACY_STATE}" != "${SLrunlevel}" ]
1309                                 then
1310                                         rc_check_sczbt=100
1311                                         debug_message "Function: check_sczbt - ${Zonename} runlevel (${SLrunlevel}) state is ${SOLARIS_LEGACY_STATE}"
1312                                         return ${rc_check_sczbt}
1313                                 fi
1314                         else
1315                                 rc_check_sczbt=100
1316                                 debug_message "Function: check_sczbt - runlevel did not return successfully (return code ${rc_get_solaris_legacy_state}) for the non-global zone {Zonename}"
1317                                 return ${rc_check_sczbt}
1318                         fi;;
1319                 esac
1320 
1321         else
1322 
1323                 # check if the scheduler is running
1324 
1325                 if ! /bin/pgrep -z ${Zonename} zsched>/dev/null 2>&1
1326                 then
1327                         # SCMSGS
1328                         # @explanation
1329                         # The zsched prcess of the referenced zone is not
1330                         # running. The zone is not operable.
1331                         # @user_action
1332                         # None. The resource will be restarted or the resource
1333                         # group will be failed over.
1334                         scds_syslog -p daemon.err -t $(syslog_tag) -m \
1335                                 "Function: check_sczbt - Zone scheduler for %s not running" \
1336                                 "${Zonename}" 
1337                         rc_check_sczbt=100
1338                         debug_message "Function: check_sczbt - Early end"
1339                         return ${rc_check_sczbt}
1340                 fi
1341         
1342                 # check if the ip addresses of the logical hoists are online
1343                 
1344                 LH_LIST=`${SCHA_RESOURCE_GET} -O NETWORK_RESOURCES_USED -R ${RESOURCE} -G ${RESOURCEGROUP}`
1345 
1346                 if [ "${LH_LIST}" ]
1347                 then
1348 
1349                         ip_config=`${IFCONFIG} -a`
1350 
1351                         for LH in ${LH_LIST}
1352                         do
1353                                 get_ipmp_hosts ${LH}
1354 
1355                                 for i in ${IPMP_HOST_IP}
1356                                 do
1357                                         if ! echo ${ip_config} | /bin/grep -w ${i} >/dev/null 2>&1
1358                                         then
1359                                                 # SCMSGS
1360                                                 # @explanation
1361                                                 # The referenced zones ip
1362                                                 # address is unplumbed.
1363                                                 # @user_action
1364                                                 # None. The resource will be
1365                                                 # restarted or the resource
1366                                                 # group will be failed over.
1367                                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
1368                                                         "Function: check_sczbt - Zones %s ip address %s is not running" \
1369                                                         "${Zonename}" "${i}"
1370                                                 rc_check_sczbt=201
1371                                                 debug_message "Function: check_sczbt - immediate failover"
1372                                                 
1373                                                 return ${rc_check_sczbt}
1374                                         fi
1375                                 done
1376                         done
1377                 fi
1378 
1379                 # check if zone service is online if not try for 60 percent of the probe timout
1380 
1381                 # RETRIEVE PROBE_TIMEOUT
1382 
1383                 PROBE_TIMEOUT=`${SCHA_RESOURCE_GET} -O Extension -R ${RESOURCE} -G ${RESOURCEGROUP} PROBE_TIMEOUT |tail -1`
1384 
1385                 # 60 % OF THE PROBE_TIMEOUT CAN BE SPEND ON WAITING
1386 
1387                 MAX_PROBE_TIMEOUT=`expr ${PROBE_TIMEOUT} \* 60 \/ 100`
1388                 SECONDS=0
1389 
1390                 # test for 60 percent of the probe timeoput if the zone is online
1391                 case ${Zonebrand} in
1392                    native)
1393                         while [ ${SECONDS} -lt ${MAX_PROBE_TIMEOUT} ]
1394                         do
1395                                 get_svc_state ${Zonename} ${Milestone}
1396 
1397                                 if [ "${SVC_STATE}" != "online" -a "${SVC_STATE}" != "degraded" ]
1398                                 then
1399                                         # SCMSGS
1400                                         # @explanation
1401                                         # The milestone is not online or degraded. The
1402                                         # state is checked again in 5 seconds.
1403                                         # @user_action
1404                                         # None.
1405                                         scds_syslog -p daemon.err -t $(syslog_tag) -m \
1406                                                 "Function: check_sczbt - %s Milestone [%s] not online, try again in 5 seconds" \
1407                                                 "${Zonename}" "${Milestone}"
1408                                         rc_check_sczbt=100
1409                                         sleep 5
1410                                 else
1411                                         SECONDS=${MAX_PROBE_TIMEOUT}
1412                                         rc_check_sczbt=0
1413                                 fi
1414                         done;;
1415 
1416                    lx)
1417                         while [ ${SECONDS} -lt ${MAX_PROBE_TIMEOUT} ]
1418                         do
1419                                 if get_lx_state ${Zonename}
1420                                 then
1421                                         if [ "${LX_STATE}" != "${LXrunlevel}" ]
1422                                         then
1423                                                 # SCMSGS
1424                                                 # @explanation
1425                                                 # The runlevel is not equal to the
1426                                                 # configured LXrunlevel. The state is
1427                                                 # checked again in 5 seconds.
1428                                                 # @user_action
1429                                                 # None.
1430                                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
1431                                                         "Function: check_sczbt - %s runlevel [%s] not online, runlevel is %s, try again in 5 seconds" \
1432                                                         "${Zonename}" "${LXrunlevel}" "${LX_STATE}"
1433                                                 rc_check_sczbt=100
1434                                                 sleep 5
1435                                         else
1436                                                 SECONDS=${MAX_PROBE_TIMEOUT}
1437                                                 rc_check_sczbt=0
1438                                         fi
1439                                 else
1440                                         # SCMSGS
1441                                         # @explanation
1442                                         # The runlevel command did not run
1443                                         # successfully in the configured
1444                                         # non-global zone. The state is
1445                                         # checked again in 5 seconds.
1446                                         # @user_action
1447                                         # None.
1448                                         scds_syslog -p daemon.err -t $(syslog_tag) -m \
1449                                                 "Function: check_sczbt - runlevel did not run successfully (return code %s) in the non-global zone %s, try again in 5 seconds" \
1450                                                 "${rc_get_lx_state}" "${Zonename}"
1451                                         rc_check_sczbt=100
1452                                         sleep 5
1453                                 fi
1454                         done;;
1455 
1456                    solaris8) 
1457                         while [ ${SECONDS} -lt ${MAX_PROBE_TIMEOUT} ]
1458                         do
1459                                 if get_solaris_legacy_state ${Zonename}
1460                                 then
1461                                         if [ "${SOLARIS_LEGACY_STATE}" != "${SLrunlevel}" ]
1462                                         then
1463                                                 # SCMSGS
1464                                                 # @explanation
1465                                                 # The legacy runlevel is not
1466                                                 # equal to the configured
1467                                                 # SLrunlevel. The state is
1468                                                 # checked again in 5 seconds.
1469                                                 # @user_action
1470                                                 # None.
1471                                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
1472                                                         "Function: check_sczbt - %s legacy runlevel [%s] not online, runlevel is %s, try again in 5 seconds" \
1473                                                         "${Zonename}" "${SLrunlevel}" "${SOLARIS_LEGACY_STATE}"
1474                                                 rc_check_sczbt=100
1475                                                 sleep 5
1476                                         else
1477                                                 SECONDS=${MAX_PROBE_TIMEOUT}
1478                                                 rc_check_sczbt=0
1479                                         fi
1480                                 else
1481                                         # SCMSGS
1482                                         # @explanation
1483                                         # The who -r command did not run
1484                                         # successfully in the configured
1485                                         # non-global zone. The state is
1486                                         # checked again in 5 seconds.
1487                                         # @user_action
1488                                         # None.
1489                                         scds_syslog -p daemon.err -t $(syslog_tag) -m \
1490                                                 "Function: check_sczbt - who -r did not run successfully (return code %s) in the non-global zone %s, try again in 5 seconds" \
1491                                                 "${rc_get_solaris_legacy_state}" "${Zonename}"
1492                                         rc_check_sczbt=100
1493                                         sleep 5
1494                                 fi
1495                         done;;
1496 
1497                 esac
1498         fi
1499 
1500         debug_message "Function: check_sczbt - End"
1501         return ${rc_check_sczbt}
1502 }
--- EOF ---