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