1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
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/OPENSOLARIS.LICENSE.
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 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26
27 #
28 # NAME
29 # sbdadm_create_info
30 # DESCRIPTION
31 # Store information about stored objects based on information
32 # passed to the function as arguments.
33 #
34 # RETURN
35 # void
36 #
37 function sbdadm_create_info
38 {
39 typeset option=$*
40 while getopts s: option
41 do
42 case $option in
43 s)
44 typeset size=$OPTARG
45 ;;
46 *)
47 cti_fail "FAIL - unknow option - $option"
48 ;;
49 esac
50 done
51
52 eval typeset object=\${$#}
53 typeset synopsis=`basename $object`
54 echo "${G_VOL}" |grep -w $synopsis >/dev/null 2>&1
55 if [ $? -ne 0 ]; then
56 G_VOL="$synopsis $G_VOL"
57 fi
58
59 echo $size | grep -i k >/dev/null 2>&1
60 if [ $? -eq 0 ];then
61 num=`echo $size |sed "s/k//g"`
62 (( bytes=$num*1024))
63 fi
64 echo $size | grep -i m >/dev/null 2>&1
65 if [ $? -eq 0 ];then
66 num=`echo $size |sed "s/m//g"`
67 (( bytes=$num*1048576))
68 fi
69 echo $size | grep -i g >/dev/null 2>&1
70 if [ $? -eq 0 ];then
71 num=`echo $size |sed "s/g//g"`
72 (( bytes=$num*1073741824))
73 fi
74 echo $size | grep -i t >/dev/null 2>&1
75 if [ $? -eq 0 ];then
76 num=`echo $size |sed "s/t//g"`
77 (( bytes=$num*1099511627776))
78 fi
79 eval typeset object=\${$#}
80 typeset synopsis=`basename $object`
81
82 eval LU_${synopsis}_SOURCE="$object"
83 eval LU_${synopsis}_SIZE="$bytes"
84 eval LU_${synopsis}_GUID="`$SBDADM list-lu | \
85 grep $object | awk '{print \$1}'`"
86 eval LU_${synopsis}_IM_SIZE="$bytes"
87 eval LU_${synopsis}_IM_GUID="`$SBDADM list-lu | \
88 grep $object | awk '{print \$1}'`"
89
90 eval typeset -u u_guid="\$LU_${synopsis}_GUID"
91 eval LU_${u_guid}_ONLINE=Y
92 }
93
94 #
95 # NAME
96 # sbdadm_modify_info
97 # DESCRIPTION
98 # Modify information about modified objects based on information
99 # passed to the function as arguments.
100 #
101 # RETURN
102 # void
103 #
104 function sbdadm_modify_info
105 {
106 typeset option=$*
107 while getopts s: option
108 do
109 case $option in
110 s)
111 typeset size=$OPTARG
112 ;;
113 *)
114 cti_fail "FAIL - unknow option - $option"
115 ;;
116 esac
117 done
118 eval typeset object=\${$#}
119 typeset synopsis=`basename $object`
120 if [ "$object" = "$synopsis" ];then
121 #it's GUID input
122 for vol in $G_VOL
123 do
124 eval typeset t_guid=\$LU_${vol}_GUID
125 if [ "$t_guid" = "$object" ];then
126 object=$vol
127 break
128 fi
129 done
130 else
131 #it's file full path input
132 object=$synopsis
133 fi
134
135 echo $size | grep -i k >/dev/null 2>&1
136 if [ $? -eq 0 ];then
137 num=`echo $size |sed "s/k//g"`
138 (( bytes=$num*1024))
139 fi
140 echo $size | grep -i m >/dev/null 2>&1
141 if [ $? -eq 0 ];then
142 num=`echo $size |sed "s/m//g"`
143 (( bytes=$num*1048576))
144 fi
145 echo $size | grep -i g >/dev/null 2>&1
146 if [ $? -eq 0 ];then
147 num=`echo $size |sed "s/g//g"`
148 (( bytes=$num*1073741824))
149 fi
150 echo $size | grep -i t >/dev/null 2>&1
151 if [ $? -eq 0 ];then
152 num=`echo $size |sed "s/t//g"`
153 (( bytes=$num*1099511627776))
154 fi
155 eval LU_${object}_SIZE="$bytes"
156 eval LU_${object}_IM_SIZE="$bytes"
157
158 }
159
160 #
161 # NAME
162 # sbdadm_delete_info
163 # DESCRIPTION
164 # Delete information about deleted objects based on information
165 # passed to the function as arguments.
166 #
167 # RETURN
168 # void
169 #
170 function sbdadm_delete_info
171 {
172 typeset option=$*
173 typeset keep_view=0
174 while getopts k option
175 do
176 case $option in
177 k)
178 typeset keep_view=1
179 ;;
180 *)
181 cti_fail "FAIL - unknow option - $option"
182 ;;
183 esac
184 done
185 eval typeset guid=\${$#}
186 typeset vol
187 for vol in $G_VOL
188 do
189
190 eval typeset guid_iter=\$LU_${vol}_GUID
191 if [ "$guid" = "$guid_iter" ];then
192 if [ $keep_view -eq 0 ];then
193 stmfadm_remove_info view -l $guid -a
194 fi
195 eval unset LU_${vol}_SOURCE
196 eval unset LU_${vol}_SIZE
197 eval unset LU_${vol}_GUID
198 echo "${G_VOL}" |grep -w $vol >/dev/null 2>&1
199 if [ $? -eq 0 ]; then
200 G_VOL=`echo $G_VOL | sed -e "s/\<$vol\>//g" | \
201 sed 's/^ *//g'`
202 typeset -u u_guid=$guid
203 eval LU_${u_guid}_ONLINE=N
204 fi
205 if [ $keep_view -eq 1 ];then
206 compare_lu_view $guid
207 fi
208 fi
209 done
210
211 }
212
213 #
214 # NAME
215 # sbdadm_import_info
216 # DESCRIPTION
217 # Store information about stored objects based on information
218 # passed to the function as arguments.
219 #
220 # RETURN
221 # void
222 #
223 function sbdadm_import_info
224 {
225 typeset option=$*
226
227 eval typeset object=\${$#}
228 typeset synopsis=`basename $object`
229 echo "${G_VOL}" |grep -w $synopsis >/dev/null 2>&1
230 if [ $? -ne 0 ]; then
231 G_VOL="$synopsis $G_VOL"
232 fi
233
234 eval LU_${synopsis}_SOURCE="$object"
235 eval LU_${synopsis}_SIZE=\$LU_${synopsis}_IM_SIZE
236 eval LU_${synopsis}_GUID=\$LU_${synopsis}_IM_GUID
237
238 eval typeset -u u_guid="\$LU_${synopsis}_GUID"
239 eval LU_${u_guid}_ONLINE=Y
240 }
241
242