New xvm_register.ksh
1 #!/usr/bin/ksh
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the License).
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/CDDL.txt
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/CDDL.txt.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets [] replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
24 #
25 #ident "@(#)xvm_register.ksh 1.1 08/11/19 SMI"
26 #
27 # DO NOT EDIT THIS FILE
28
29 rc=0
30 typeset opt
31
32 while getopts 'f:' opt
33 do
34 case "$opt" in
35 f) MYCONFIG=${OPTARG};;
36 *) echo "ERROR: ${MYNAME} Option ${OPTARG} unknown"
37 echo "Usage: ${MYNAME} -f <config file>"
38 exit 1;;
39 esac
40 done
41
42 [ -z "${MYCONFIG}" ] && MYCONFIG=/opt/SUNWscxvm/util/xvm_config
43
44 . ${MYCONFIG}
45
46 for i in RS RG DOMAIN FAILOVER ADMIN
47 do
48 if eval [ -z \$$i ]
49 then
50 /usr/bin/printf "xvm_register requires a value for $i= within ${MYCONFIG}\n"
51 rc=1
52 fi
53 done
54
55 [ "${rc}" -ne 0 ] && exit 1
56
57 if [ "${#LH_RS}" -ne 0 ]
58 then
59 RESOURCE_DEPENDENCIES="-p Resource_dependencies=${LH_RS}"
60 NETWORK_AWARE="-p NETWORK_AWARE=true"
61 else
62 RESOURCE_DEPENDENCIES=""
63 NETWORK_AWARE="-p NETWORK_AWARE=false"
64 fi
65
66 if [ "${#HAS_RS}" -ne 0 ]
67 then
68 if [ "${#RESOURCE_DEPENDENCIES}" -ne 0 ]
69 then
70 RESOURCE_DEPENDENCIES="${RESOURCE_DEPENDENCIES},${HAS_RS}"
71 else
72 RESOURCE_DEPENDENCIES="-p Resource_dependencies=${HAS_RS}"
73 fi
74 fi
75
76 if [ "${#PLUGIN_PROBE}" -ne 0 ]
77 then
78 PLUGIN_PROBE="-P '${PLUGIN_PROBE}'"
79 else
80 PLUGIN_PROBE=""
81 fi
82
83 /usr/cluster/bin/clrs create -g ${RG} -t SUNW.gds \
84 -p Start_command="/opt/SUNWscxvm/bin/control_xvm start \
85 -R '${RS}' -G '${RG}' -D '${DOMAIN}' -M '${FAILOVER}' ${PLUGIN_PROBE} -A '${ADMIN}' " \
86 -p Stop_command="/opt/SUNWscxvm/bin/control_xvm stop \
87 -R '${RS}' -G '${RG}' -D '${DOMAIN}' -M '${FAILOVER}' ${PLUGIN_PROBE} -A '${ADMIN}' " \
88 -p Probe_command="/opt/SUNWscxvm/bin/control_xvm probe \
89 -R '${RS}' -G '${RG}' -D '${DOMAIN}' -M '${FAILOVER}' ${PLUGIN_PROBE} -A '${ADMIN}' " \
90 -p Validate_command="/opt/SUNWscxvm/bin/control_xvm validate \
91 -R '${RS}' -G '${RG}' -D '${DOMAIN}' -M '${FAILOVER}' ${PLUGIN_PROBE} -A '${ADMIN}' " \
92 -p Port_list=23/tcp -p Stop_signal=9 -p Stop_timeout=600 \
93 ${NETWORK_AWARE} ${RESOURCE_DEPENDENCIES} \
94 ${RS}
95
96 exit $?