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, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
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/OPENSOLARIS.LICENSE.
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 /*
23 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <unistd.h>
30 #include <netdb.h>
31 #include <errno.h>
32
33 #include "util.h"
34 #include "cimKeys.h"
35 #include "ctrl_descriptors.h"
36 #include "providerNames.h"
37 #include "messageStrings.h"
38 #include "mpxiogroup_descriptors.h"
39 #include "Solaris_MPXIOGroup.h"
40
41 #define MPXIO_GETINSTANCE "MPXIO_GROUP,GET_INSTANCE"
42 #define MPXIO_ENUMINSTANCES "MPXIO_GROUP,ENUM_INSTANCES"
43 #define MPXIO_ENUMINSTANCENAMES "MPXIO_GROUP,ENUM_INSTANCENAMES"
44 #define MPXIO_CREATEINSTANCE "MPXIO_GROUP,CREATE_INSTANCE"
45 #define MPXIO_DELETEINSTANCE "MPXIO_GROUP,DELETE_INSTANCE"
46 #define MPXIO_SETINSTANCE "MPXIO_GROUP,SET_INSTANCE"
47 #define MPXIO_GETPROPERTY "MPXIO_GROUP,GET_PROPERTY"
48 #define MPXIO_SETPROPERTY "MPXIO_GROUP,SET_PROPERTY"
49 #define MPXIO_INVOKEMETHOD "MPXIO_GROUP,INVOKE_METHOD"
50 #define MPXIO_EXECQUERY "MPXIO_GROUP,EXEC_QUERY"
51
52
53 /*
54 * Solaris_MPXIOGroup provider
55 *
56 * It is important to note that all memory allocated by these functions
57 * and passed to the CIMOM, is freed by the CIMOM as the caller.
58 */
59
60
61 /*
62 * Name: cp_getInstance_Solaris_MPXIOGroup
63 *
64 * Description: Returns an instance which matches the passed in object path
65 * if found.
66 *
67 * Parameters:
68 * pOP - An CCIMObjectPath * which contains the information on
69 * the class for which to find the instance.
70 * Returns:
71 * CCIMInstance * if matched instance is found. Otherwise, NULL.
72 */
73
74 /* ARGSUSED */
75 CCIMInstance*
cp_getInstance_Solaris_MPXIOGroup(CCIMObjectPath * pOP)76 cp_getInstance_Solaris_MPXIOGroup(CCIMObjectPath* pOP)
77 {
78 CCIMInstance* inst = NULL;
79 CCIMPropertyList* pCurPropList;
80 dm_descriptor_t mpxioctrl_descriptor;
81 char *name;
82 int error;
83
84 if (pOP == NULL ||
85 pOP->mKeyProperties == NULL) {
86 util_handleError(MPXIO_GETINSTANCE, CIM_ERR_INVALID_PARAMETER,
87 NULL, NULL, &error);
88 return ((CCIMInstance *)NULL);
89 }
90
91 pCurPropList = pOP->mKeyProperties;
92 name = (cimchar *)util_getKeyValue(pCurPropList, string, DEVICEID,
93 &error);
94
95 if (error != 0 || name == NULL) {
96 util_handleError(MPXIO_GETINSTANCE, CIM_ERR_INVALID_PARAMETER, NULL,
97 NULL, &error);
98 return ((CCIMInstance*)NULL);
99 }
100
101 mpxioctrl_descriptor =
102 dm_get_descriptor_by_name(DM_CONTROLLER, name, &error);
103
104 /*
105 * Not found. Return a null instance.
106 */
107
108 if (error == ENODEV) {
109 return ((CCIMInstance *)NULL);
110 }
111
112 if (error != 0) {
113 util_handleError(MPXIO_GETINSTANCE, CIM_ERR_FAILED,
114 DM_GET_DESC_BYNAME_FAILURE, NULL, &error);
115 return ((CCIMInstance*)NULL);
116 }
117
118 /* Turn this descriptor in to a mpxio group instance */
119
120 inst = mpxiogroup_descriptor_toCCIMInstance(mpxioctrl_descriptor,
121 MPXIO_GROUP, &error);
122 dm_free_descriptor(mpxioctrl_descriptor);
123
124 if (error != 0) {
125 util_handleError(MPXIO_GETINSTANCE, CIM_ERR_FAILED,
126 MPXIOCTRL_DESC_TO_INSTANCE_FAILURE, NULL, &error);
127 return ((CCIMInstance*)NULL);
128 }
129
130 return (inst);
131 }
132
133 /*
134 * Name: cp_enumInstances_Solaris_MPXIOGroup
135 *
136 * Description: Returns a list of instances if found.
137 *
138 * Parameters:
139 * pOP - An CCIMObjectPath * which contains the information on
140 * the class for which to find the instance.
141 * Returns:
142 * CCIMInstanceList * if matched instance is found. Otherwise, NULL.
143 */
144
145 /* ARGSUSED */
146 CCIMInstanceList*
cp_enumInstances_Solaris_MPXIOGroup(CCIMObjectPath * pOP)147 cp_enumInstances_Solaris_MPXIOGroup(CCIMObjectPath* pOP)
148 {
149 CCIMInstanceList* instList = NULL;
150 dm_descriptor_t *mpxioctrl_descriptorp;
151 int error;
152 int filter[1];
153
154 filter[0] = DM_FILTER_END;
155
156 mpxioctrl_descriptorp = dm_get_descriptors(DM_CONTROLLER, filter,
157 &error);
158
159 /*
160 * If no devices, return NULL. CIMOM expects NULL. Do not set
161 * last error. If set, the CIMOM will assume an error and
162 * throw an exception.
163 */
164
165 if (mpxioctrl_descriptorp == NULL ||
166 mpxioctrl_descriptorp[0] == NULL) {
167 return ((CCIMInstanceList *)NULL);
168 }
169
170 if (error != 0) {
171 util_handleError(MPXIO_ENUMINSTANCES, CIM_ERR_FAILED,
172 DM_GET_DESCRIPTORS, NULL, &error);
173 return ((CCIMInstanceList *)NULL);
174 }
175
176 /* convert controller to CCIMInstanceList */
177 instList = mpxiogroup_descriptors_toCCIMInstanceList(MPXIO_GROUP,
178 mpxioctrl_descriptorp, &error);
179 dm_free_descriptors(mpxioctrl_descriptorp);
180
181 if (error != 0) {
182 util_handleError(MPXIO_ENUMINSTANCES, CIM_ERR_FAILED,
183 MPXIOCTRL_DESC_TO_INSTANCE_FAILURE, NULL, &error);
184 return ((CCIMInstanceList *)NULL);
185 }
186
187 return (instList);
188 }
189
190 /*
191 * Name: cp_enumInstanceNames_Solaris_MPXIOGroup
192 *
193 * Description: Returns a list of instances if found.
194 *
195 * Parameters:
196 * pOP - An CCIMObjectPath * which contains the information on
197 * the class for which to find the instance.
198 * Returns:
199 * CCIMObjectPathList * if matched instance is found. Otherwise, NULL.
200 */
201
202 /* ARGSUSED */
203 CCIMObjectPathList*
cp_enumInstanceNames_Solaris_MPXIOGroup(CCIMObjectPath * pOP)204 cp_enumInstanceNames_Solaris_MPXIOGroup(CCIMObjectPath * pOP) {
205
206 CCIMInstanceList *instList = NULL;
207 CCIMObjectPathList *objList = NULL;
208 int error;
209
210 if (pOP == NULL) {
211 util_handleError(MPXIO_ENUMINSTANCENAMES,
212 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
213 return ((CCIMObjectPathList *)NULL);
214 }
215
216 /*
217 * Call in to enumInstances and then convert the instance list in
218 * to an object list.
219 */
220
221 instList = cp_enumInstances_Solaris_MPXIOGroup(pOP);
222 if (instList != NULL) {
223 objList = cim_createObjectPathList(instList);
224 cim_freeInstanceList(instList);
225 }
226
227 return (objList);
228 }
229
230 /*
231 * Creating an instance of a Solaris_MPXIOGroup is not supported.
232 */
233
234 /* ARGSUSED */
235 CCIMObjectPath*
cp_createInstance_Solaris_MPXIOGroup(CCIMObjectPath * pOP,CCIMInstance * pInst)236 cp_createInstance_Solaris_MPXIOGroup(CCIMObjectPath* pOP, CCIMInstance* pInst)
237 {
238 int error;
239
240 util_handleError(MPXIO_CREATEINSTANCE, CIM_ERR_NOT_SUPPORTED, NULL,
241 NULL, &error);
242 return ((CCIMObjectPath*)NULL);
243 }
244
245
246 /*
247 * Deleting an instance of a Solaris_MPXIOGroup is not supported.
248 */
249
250 /* ARGSUSED */
251 CIMBool
cp_deleteInstance_Solaris_MPXIOGroup(CCIMObjectPath * pInst)252 cp_deleteInstance_Solaris_MPXIOGroup(CCIMObjectPath* pInst)
253 {
254
255 int error;
256
257 util_handleError(MPXIO_DELETEINSTANCE, CIM_ERR_NOT_SUPPORTED, NULL,
258 NULL, &error);
259 return (cim_false);
260 }
261
262 /*
263 * Name: cp_getProperty_Solaris_MPXIOGroup
264 *
265 * Description: Returns the property requested, if found.
266 *
267 * Parameters:
268 * pOP - An CCIMObjectPath * which contains the information on
269 * the class for which to find the instances.
270 * Returns:
271 * CCIMProperty * if found.
272 */
273
274 /* ARGSUSED */
275 CCIMProperty *
cp_getProperty_Solaris_MPXIOGroup(CCIMObjectPath * pOP,char * pPropName)276 cp_getProperty_Solaris_MPXIOGroup(CCIMObjectPath *pOP,
277 char *pPropName)
278 {
279
280 CCIMProperty *prop = NULL;
281 CCIMInstance *inst = NULL;
282 int error = 0;
283
284 if (pOP == NULL) {
285 util_handleError(MPXIO_GETPROPERTY, CIM_ERR_INVALID_PARAMETER, NULL,
286 NULL, &error);
287 return ((CCIMProperty *)NULL);
288 }
289
290 inst = cp_getInstance_Solaris_MPXIOGroup(pOP);
291 if (inst == NULL) {
292 return ((CCIMProperty *)NULL);
293 }
294
295 prop = cim_getProperty(inst, pPropName);
296 cim_freeInstance(inst);
297 return (prop);
298 }
299 /*
300 * Setting an instance of a Solaris_MPXIOGroup is not supported.
301 */
302
303 /* ARGSUSED */
304 CIMBool
cp_setInstance_Solaris_MPXIOGroup(CCIMObjectPath * pOP,CCIMInstance * pInst)305 cp_setInstance_Solaris_MPXIOGroup(CCIMObjectPath* pOP, CCIMInstance* pInst)
306 {
307
308 int error;
309
310 util_handleError(MPXIO_SETINSTANCE, CIM_ERR_NOT_SUPPORTED, NULL,
311 NULL, &error);
312 return (cim_false);
313 }
314
315 /*
316 * This provider cannot set a property on a Solaris_MPXIOGroup object.
317 */
318
319 /* ARGSUSED */
320 CIMBool
cp_setProperty_Solaris_MPXIOGroup(CCIMObjectPath * pOP,CCIMProperty * pProp)321 cp_setProperty_Solaris_MPXIOGroup(CCIMObjectPath* pOP, CCIMProperty* pProp)
322 {
323
324 int error;
325
326 util_handleError(MPXIO_SETPROPERTY, CIM_ERR_NOT_SUPPORTED, NULL,
327 NULL, &error);
328 return (cim_false);
329 }
330 /*
331 * No methods on this class.
332 */
333
334 /* ARGSUSED */
335 CCIMProperty*
cp_invokeMethod_Solaris_MPXIOGroup(CCIMObjectPath * op,cimchar * methodName,CCIMPropertyList * inParams,CCIMPropertyList * outParams)336 cp_invokeMethod_Solaris_MPXIOGroup(CCIMObjectPath* op, cimchar* methodName,
337 CCIMPropertyList* inParams, CCIMPropertyList* outParams)
338 {
339 CCIMProperty *retVal = (CCIMProperty *)NULL;
340 return (retVal);
341 }
342
343 /*
344 * Name: cp_execQuery_Solaris_MPXIOGroup
345 *
346 * Description:
347 * Returns an instance list which matches the query if any are found.
348 *
349 * Parameters:
350 * CCIMObjectPath *op - An CCIMObjectPath * which contains the
351 * information on the class for which to find the instances.
352 *
353 * selectList - Not used
354 * nonJoinExp - Not used
355 *
356 * Returns:
357 * CCIMInstanceList * if found. Otherwise, NULL.
358 */
359
360 /*
361 * Currently, there is no WQL parser for the C providers. As a result,
362 * what is returned to the CIMOM is a list of instances with
363 * a NULL value at the beginning of the list. This NULL value indicates
364 * to the CIMOM that it must do the filtering for the client.
365 */
366
367 /* ARGSUSED */
368 CCIMInstanceList*
cp_execQuery_Solaris_MPXIOGroup(CCIMObjectPath * op,cimchar * selectList,cimchar * nonJoinExp,cimchar * queryExp,int queryType)369 cp_execQuery_Solaris_MPXIOGroup(CCIMObjectPath *op, cimchar *selectList,
370 cimchar *nonJoinExp, cimchar *queryExp, int queryType)
371 {
372 CCIMInstanceList *instList = NULL;
373 CCIMInstanceList *result;
374 CCIMInstance *emptyInst;
375 CCIMException *ex;
376 int error;
377
378 if (op == NULL) {
379 util_handleError(MPXIO_EXECQUERY, CIM_ERR_INVALID_PARAMETER, NULL,
380 NULL, &error);
381 return ((CCIMInstanceList *)NULL);
382 }
383
384 instList = cp_enumInstances_Solaris_MPXIOGroup(op);
385
386 if (instList == NULL) {
387 return ((CCIMInstanceList *)NULL);
388 }
389 /*
390 * Create a null instance and add it to the beginning
391 * of the list to indicate to the CIMOM that no filtering
392 * was done.
393 */
394
395 emptyInst = cim_createInstance("");
396 if (emptyInst == NULL) {
397 ex = cim_getLastError();
398 util_handleError(MPXIO_EXECQUERY, CIM_ERR_FAILED,
399 CREATE_INSTANCE_FAILURE, ex, &error);
400 cim_freeInstanceList(instList);
401 return ((CCIMInstanceList *)NULL);
402 }
403
404 result = cim_createInstanceList();
405 if (result == NULL) {
406 ex = cim_getLastError();
407 util_handleError(MPXIO_EXECQUERY, CIM_ERR_FAILED,
408 CREATE_INSTANCE_LIST_FAILURE, ex, &error);
409 cim_freeInstance(emptyInst);
410 cim_freeInstanceList(instList);
411 return ((CCIMInstanceList *)NULL);
412 }
413
414 result = cim_addInstance(result, emptyInst);
415 if (result == NULL) {
416 ex = cim_getLastError();
417 util_handleError(MPXIO_EXECQUERY, CIM_ERR_FAILED,
418 ADD_INSTANCE_FAILURE, ex, &error);
419 cim_freeInstance(emptyInst);
420 cim_freeInstanceList(instList);
421 return ((CCIMInstanceList *)NULL);
422 }
423
424 /*
425 * Since copying the original list to the new list will
426 * leave no way to free the original list, manually
427 * concatenate the original list to the new one.
428 */
429
430 result->mNext = instList;
431 return (result);
432 }
433