3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the License).
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/CDDL.txt
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/CDDL.txt.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets [] replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # ident "%Z%%M% %I% %E% SMI"
27 #
28
29 # define variables
30
31 validate_options()
32 {
33 debug_message "Function: validate_options - Begin"
34 ${SET_DEBUG}
35
36 #
37 # Ensure all options are set
38 #
39 rc_validate_options=0
40
41 for i in RESOURCE RESOURCEGROUP PARDIR
42 do
43 case ${i} in
91 debug_message "Function: validate - Begin"
92 ${SET_DEBUG}
93
94 rc_validate=0
95
96 #
97 # Validate that prameter file exists and is syntactically correct
98 #
99
100 if ! val_parfile ${PARFILE} "Zonename Zonebootopt Milestone" ${PARDIR}
101 then
102 debug_message "Function: validate - End"
103 rc_validate=1
104 return ${rc_validate}
105 fi
106
107 # test the semantic of the parameters
108
109 . ${PARFILE}
110
111 for i in `cat ${PARFILE} |grep -v "^#"|grep -v "^ "|nawk -F= '{print $1}'`
112 do
113 case ${i} in
114
115 Zonename)
116
117 # test the Zonename
118
119 # is the zone name specified
120
121 if [ -z ${Zonename} ]; then
122 # SCMSGS
123 # @explanation
124 # The variable Zonename does not contain a
125 # value.
126 # @user_action
127 # Review the components configuration file and
128 # make sure the variable Zonename is properly
129 # defined.
130 scds_syslog -p daemon.err -t $(syslog_tag) -m \
131 "Function: validate - Zone name not set in %s" \
143 then
144 debug_message "Function: validate - ${Zonename} state is ${ZONE_STATE}"
145 else
146 # SCMSGS
147 # @explanation
148 # The referenced zone is not in the state
149 # installed, ready or running.
150 # @user_action
151 # Make sure that the referenced zone name is
152 # configured properly. Check if you have done
153 # a zlogin -C. Make sure that the name in the
154 # appropriate config file is correct.
155 scds_syslog -p daemon.err -t $(syslog_tag) -m \
156 "Function: validate - %s state is %s" \
157 "${Zonename}" "${ZONE_STATE}"
158 rc_validate=1
159 fi
160
161 # is the autobooot set to false
162
163 if ! ${ZONECFG} -z ${Zonename} info |grep autoboot|grep false >/dev/null 2>&1
164 then
165 # SCMSGS
166 # @explanation
167 # The referenced zone is configured with
168 # autoboot = true. This option needs to be
169 # set to false.
170 # @user_action
171 # Configure the autoboot variable of the
172 # configured zone to false. You need to run
173 # the zoncfg command to complete this task.
174 scds_syslog -p daemon.err -t $(syslog_tag) -m \
175 "Function: validate - %s configured with autoboot true, it needs to be false" \
176 "${Zonename}"
177 rc_validate=1
178 else
179 debug_message "Function: validate - ${Zonename} configured with autoboot false"
180 fi;;
181
182 Zonebrand)
183
477 scds_syslog -p daemon.err -t $(syslog_tag) -m \
478 "Function: validate - Zone %s is configured with ip-type=exclusive, and the sczbt resource is dependand on a SUNW.LogicalHostname resource. This combination does not work." \
479 "${Zonename}"
480 rc_validate=1
481 fi
482
483 # Check if any IPMP_HOST_IP has been configured with the Zone
484
485 for LH in ${LH_LIST}
486 do
487 get_ipmp_state ${LH}
488
489 # Test if the IPMP_HOST_IP has been configured within the Zone
490
491 ZONE_NET_INFO=/tmp/${RESOURCE}_zoneinfo.txt
492
493 echo info net | ${ZONECFG} -z ${Zonename} > ${ZONE_NET_INFO}
494
495 for j in ${IPMP_HOST_IP}
496 do
497 for i in `grep address ${ZONE_NET_INFO} | awk '{print $2}' | awk -F/ '{print $1}'`
498 do
499 if [ "${i}" = "${j}" ]
500 then
501 # SCMSGS
502 # @explanation
503 # There is an IP address conflict
504 # between the SUNW.LogicalHostname
505 # resource and the configured zone.
506 # @user_action
507 # Remove the IP address from the zones
508 # configuration with the zonecfg
509 # command.
510 scds_syslog -p daemon.err -t $(syslog_tag) -m \
511 "Function: validate - %s configured with address %s, please remove the address using zonecfg" \
512 "${Zonename}" "${j}"
513 rc_validate=1
514 fi
515 done
516 done
517
518 # Test if the IPMP_HOST has been configured within the Zone
519
520 for j in ${IPMP_HOST}
521 do
522 for i in `grep address ${ZONE_NET_INFO} | awk '{print $2}' | awk -F/ '{print $1}'`
523 do
524 if [ "${i}" = "${j}" ]
525 then
526 scds_syslog -p daemon.err -t $(syslog_tag) -m \
527 "Function: validate - %s configured with address %s, please remove the address using zonecfg" \
528 "${Zonename}" "${j}"
529 rc_validate=1
530 fi
531 done
532 done
533
534 # Test if another zone is already using this IPMP_HOST_IP
535
536 for ADAPTER in ${ADAPTER_LIST}
537 do
538 for i in `${IFCONFIG} -a | grep ${ADAPTER} | awk -F: '{print $2}' | grep -v flags`
539 do
540 IPMP_ADAPTER_IP=`${IFCONFIG} ${ADAPTER}:${i} | grep -w inet | awk '{print $2}'`
541
542 for j in ${IPMP_HOST_IP}
543 do
544 if [ "${IPMP_ADAPTER_IP}" = "${j}" ]
545 then
546 if ${IFCONFIG} ${ADAPTER}:${i} | grep -w zone > /dev/null
547 then
548 ZONE_ADAPTER=`${IFCONFIG} ${ADAPTER}:${i} | grep -w zone | awk '{print $2}'`
549
550 # SCMSGS
551 # @explanation
552 # The logical host is
553 # used in another zone
554 # already. A logical
555 # host can not be used
556 # in two zones at the
557 # same time.
558 # @user_action
559 # Resolve the
560 # conflicting IP address
561 # configuration for
562 # your zones.
563 scds_syslog -p daemon.err -t $(syslog_tag) -m \
564 "Function: validate - %s (%s) already in use on %s:%s for %s, please resolve this conflict" \
565 "${LH}" "${j}" "${ADAPTER}" "${i}" "${ZONE_ADAPTER}"
566 rc_validate=1
567 fi
568 fi
569 done
570 done
571 done
572 done
573
574 # Check Zonebootopt="-s" has Milestone=single-user
575
576 if [ "${Zonebootopt}" = "-s" ]
577 then
578 case ${Zonebrand} in
579 native)
580 if ! echo ${Milestone} | grep single-user > /dev/null
581 then
582 # SCMSGS
583 # @explanation
584 # The Zoneboot variable is set to -s. Every
585 # milestone other than single-user is invalid.
586 # @user_action
587 # Correct the milestone in the paramter file
588 # sczbt_<resource name>. You need to specify
589 # single user together with the boot option -s.
590 scds_syslog -p daemon.err -t $(syslog_tag) -m \
591 "Function: validate - Milestone (%s) is invalid with Zonebootopt=%s, needs single-user" \
592 "${Milestone}" "${Zonebootopt}"
593 rc_validate=1
594 fi;;
595
596 lx)
597 if [ "${LXrunlevel}" != "unknown" ]
598 then
599 # SCMSGS
600 # @explanation
617 # SCMSGS
618 # @explanation
619 # The Zoneboot variable is set to -s. Every
620 # SLrunlevel other than "S" is invalid.
621 # @user_action
622 # Correct the SLrunlevel variable in the
623 # paramter file sczbt_<resource name>. You need
624 # to specify "S" together with the boot
625 # option -s.
626 scds_syslog -p daemon.err -t $(syslog_tag) -m \
627 "Function: validate - SLrunlevel (%s) is invalid with Zonebootopt=%s, needs single-user" \
628 "${SLrunlevel}" "${Zonebootopt}"
629 rc_validate=1
630 fi;;
631
632 esac
633 fi
634
635 # Check that lofs is not excluded, first check if an exclude lofs in in /etc/system
636
637 if grep -w exclude /etc/system |grep lofs >/dev/null 2>&1
638 then
639
640 # if yes check if it is commented out
641
642 if ! grep -w exclude /etc/system |grep lofs |egrep "^\*|^ +\*|^#|^ +| +#|^ +\*" >/dev/null 2>&1
643 then
644 # SCMSGS
645 # @explanation
646 # The kernel module for the lofs filesystem is still
647 # excluded in /etc/system.
648 # @user_action
649 # Place a ☆ in front of the exlude: lofs line and
650 # reboot the node.
651 scds_syslog -p daemon.err -t $(syslog_tag) -m \
652 "Function: validate - exclude: lofs found in /etc/system"
653 rc_validate=1
654 else
655 debug_message "Function: validate - exclude: lofs commented out in /etc/system"
656 fi
657 else
658 debug_message "Function: validate - No exclude: lofs found in /etc/system"
659 fi
660
661 if [ -n "${Mounts}" ]
662 then
663 for i in ${Mounts}
664 do
665 directory=
666 localdir=
667
668 if echo ${i} | grep : >/dev/null 2>&1
669 then
670 echo ${i} | awk -F: '{ print NF,$1,$2 }' | read field_count val1 val2
671
672 case ${field_count} in
673 2) # Support <global zone directory>:<local zone directory>
674 # Support <global zone directory>:<mount options>
675 directory=${val1}
676
677 if echo ${val2} | grep / > /dev/null 2>&1
678 then
679 localdir=${Zonepath}/root${val2}
680 else
681 localdir=${Zonepath}/root${val1}
682 fi
683 ;;
684 3) # Support <global zone directory>:<local zone directory>:<mount options>
685 # Support <global zone directory>:<local zone directory>:
686 directory=${val1}
687 localdir=${Zonepath}/root${val2}
688 ;;
689 *) scds_syslog -p daemon.err -t $(syslog_tag) -m \
690 "Function: validate - Mounts=%s is invalid"
691 "${Mounts}"
692 rc_validate=1
693 ;;
694 esac
695 else
696 # Support just <global zone directory> without any further entries
697 directory=${i}
749 get_svc_state ${Zonename} svc:/system/filesystem/minimal:default
750
751 while [ "${SVC_STATE}" != "online" ]
752 do
753 debug_message "wait until svc:/system/filesystem/minimal:default gets online in zone ${Zonename}"
754 sleep 2
755 get_svc_state ${Zonename} svc:/system/filesystem/minimal:default
756 done
757 fi
758
759 # start with the mounts
760
761 get_zonepath ${Zonename}
762
763 for i in ${Mounts}
764 do
765 source=
766 target=
767 mountopt=
768
769 if echo ${i} | grep : >/dev/null 2>&1
770 then
771 echo ${i} | awk -F: '{ print NF,$1,$2,$3 }' | read field_count val1 val2 val3
772
773 case ${field_count} in
774 2) # Support <global zone directory>:<local zone directory>
775 # Support <global zone directory>:<mount options>
776 source=${val1}
777
778 if echo ${val2} | grep / > /dev/null 2>&1
779 then
780 target=${Zonepath}/root${val2}
781 else
782 target=${Zonepath}/root${val1}
783 [ ${val2} ] && mountopt="-o ${val2}"
784 fi
785 ;;
786 3) # Support <global zone directory>:<local zone directory>:<mount options>
787 # Support <global zone directory>:<local zone directory>:
788 source=${val1}
789 target=${Zonepath}/root${val2}
790 [ ${val3} ] && mountopt="-o ${val3}"
791 ;;
792 *) scds_syslog -p daemon.err -t $(syslog_tag) -m \
793 "Function: validate - Mounts=%s is invalid"
794 "${Mounts}"
795 ;;
796 esac
797 else
798 # Support just <global zone directory> without any further entries
821 # @user_action
822 # Watch the verbose error message in the zones start
823 # messages and fix the issue with appropriate methods.
824 scds_syslog -p daemon.err -t $(syslog_tag) -m \
825 "Function: lofsmount - Non-global zones mount from %s to %s with options %s failed" \
826 "${source}" "${target}" "${mountopt}"
827 lofs_mount_rc=1
828 fi
829 done
830
831 debug_message "Function: lofs_mount - End"
832 return ${lofs_mount_rc}
833 }
834
835 get_zonepath()
836 {
837 debug_message "Function: get_zonepath - Begin"
838 ${SET_DEBUG}
839
840 myzone=${1}
841 Zonepath=`${ZONECFG} -z ${myzone} info|grep ^zonepath:|awk '{print $2}'`
842
843 debug_message "Function: zonepath - End"
844 }
845
846 get_ipmp_hosts()
847 {
848 debug_message "Function: get_ipmp_hosts - Begin"
849 ${SET_DEBUG}
850
851 LH=$1
852
853 IPMP_HOST=`${SCHA_RESOURCE_GET} -O Extension -R ${LH} -G ${RESOURCEGROUP} HostnameList |tail +2`
854 IPMP_HOST_IP=`getent hosts ${IPMP_HOST} | awk '{print $1}'`
855
856 debug_message "Function: get_ipmp_hosts - End"
857 }
858
859 get_ipmp_state()
860 {
861 # Retreive IPMP information for each Network_resources_used entry
862
863 debug_message "Function: get_ipmp_state - Begin"
864 ${SET_DEBUG}
865
866 LH=$1
867
868 get_ipmp_hosts ${LH}
869
870 NODEID=`${CLINFO} -n`
871
872 # Get the correct IPMP group, i.e. <IPMP>@${NODEID}
873
874 IPMP_LIST=`${SCHA_RESOURCE_GET} -O Extension -R ${LH} -G ${RESOURCEGROUP} NetIfList |tail +2`
875
876 for i in ${IPMP_LIST}
877 do
878 if [ `echo ${i} | awk -F@ '{print $2}'` -eq "${NODEID}" ]
879 then
880 IPMP_GROUP=`echo ${i} | awk -F@ '{print $1}'`
881 fi
882 done
883
884 # Get the Online IPMP adapter list for that IPMP Group
885
886 LOCALNODENAME=`${SCHA_CLUSTER_GET} -O NODENAME_LOCAL`
887
888 ADAPTER_LIST=`${SCSTAT} -i -h ${LOCALNODENAME} | grep " ${IPMP_GROUP} " | \
889 grep Online | awk '{print $6}'`
890
891 debug_message "Function: get_ipmp_state - End"
892 }
893
894 start_sczbt()
895 {
896 #
897 # Start sczbt
898 #
899
900 debug_message "Function: start_sczbt - Begin"
901 ${SET_DEBUG}
902
903 # If the zone is of brand type "solaris8" and if the platform changed
904 # from where the zone was previously started, the s8_p2v script needs
905 # to get called prior boot to make sure that any platform specific
906 # libraries are properly setup within the zone rootpath.
907 # The script needs to run only once per new platform. The file
908 # .platform.orig stores the platform names for which the s8_p2v script
909 # had already run. Only if a new platform gets introduced into the
980
981 if ! lofs_mounts
982 then
983 rc_start_command=1
984 fi
985
986 # assign zone flag to registered interfaces of the SUNW.LogicalHostname resources
987
988 if [ "${LH_LIST}" ]
989 then
990 for LH in ${LH_LIST}
991 do
992 get_ipmp_state ${LH}
993
994 # Place the IPMP ADAPTER into the local zone
995
996 for ADAPTER in ${ADAPTER_LIST}
997 do
998 for j in ${IPMP_HOST_IP}
999 do
1000 for i in `${IFCONFIG} -a | grep ${ADAPTER} | awk -F: '{print $2}' | grep -v flags`
1001 do
1002 IPMP_ADAPTER_IP=`${IFCONFIG} ${ADAPTER}:${i} | grep -w inet | awk '{print $2}'`
1003
1004 if [ "${IPMP_ADAPTER_IP}" = "${j}" ]
1005 then
1006 if ! ${IFCONFIG} ${ADAPTER}:${i} zone ${Zonename}
1007 then
1008 rc_start_command=1
1009 fi
1010
1011 # SCMSGS
1012 # @explanation
1013 # The interface of the
1014 # logical host
1015 # resource is placed
1016 # by the start command
1017 # into the referenced
1018 # zone.
1019 # @user_action
1020 # None.
1021 scds_syslog -p daemon.notice -t $(syslog_tag) -m \
1022 "Function: start_sczbt - logical interface %s:%s placed into %s" \
1051
1052 # 15 % of the STOP_TIMEOUT can be spend on waiting for clear_zone()
1053 CLEAR_STOP_TIMEOUT=`expr ${STOP_TIMEOUT} \* 15 \/ 100`
1054
1055 # reset SECONDS to zero
1056 SECONDS=0
1057
1058 # Place the IPMP ADAPTER back into the global zone
1059 LH_LIST=`${SCHA_RESOURCE_GET} -O NETWORK_RESOURCES_USED -R ${RESOURCE} -G ${RESOURCEGROUP}`
1060
1061 if [ "${LH_LIST}" ]
1062 then
1063 for LH in ${LH_LIST}
1064 do
1065 get_ipmp_state ${LH}
1066
1067 for ADAPTER in ${ADAPTER_LIST}
1068 do
1069 for j in ${IPMP_HOST_IP}
1070 do
1071 for i in `${IFCONFIG} -a | grep ${ADAPTER} | awk -F: '{print $2}' | grep -v flags`
1072 do
1073 # For each ${ADAPTER}:${i} check "${IPMP_ADAPTER_IP}" = "${j}" , ${j} is one of the list of ip addresses
1074 # If there's a match, then for each ${ADAPTER}:${i} check the zone flag = "${Zonename}"
1075 # If there's a match then place the ${ADAPTER}:${i} back into the global zone
1076
1077 IPMP_ADAPTER_IP=`${IFCONFIG} ${ADAPTER}:${i} | grep -w inet | awk '{print $2}'`
1078
1079 if [ "${IPMP_ADAPTER_IP}" = "${j}" ]
1080 then
1081 if ${IFCONFIG} ${ADAPTER}:${i} | grep -w zone > /dev/null
1082 then
1083 ZONE_ADAPTER=`${IFCONFIG} ${ADAPTER}:${i} | grep -w zone | awk '{print $2}'`
1084
1085 if [ "${ZONE_ADAPTER}" = "${Zonename}" ]
1086 then
1087 ${IFCONFIG} ${ADAPTER}:${i} -zone
1088
1089 # SCMSGS
1090 # @explanation
1091 # The
1092 # interface
1093 # of
1094 # the
1095 # associated
1096 # logical
1097 # host
1098 # is
1099 # placed
1100 # back
1101 # into
1102 # the
1103 # global
1252 ${SET_DEBUG}
1253
1254 rc_check_sczbt=0
1255
1256 # check if start program is running
1257
1258 if /bin/pgrep -z global -f "start_sczbt -R ${RESOURCE} " >/dev/null 2>&1
1259 then
1260 debug_message "Function: check_sczbt - Start program is still running "
1261 rc_check_sczbt=100
1262 return ${rc_check_sczbt}
1263 fi
1264
1265 # do a reduced check as long as the gds_svc_start is running otherwise do an extensive check
1266
1267 if /bin/pgrep -z global -f "gds_svc_start .*-R ${RESOURCE} " >/dev/null 2>&1
1268 then
1269
1270 # check if the scheduler is running
1271
1272 if ! pgrep -z ${Zonename} zsched>/dev/null 2>&1
1273 then
1274 rc_check_sczbt=100
1275 debug_message "Function: check_sczbt - Early end"
1276 return ${rc_check_sczbt}
1277 fi
1278
1279 # check if zone service is online
1280
1281 case ${Zonebrand} in
1282 native)
1283 get_svc_state ${Zonename} ${Milestone}
1284
1285 if [ "${SVC_STATE}" != "online" -a "${SVC_STATE}" != "degraded" ]
1286 then
1287 rc_check_sczbt=100
1288 debug_message "Function: check_sczbt - ${Zonename} milestone (${Milestone}) state is ${SVC_STATE}"
1289 return ${rc_check_sczbt}
1290 fi;;
1291 lx)
1292 if get_lx_state ${Zonename}
1306 solaris8)
1307 if get_solaris_legacy_state ${Zonename}
1308 then
1309 if [ "${SOLARIS_LEGACY_STATE}" != "${SLrunlevel}" ]
1310 then
1311 rc_check_sczbt=100
1312 debug_message "Function: check_sczbt - ${Zonename} runlevel (${SLrunlevel}) state is ${SOLARIS_LEGACY_STATE}"
1313 return ${rc_check_sczbt}
1314 fi
1315 else
1316 rc_check_sczbt=100
1317 debug_message "Function: check_sczbt - runlevel did not return successfully (return code ${rc_get_solaris_legacy_state}) for the non-global zone {Zonename}"
1318 return ${rc_check_sczbt}
1319 fi;;
1320 esac
1321
1322 else
1323
1324 # check if the scheduler is running
1325
1326 if ! pgrep -z ${Zonename} zsched>/dev/null 2>&1
1327 then
1328 # SCMSGS
1329 # @explanation
1330 # The zsched prcess of the referenced zone is not
1331 # running. The zone is not operable.
1332 # @user_action
1333 # None. The resource will be restarted or the resource
1334 # group will be failed over.
1335 scds_syslog -p daemon.err -t $(syslog_tag) -m \
1336 "Function: check_sczbt - Zone scheduler for %s not running" \
1337 "${Zonename}"
1338 rc_check_sczbt=100
1339 debug_message "Function: check_sczbt - Early end"
1340 return ${rc_check_sczbt}
1341 fi
1342
1343 # check if the ip addresses of the logical hoists are online
1344
1345 LH_LIST=`${SCHA_RESOURCE_GET} -O NETWORK_RESOURCES_USED -R ${RESOURCE} -G ${RESOURCEGROUP}`
1346
1347 if [ "${LH_LIST}" ]
1348 then
1349
1350 ip_config=`${IFCONFIG} -a`
1351
1352 for LH in ${LH_LIST}
1353 do
1354 get_ipmp_hosts ${LH}
1355
1356 for i in ${IPMP_HOST_IP}
1357 do
1358 if ! echo ${ip_config} |grep -w ${i}>/dev/null 2>&1
1359 then
1360 # SCMSGS
1361 # @explanation
1362 # The referenced zones ip
1363 # address is unplumbed.
1364 # @user_action
1365 # None. The resource will be
1366 # restarted or the resource
1367 # group will be failed over.
1368 scds_syslog -p daemon.err -t $(syslog_tag) -m \
1369 "Function: check_sczbt - Zones %s ip address %s is not running" \
1370 "${Zonename}" "${i}"
1371 rc_check_sczbt=201
1372 debug_message "Function: check_sczbt - immediate failover"
1373
1374 return ${rc_check_sczbt}
1375 fi
1376 done
1377 done
1378 fi
|
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
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" \
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
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
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 ☆ 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}
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
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
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" \
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
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}
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
|