Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- /workspace/neilga/ohacds-ids/webrev/usr/src/cmd/ha-services/gds-agents/ids/ids_register.ksh-
+++ ids_register.ksh
1 1 #!/usr/bin/ksh
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the License).
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/CDDL.txt
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/CDDL.txt.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets [] replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 # Use is subject to license terms.
24 24 #
25 25 #ident "%Z%%M% %I% %E% SMI"
26 26 #
27 27 # DO NOT EDIT THIS FILE
28 28
29 29 IDSDIR=/opt/SUNWscids/
30 30
31 31 typeset opt
32 32
33 33 while getopts 'f:' opt
34 34 do
35 35 case "$opt" in
36 36 f) MYCONFIG=${OPTARG};;
|
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
37 37 *) /usr/bin/echo "ERROR: ${MYNAME} Option ${OPTARG} unknown"
38 38 /usr/bin/echo "Usage: ${MYNAME} -f <config file>"
39 39 exit 1;;
40 40 esac
41 41 done
42 42
43 43 [ -z "${MYCONFIG}" ] && MYCONFIG=/opt/SUNWscids/util/ids_config
44 44
45 45 . ${MYCONFIG}
46 46
47 +for i in RS RG USERID INFORMIXDIR ONCONFIG INFORMIXSERVER INFORMIXSQLHOSTS
48 +do
49 + if eval [ -z \$$i ]
50 + then
51 + /usr/bin/printf "ids requires a value for $i= within ${MYCONFIG}\n"
52 + rc=1
53 + fi
54 +done
55 +
56 +[ "${rc}" -ne 0 ] && exit 1
57 +
47 58 if [ -z ${RS_ZONE} ]
48 59 then
49 60
50 61 /usr/cluster/bin/clrs create -g ${RG} -t SUNW.gds \
51 62 -p Start_command="/opt/SUNWscids/bin/control_ids \
52 63 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \
53 64 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' start ids " \
54 65 -p Stop_command="/opt/SUNWscids/bin/control_ids \
55 66 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \
56 67 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' stop ids " \
57 68 -p Probe_command="/opt/SUNWscids/bin/control_ids \
58 69 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \
59 70 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' probe ids " \
60 71 -p Validate_command="/opt/SUNWscids/bin/control_ids \
61 72 -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' \
62 73 -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' validate ids " \
63 74 -p Port_list=23/tcp -p Stop_signal=9 \
64 75 -y Resource_dependencies=${HAS_RS},${LH_RS} \
65 76 ${RS}
66 77
67 78 else
68 79 # Process a failover zone registration
69 80 #
70 81 # 1. Validate ${START_TIMEOUT} and ${STOP_TIMEOUT}
71 82 # 2. Get the failover zone's pfile and determine failover zone name
72 83 # 3. Build a temporary sczsmf_config file
73 84 # 4. zlogin to the failover zone execute ids_smf_register
74 85 # - Creates the SMF manifest using parameter values
75 86 # - Validate and import the SMF manifest into the SMF repository
76 87 # 5. Register a SC sczsmf resource to enable/disable the SMF instance
77 88
78 89 RS_STATE=`/usr/cluster/bin/scha_resource_get -O status -R ${RS}`
79 90 rc=$?
80 91
81 92 if [ "${rc}" -eq 0 ]
82 93 then
83 94 /usr/bin/printf "Sun Cluster resource ${RS} already exists\n"
84 95 /usr/bin/printf "Cleanup resource before retrying\n"
85 96 exit 1
86 97 fi
87 98
88 99 if ! [ "${START_TIMEOUT}" -ge 0 ] 2> /dev/null
89 100 then
90 101 /usr/bin/printf "START_TIMEOUT value is not an integer\n"
91 102 exit 1
92 103 fi
93 104
94 105 if ! [ "${STOP_TIMEOUT}" -ge 0 ] 2> /dev/null
95 106 then
96 107 /usr/bin/printf "STOP_TIMEOUT value is not an integer\n"
97 108 exit 1
98 109 fi
99 110
100 111 ZONEPFILE=`/usr/cluster/bin/clrs show -p Start_command ${RS_ZONE} | /usr/bin/grep -w Start_command | \
|
↓ open down ↓ |
44 lines elided |
↑ open up ↑ |
101 112 /usr/bin/awk '{ if ($7 == "-P") print $8 }'`
102 113
103 114 if [ ! -d "${ZONEPFILE}" ]
104 115 then
105 116 /usr/bin/printf "Unable to retrieve zone parameter file directory\n"
106 117 exit 1
107 118 else
108 119 ZONE=`/usr/bin/grep Zonename= ${ZONEPFILE}/sczbt_${RS_ZONE} | /usr/bin/awk -F= '{print $2}' | /usr/xpg4/bin/tr -d '"' `
109 120 fi
110 121
122 + # VALIDATE RESOURCE
123 +
124 + if /usr/sbin/zlogin ${ZONE} "/opt/SUNWscids/bin/control_ids -R '${RS}' -G '${RG}' -U '${USERID}' -D '${INFORMIXDIR}' -C '${ONCONFIG}' -S '${INFORMIXSERVER}' -H '${INFORMIXSQLHOSTS}' validate ids "
125 + then
126 + /usr/bin/printf "Validation of ${RS} succeeded\n"
127 + else
128 + /usr/bin/printf "Validation of ${RS} failed\n"
129 + /usr/bin/printf "Check the syslog for ${ZONE}\n"
130 + exit 1
131 + fi
132 +
111 133 SERVICE_TAG=svc:/application/sczone-agents:${RS}
112 134
113 135 /usr/bin/cat > /var/tmp/${RS}_smf_config <<-EOF
114 136 RS=${RS}
115 137 RG=${RG}
116 138 SCZBT_RS=${RS_ZONE}
117 139 ZONE=${ZONE}
118 140 SERVICE=${SERVICE_TAG}
119 141 RECURSIVE=true
120 142 STATE=true
121 143 SERVICE_PROBE="/opt/SUNWscids/bin/control_ids probe ids ${SERVICE_TAG}"
122 144 EOF
123 145
124 146 TMP_WORK_CONFIG=/var/tmp/${RS}_tmp_work_config
125 147 /usr/bin/cat ${MYCONFIG} | /usr/sbin/zlogin ${ZONE} /usr/bin/cat - \> ${TMP_WORK_CONFIG}
|
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
126 148
127 149 # Remove an existing FMRI in the zone if it already exists
128 150 ${IDSDIR}/util/ids_smf_remove -z ${ZONE} -f ${SERVICE_TAG} 2>/dev/null
129 151
130 152 # Create and register the ${SERVICE_TAG}
131 153 if /usr/sbin/zlogin ${ZONE} ${IDSDIR}/util/ids_smf_register ${TMP_WORK_CONFIG}
132 154 then
133 155 if /opt/SUNWsczone/sczsmf/util/sczsmf_register -f /var/tmp/${RS}_smf_config
134 156 then
135 157 /usr/bin/printf "Registration of ${RS} succeeded\n"
158 +
159 + if ! /usr/cluster/bin/clrs set -p Start_timeout=${START_TIMEOUT} ${RS}
160 + then
161 + /usr/bin/printf "clrs set -p Start_timeout=${START_TIMEOUT} ${RS} failed\n"
162 + fi
163 +
164 + if ! /usr/cluster/bin/clrs set -p Stop_timeout=${STOP_TIMEOUT} ${RS}
165 + then
166 + /usr/bin/printf "clrs set -p Stop_timeout=${STOP_TIMEOUT} ${RS} failed\n"
167 + fi
136 168 else
137 169 /usr/bin/printf "Registration of ${RS} failed\n"
138 170 exit 1
139 171 fi
140 172 fi
141 173 fi
142 174
143 175 exit 0
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX