xref: /titanic_44/usr/src/cmd/mpathadm/mpathadm_text.c (revision f169c0eae91b2ee787cf8d6dcf8edd9159d4c9e2)
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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * mpathadm_text.c : MP API CLI program
28  *
29  */
30 
31 #include <libintl.h>
32 
33 #include <mpapi.h>
34 #include "mpathadm_text.h"
35 
36 
37 MP_CHAR * getTextString(int stringVal) {
38 	switch (stringVal) {
39 		case TEXT_UNKNOWN:
40 			return (gettext("unknown"));
41 
42 		/* load balance types for display and input to cli */
43 		case TEXT_LBTYPE_FAILOVER_ONLY:
44 			return ("failover-only");
45 		case TEXT_LBTYPE_LBAREGION:
46 			return ("logical-block");
47 		case TEXT_LBTYPE_DEVICEPROD:
48 			return ("device-product-specific");
49 		case TEXT_LBTYPE_LEASTIO:
50 			return ("least-used");
51 		case TEXT_LBTYPE_LEASTBLOCKS:
52 			return ("least-blocks");
53 		case TEXT_LBTYPE_ROUNDROBIN:
54 			return ("round-robin");
55 		case TEXT_LBTYPE_UNKNOWN:
56 			return ("unknown");
57 		case TEXT_LBTYPE_NONE:
58 			return ("none");
59 		case TEXT_LBTYPE_PROPRIETARY1:
60 			return ("proprietary1");
61 		case TEXT_LBTYPE_PROPRIETARY2:
62 			return ("proprietary2");
63 		case TEXT_LBTYPE_PROPRIETARY3:
64 			return ("proprietary3");
65 		case TEXT_LBTYPE_PROPRIETARY4:
66 			return ("proprietary4");
67 		case TEXT_LBTYPE_PROPRIETARY5:
68 			return ("proprietary5");
69 		case TEXT_LBTYPE_PROPRIETARY6:
70 			return ("proprietary6");
71 		case TEXT_LBTYPE_PROPRIETARY7:
72 			return ("proprietary7");
73 		case TEXT_LBTYPE_PROPRIETARY8:
74 			return ("proprietary8");
75 		case TEXT_LBTYPE_PROPRIETARY9:
76 			return ("proprietary9");
77 		case TEXT_LBTYPE_PROPRIETARY10:
78 			return ("proprietary10");
79 		case TEXT_LBTYPE_PROPRIETARY11:
80 			return ("proprietary11");
81 		case TEXT_LBTYPE_PROPRIETARY12:
82 			return ("proprietary12");
83 		case TEXT_LBTYPE_PROPRIETARY13:
84 			return ("proprietary13");
85 		case TEXT_LBTYPE_PROPRIETARY14:
86 			return ("proprietary14");
87 		case TEXT_LBTYPE_PROPRIETARY15:
88 			return ("proprietary15");
89 		case TEXT_LBTYPE_PROPRIETARY16:
90 			return ("proprietary16");
91 
92 		/* used for display */
93 		case TEXT_NA:
94 			return (gettext("NA"));
95 
96 		/* used for displaying of state and comparing input into cli */
97 		case TEXT_YES:
98 			return (gettext("yes"));
99 		case TEXT_NO:
100 			return (gettext("no"));
101 		case TEXT_ON:
102 			return ("on");
103 		case TEXT_OFF:
104 			return ("off");
105 
106 		/* labels for display */
107 		case TEXT_LB_VENDOR:
108 			return ("Vendor:");
109 		case TEXT_LB_DRIVER_NAME:
110 			return ("Driver Name:");
111 		case TEXT_LB_DEFAULT_LB:
112 			return ("Default Load Balance:");
113 		case TEXT_LB_SUPPORTED_LB:
114 			return ("Supported Load Balance Types:");
115 		case TEXT_LB_ALLOWS_ACT_TPG:
116 			return ("Allows To Activate Target Port Group Access:");
117 		case TEXT_LB_ALLOWS_PATH_OV:
118 			return ("Allows Path Override:");
119 		case TEXT_LB_SUPP_AUTO_FB:
120 			return ("Supported Auto Failback Config:");
121 		case TEXT_LB_AUTO_FB:
122 			return ("Auto Failback:");
123 		case TEXT_LB_FB_POLLING_RATE:
124 			return ("Failback Polling Rate (current/max):");
125 		case TEXT_LB_SUPP_AUTO_P:
126 			return ("Supported Auto Probing Config:");
127 		case TEXT_LB_AUTO_PROB:
128 			return ("Auto Probing:");
129 		case TEXT_LB_PR_POLLING_RATE:
130 			return ("Probing Polling Rate (current/max):");
131 		case TEXT_LB_SUPP_DEVICES:
132 			return ("Supported Devices:");
133 		case TEXT_LB_PRODUCT:
134 			return ("Product:");
135 		case TEXT_LB_REVISION:
136 			return ("Revision:");
137 		case TEXT_LB_LOGICAL_UNIT:
138 			return ("Logical Unit:");
139 		case TEXT_LB_INQUIRY_NAME_TYPE:
140 			return ("Name Type:");
141 		case TEXT_NAME_TYPE_UNKNOWN:
142 			return ("unknown type");
143 		case TEXT_NAME_TYPE_VPD83_TYPE1:
144 			return ("SCSI Inquiry VPD Page83 Type1");
145 		case TEXT_NAME_TYPE_VPD83_TYPE2:
146 			return ("SCSI Inquiry VPD Page83 Type2");
147 		case TEXT_NAME_TYPE_VPD83_TYPE3:
148 			return ("SCSI Inquiry VPD Page83 Type3");
149 		case TEXT_NAME_TYPE_DEVICE_SPECIFIC:
150 			return ("device specific type");
151 		case TEXT_LB_INQUIRY_NAME:
152 			return ("Name:");
153 		case TEXT_LB_ASYMMETRIC:
154 			return ("Asymmetric:");
155 		case TEXT_LB_EXPLICIT_FAILOVER:
156 			return ("Explicit Failover:");
157 		case TEXT_LB_CURR_LOAD_BALANCE:
158 			return ("Current Load Balance:");
159 		case TEXT_LB_LU_GROUP_ID:
160 			return ("Logical Unit Group ID:");
161 		case TEXT_LB_PATH_INFO:
162 			return ("Paths:");
163 		case TEXT_LB_INIT_PORT_NAME:
164 			return ("Initiator Port Name:");
165 		case TEXT_LB_TARGET_PORT_NAME:
166 			return ("Target Port Name:");
167 		case TEXT_LB_OVERRIDE_PATH:
168 			return ("Override Path:");
169 		case TEXT_LB_PATH_STATE:
170 			return ("Path State:");
171 		case TEXT_LB_TPG_INFO:
172 			return ("Target Port Groups:");
173 		case TEXT_LB_ACCESS_STATE:
174 			return ("Access State:");
175 		case TEXT_LB_ID:
176 			return ("ID:");
177 		case TEXT_TPORT_LIST:
178 			return ("Target Ports:");
179 		case TEXT_LB_NAME:
180 			return ("Name:");
181 		case TEXT_LB_RELATIVE_ID:
182 			return ("Relative ID:");
183 		case TEXT_LB_INITATOR_PORT:
184 			return ("Initiator Port:");
185 		case TEXT_LB_TRANSPORT_TYPE:
186 			return ("Transport Type:");
187 		case TEXT_LB_OS_DEVICE_FILE:
188 			return ("OS Device File:");
189 		case TEXT_LB_MPATH_SUPPORT:
190 			return ("mpath-support:");
191 		case TEXT_LB_PATH_COUNT:
192 			return ("Total Path Count:");
193 		case TEXT_LB_OP_PATH_COUNT:
194 			return ("Operational Path Count:");
195 
196 		case TEXT_LB_ENABLED:
197 			return ("Enabled:");
198 		case TEXT_LB_DISABLED:
199 			return ("Disabled:");
200 
201 		case TEXT_UNKNOWN_OBJECT:
202 			return (gettext("unknown object"));
203 
204 		/* status strings used in error messages */
205 		case TEXT_MPSTATUS_SUCCESS:
206 			return (gettext("success"));
207 		case TEXT_MPSTATUS_INV_PARAMETER:
208 			return (gettext("invalid parameter"));
209 		case TEXT_MPSTATUS_UNKNOWN_FN:
210 			return (gettext("unknown client function"));
211 		case TEXT_MPSTATUS_FAILED:
212 			return (gettext("failed"));
213 		case TEXT_MPSTATUS_INSUFF_MEMORY:
214 			return (gettext("insufficient memory"));
215 		case TEXT_MPSTATUS_INV_OBJ_TYPE:
216 			return (gettext("invalid object type"));
217 		case TEXT_MPSTATUS_OBJ_NOT_FOUND:
218 			return (gettext("object not found"));
219 		case TEXT_MPSTATUS_UNSUPPORTED:
220 			return (gettext("unsupported"));
221 		case TEXT_MPSTATUS_FN_REPLACED:
222 			return (gettext("function replaced"));
223 		case TEXT_MPSTATUS_ACC_STATE_INVAL:
224 			return (gettext("invalid access state"));
225 		case TEXT_MPSTATUS_PATH_NONOP:
226 			return (gettext("path not operational"));
227 		case TEXT_MPSTATUS_TRY_AGAIN:
228 			return (gettext("try again"));
229 		case TEXT_MPSTATUS_NOT_PERMITTED:
230 			return (gettext("not permitted"));
231 
232 		/* error messages */
233 		case ERR_NO_MPATH_SUPPORT_LIST:
234 			return (gettext("Error: Unable to get mpath-support "
235 			    "list."));
236 		case ERR_CANT_FIND_MPATH_SUPPORT_WITH_NAME:
237 			return (gettext("Error: Unable to find mpath-support "
238 			    "%s."));
239 		case ERR_NO_PROPERTIES:
240 			return (gettext("Error: Unable to get configuration "
241 			    "information."));
242 		case ERR_NO_SUPP_DEVICE_INFO:
243 			return (gettext("Error: Unable to get supported "
244 			    "device product information."));
245 		case ERR_NO_LU_LIST:
246 			return (gettext("Error: Unable to get the logical "
247 			    "unit list."));
248 		case ERR_NO_ASSOCIATED_LU:
249 			return (gettext("Error: Unable to find an "
250 			    "associated logical-unit."));
251 		case ERR_LU_NOT_FOUND_WITH_MISSING_LU_STR:
252 			return (gettext("Error: Logical-unit %s is not "
253 			    "found."));
254 		case ERR_NO_LU_PATH_INFO_WITH_MISSING_LU_STR:
255 			return (gettext("Error: Failed to get path info for "
256 			    "logical-unit %s."));
257 		case ERR_NO_ASSOC_TPGS:
258 			return (gettext("Error: Unable to get associated "
259 			    "target port groups ."));
260 		case ERR_NO_ASSOC_TPORTS:
261 			return (gettext("Error: Unable to get associated "
262 			    "target ports."));
263 		case ERR_NO_INIT_PORTS:
264 			return (gettext("Error: Unable to get the "
265 			    "initiator-port list."));
266 		case ERR_NO_INIT_PORT_LIST_WITH_REASON:
267 			return (gettext("Error: Unable to get the "
268 			    "initiator-port list: %s."));
269 		case ERR_INIT_PORT_NOT_FOUND_WITH_MISSING_LU_STR:
270 			return (gettext("Error: Initiator port %s is not "
271 			    "found."));
272 		case ERR_FAILED_TO_REGISTER_PLUGIN_NAME_WITH_REASON:
273 			return (gettext("Error: Failed to register %s: %s."));
274 		case ERR_FAILED_TO_DEREGISTER_PLUGIN_NAME_WITH_REASON:
275 			return (gettext("Error: Failed to deregister "
276 			    "%ls: %s."));
277 		case ERR_FAILED_TO_CHANGE_OPTION_WITH_REASON:
278 			return (gettext("Error: Failed to change %s: %s."));
279 		case ERR_FAILED_TO_ENABLE_PATH_WITH_REASON:
280 			return (gettext("Error: Failed to enable path: %s."));
281 		case ERR_FAILED_TO_DISABLE_PATH_WITH_REASON:
282 			return (gettext("Error: Failed to disable path: %s."));
283 		case ERR_FAILED_TO_OVERRIDE_PATH_WITH_REASON:
284 			return (gettext("Error: Failed to override path: "
285 			    "%s."));
286 		case ERR_LU_NOT_ASYMMETRIC:
287 			return (gettext("Error: The logical unit is not "
288 			    "asymmetric."));
289 		case ERR_NO_FAILOVER_ALLOWED:
290 			return (gettext("Error: The logical unit doesn't "
291 			    "support explicit state change."));
292 		case ERR_FAILED_TO_FAILOVER_WITH_LU_AND_REASON:
293 			return (gettext("Error: Failover failed %s: %s."));
294 		case ERR_FAILED_TO_FAILOVER_WITH_REASON:
295 			return (gettext("Error: Failover failed: %s."));
296 		case ERR_FAILED_TO_CANCEL_OVERRIDE_PATH_WITH_REASON:
297 			return (gettext("Error: Failed to cancel the "
298 			    "overriding setting:  %s."));
299 		case ERR_FAILED_TO_FIND_PATH:
300 			return (gettext("Error: Unable to find path."));
301 		case LU_NOT_FOUND:
302 			return (gettext("logical-unit not found"));
303 		case FAILED_TO_FIND_PATH:
304 			return (gettext("Unable to find path"));
305 		case MISSING_LU_NAME:
306 			return (gettext("Missing logical-unit name"));
307 		case MISSING_INIT_PORT_NAME:
308 			return (gettext("Missing initiator-port name"));
309 		case MISSING_TARGET_PORT_NAME:
310 			return (gettext("Missing target-port name"));
311 		case TEXT_AUTO_FAILBACK:
312 			return (gettext("auto failback"));
313 		case TEXT_AUTO_PROBING:
314 			return (gettext("auto probing"));
315 		case TEXT_LOAD_BALANCE:
316 			return (gettext("load balance"));
317 		case TEXT_ILLEGAL_ARGUMENT:
318 			return (gettext("illegal argument"));
319 		case TEXT_MPATH_SUPPORT_NOT_FOUND:
320 			return (gettext("unable to find specified "
321 			    "mpath-support"));
322 		case ERR_MEMORY_ALLOCATION:
323 			return (gettext("Error: Memory allocation failure"));
324 		case TEXT_MORE_INFO:
325 			return (gettext("For more information, please see"));
326 		case TEXT_UNABLE_TO_COMPLETE:
327 			return (gettext("Unable to complete operation"));
328 		case ERR_FILE_DESCRIPTOR:
329 			return (gettext("ERROR: Failed getting file "
330 			    "descriptor"));
331 		case ERR_DEVID:
332 			return (gettext("ERROR: Failed attempt to get devid "
333 			    "information"));
334 		case ERR_LU_ACCESS_STATE_UNCHANGED:
335 			return (gettext("ERROR: LU access state unchanged.  "
336 			    "No standby TPG found."));
337 
338 		/* strings to display info */
339 		case TEXT_PATH_STATE_OKAY:
340 			return ("OK");
341 		case TEXT_PATH_STATE_PATH_ERR:
342 			return ("path error");
343 		case TEXT_PATH_STATE_LU_ERR:
344 			return ("LU error");
345 		case TEXT_PATH_STATE_RESERVED:
346 			return ("reserved");
347 		case TEXT_PATH_STATE_REMOVED:
348 			return ("unavailable");
349 		case TEXT_PATH_STATE_TRANSITIONING:
350 			return ("transitioning");
351 		case TEXT_PATH_STATE_OPERATIONAL_CLOSED:
352 			return ("operational but closed");
353 		case TEXT_PATH_STATE_INVALID_CLOSED:
354 			return ("invalid closed");
355 		case TEXT_PATH_STATE_OFFLINE_CLOSED:
356 			return ("operational but closed");
357 		case TEXT_ACCESS_STATE_ACTIVE_OPTIMIZED:
358 			return ("active optimized");
359 		case TEXT_ACCESS_STATE_ACTIVE_NONOPTIMIZED:
360 			return ("active not optimized");
361 		case TEXT_ACCESS_STATE_STANDBY:
362 			return ("standby");
363 		case TEXT_ACCESS_STATE_UNAVAILABLE:
364 			return ("unavailable");
365 		case TEXT_ACCESS_STATE_TRANSITIONING:
366 			return ("transitioning");
367 		case TEXT_ACCESS_STATE_ACTIVE:
368 			return ("active");
369 		case TEXT_ANY_DEVICE:
370 			return ("any device");
371 
372 		case TEXT_TRANS_PORT_TYPE_MPNODE:
373 			return ("Logical Multipath Port");
374 		case TEXT_TRANS_PORT_TYPE_FC:
375 			return ("Fibre Channel");
376 		case TEXT_TRANS_PORT_TYPE_SPI:
377 			return ("parallel SCSI");
378 		case TEXT_TRANS_PORT_TYPE_ISCSI:
379 			return ("iSCSI");
380 		case TEXT_TRANS_PORT_TYPE_IFB:
381 			return ("InfiniBand-Fibre Channel");
382 
383 
384 		default:
385 			return ("");
386 	}
387 }
388