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 "providerNames.h"
36 #include "messageStrings.h"
37 #include "disk_descriptors.h"
38 #include "logicaldisk_descriptors.h"
39 #include "realizesextent_descriptors.h"
40 #include "Solaris_RealizesExtent.h"
41
42 #define REALIZES_GETINSTANCE "REALIZES_EXTENT,GET_INSTANCE"
43 #define REALIZES_ENUMINSTANCES "REALIZES_EXTENT,ENUM_INSTANCES"
44 #define REALIZES_ENUMINSTANCENAMES \
45 "REALIZES_EXTENT,ENUM_INSTANCENAMES"
46 #define REALIZES_CREATEINSTANCE "REALIZES_EXTENT,CREATE_INSTANCE"
47 #define REALIZES_DELETEINSTANCE "REALIZES_EXTENT,DELETE_INSTANCE"
48 #define REALIZES_SETINSTANCE "REALIZES_EXTENT,SET_INSTANCE"
49 #define REALIZES_SETPROPERTY "REALIZES_EXTENT,SET_PROPERTY"
50 #define REALIZES_GETPROPERTY "REALIZES_EXTENT,GET_PROPERTY"
51 #define REALIZES_INVOKEMETHOD "REALIZES_EXTENT,INVOKE_METHOD"
52 #define REALIZES_EXECQUERY "REALIZES_EXTENT,EXEC_QUERY"
53 #define REALIZES_ASSOCIATORS "REALIZES_EXTENT,ASSOCIATORS"
54 #define REALIZES_ASSOCIATORNAMES "REALIZES_EXTENT,ASSOCIATOR_NAMES"
55 #define REALIZES_REFERENCES "REALIZES_EXTENT,REFERENCES"
56 #define REALIZES_REFERENCENAMES "REALIZES_EXTENT,REFERENCE_NAMES"
57
58 static
59 CCIMInstanceList *
60 createRealizesExtentList(CCIMObjectPath *pObjectName,
61 cimchar *pObjectNameRole,
62 CCIMObjectPathList *objList, cimchar *objRole, int *error);
63 /*
64 * Solaris_RealizesExtent provider
65 *
66 * It is important to note that all memory allocated by these functions
67 * and passed to the CIMOM, is freed by the door process prior to
68 * sending a copy of the data to the CIMOM.
69 */
70
71 /*
72 * Name: cp_getInstance_Solaris_RealizesExtent
73 *
74 * Description: Returns an instance of Solaris_RealizesExtent if one
75 * is found that matches the object path passed in .
76 *
77 * Parameters:
78 * pOP - An CCIMObjectPath * which contains the information on
79 * the class for which to find the instance.
80 * Returns: CCIMInstance * if match is found, or NULL if not.
81 *
82 */
83
84 CCIMInstance*
cp_getInstance_Solaris_RealizesExtent(CCIMObjectPath * pOP)85 cp_getInstance_Solaris_RealizesExtent(CCIMObjectPath* pOP)
86 {
87
88 CCIMInstance *inst = NULL;
89 CCIMPropertyList *pCurPropList;
90 CCIMObjectPath *antOp = NULL;
91 CCIMObjectPath *depOp = NULL;
92 dm_descriptor_t d_descriptor;
93 char *name;
94 int error;
95
96
97 if (pOP == NULL || pOP->mKeyProperties == NULL) {
98 util_handleError(REALIZES_GETINSTANCE,
99 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
100 }
101
102 pCurPropList = pOP->mKeyProperties;
103 antOp = (CCIMObjectPath *)util_getKeyValue(pCurPropList, reference,
104 ANTECEDENT, &error);
105
106 if (error == 0) {
107 depOp = (CCIMObjectPath *)util_getKeyValue(pCurPropList, reference,
108 DEPENDENT, &error);
109 }
110
111 /*
112 * Make sure we have both keys. If not, this is an error.
113 */
114
115 if (error != 0) {
116 util_handleError(REALIZES_GETINSTANCE,
117 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
118 return ((CCIMInstance *)NULL);
119 }
120
121 /*
122 * Now get the name of the antecedent from the object path.
123 */
124
125 if (antOp->mKeyProperties == NULL ||
126 depOp->mKeyProperties == NULL) {
127 util_handleError(REALIZES_GETINSTANCE,
128 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
129 return ((CCIMInstance *)NULL);
130 }
131
132 pCurPropList = antOp->mKeyProperties;
133 name = (cimchar *)util_getKeyValue(pCurPropList, string, TAG, &error);
134
135 if (error != 0 || name == NULL) {
136 util_handleError(REALIZES_GETINSTANCE,
137 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
138 return ((CCIMInstance *)NULL);
139 }
140
141 d_descriptor = dm_get_descriptor_by_name(DM_MEDIA, name, &error);
142
143 /*
144 * Not found. Return a null instance.
145 */
146
147 if (error == ENODEV || d_descriptor == NULL) {
148 return ((CCIMInstance *)NULL);
149 }
150
151 if (error != 0) {
152 util_handleError(REALIZES_GETINSTANCE, CIM_ERR_FAILED,
153 DM_GET_DESC_BYNAME_FAILURE, NULL, &error);
154 return ((CCIMInstance *)NULL);
155 }
156
157 /*
158 * Turn this in to a realizes extent instance.
159 */
160
161 inst = realizesextent_descriptor_toCCIMInstance(hostName, d_descriptor,
162 REALIZES_EXTENT, &error);
163 dm_free_descriptor(d_descriptor);
164
165 if (error != 0) {
166 util_handleError(REALIZES_GETINSTANCE, CIM_ERR_FAILED,
167 REALIZESEXT_DESC_TO_INSTANCE_FAILURE, NULL, &error);
168 return ((CCIMInstance *)NULL);
169 }
170
171 return (inst);
172 }
173
174 /*
175 * Name: cp_enumInstances_Solaris_RealizesExtent
176 *
177 * Description: Returns a linked list of instances of this association.
178 *
179 * Parameters:
180 * pOP - An CCIMObjectPath * which contains the information on
181 * the class for which to find the instances.
182 * Returns:
183 * CCIMInstanceList * if istances are found. NULL otherwise.
184 */
185
186 /* ARGSUSED */
187 CCIMInstanceList*
cp_enumInstances_Solaris_RealizesExtent(CCIMObjectPath * pOP)188 cp_enumInstances_Solaris_RealizesExtent(CCIMObjectPath* pOP)
189 {
190 CCIMInstanceList* instList = NULL;
191 CCIMInstance* inst;
192 CCIMException* ex;
193 dm_descriptor_t *disk_descriptorp = NULL;
194 int error = 0;
195 int filter[2];
196 int i = 0;
197
198 filter[0] = DM_MT_FIXED;
199 filter[1] = DM_FILTER_END;
200
201
202 disk_descriptorp = dm_get_descriptors(DM_MEDIA, filter, &error);
203 if (disk_descriptorp == NULL ||
204 disk_descriptorp[0] == NULL) {
205 return ((CCIMInstanceList *)NULL);
206 }
207 if (error != 0) {
208 util_handleError(REALIZES_ENUMINSTANCES, CIM_ERR_FAILED,
209 DM_GET_DESCRIPTORS, NULL, &error);
210 return ((CCIMInstanceList *)NULL);
211 }
212
213 /*
214 * For each one of the disks found, generate the physical and
215 * logical views and create an association instance.
216 */
217
218 instList = cim_createInstanceList();
219 if (instList == NULL) {
220 ex = cim_getLastError();
221 util_handleError(REALIZES_ENUMINSTANCES, CIM_ERR_FAILED,
222 CREATE_INSTANCE_LIST_FAILURE, ex, &error);
223 dm_free_descriptors(disk_descriptorp);
224 return ((CCIMInstanceList *)NULL);
225 }
226
227 for (i = 0; disk_descriptorp[i] != NULL; i ++) {
228 inst = realizesextent_descriptor_toCCIMInstance(hostName,
229 disk_descriptorp[i], REALIZES_EXTENT, &error);
230 if (error != 0) {
231 util_handleError(REALIZES_ENUMINSTANCES, CIM_ERR_FAILED,
232 REALIZESEXT_DESC_TO_INSTANCE_FAILURE, NULL, &error);
233 cim_freeInstanceList(instList);
234 dm_free_descriptors(disk_descriptorp);
235 return ((CCIMInstanceList *)NULL);
236 }
237 instList = cim_addInstance(instList, inst);
238 if (instList == NULL) {
239 util_handleError(REALIZES_ENUMINSTANCES, CIM_ERR_FAILED,
240 ADD_INSTANCE_FAILURE, NULL, &error);
241 dm_free_descriptors(disk_descriptorp);
242 cim_freeInstance(inst);
243 return ((CCIMInstanceList *)NULL);
244 }
245 }
246
247 dm_free_descriptors(disk_descriptorp);
248 if (instList->mDataObject == NULL) {
249 cim_freeInstanceList(instList);
250 instList = NULL;
251 }
252 return (instList);
253 }
254
255 /*
256 * Name: cp_enumInstanceNames_Solaris_RealizesExtent
257 *
258 * Description: Returns a linked list of CCIMObjectPath *
259 * of Solaris_RealizesExtent objects if found.
260 *
261 * Parameters:
262 * pOP - An CCIMObjectPath * which contains the information on
263 * the class for which to find the instances.
264 * Returns:
265 * CCIMObjectPathList * if objects are found. NULL otherwise.
266 */
267
268 /* ARGSUSED */
269 CCIMObjectPathList*
cp_enumInstanceNames_Solaris_RealizesExtent(CCIMObjectPath * pOP)270 cp_enumInstanceNames_Solaris_RealizesExtent(CCIMObjectPath * pOP) {
271
272 CCIMInstanceList *instList;
273 CCIMObjectPathList *objList = NULL;
274 int error;
275
276 if (pOP == NULL) {
277 util_handleError(REALIZES_ENUMINSTANCENAMES,
278 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
279 return ((CCIMObjectPathList *)NULL);
280 }
281
282 /*
283 * Call in to enumInstances and then convert the instance list in
284 * to an object list.
285 */
286
287 instList = cp_enumInstances_Solaris_RealizesExtent(pOP);
288
289 if (instList != NULL) {
290 objList = cim_createObjectPathList(instList);
291 cim_freeInstanceList(instList);
292 }
293
294 return (objList);
295 }
296
297 /*
298 * Creating an instance of a Solaris_RealizesExtent is not supported.
299 */
300
301 /* ARGSUSED */
302 CCIMObjectPath*
cp_createInstance_Solaris_RealizesExtent(CCIMObjectPath * pOP,CCIMInstance * pInst)303 cp_createInstance_Solaris_RealizesExtent(
304 CCIMObjectPath* pOP, CCIMInstance* pInst)
305 {
306 int error;
307
308 util_handleError(REALIZES_CREATEINSTANCE, CIM_ERR_NOT_SUPPORTED, NULL,
309 NULL, &error);
310 return ((CCIMObjectPath *)NULL);
311 }
312
313
314 /*
315 * Deleting an instance of a Solaris_RealizesExtent is not supported.
316 */
317
318 /* ARGSUSED */
319 CIMBool
cp_deleteInstance_Solaris_RealizesExtent(CCIMObjectPath * pInst)320 cp_deleteInstance_Solaris_RealizesExtent(CCIMObjectPath* pInst)
321 {
322 int error;
323
324 util_handleError(REALIZES_DELETEINSTANCE, CIM_ERR_NOT_SUPPORTED, NULL,
325 NULL, &error);
326 return (cim_false);
327 }
328
329 /*
330 * Name: cp_getProperty_Solaris_RealizesExtent
331 *
332 * Description: Returns the property requested, if found.
333 *
334 * Parameters:
335 * pOP - An CCIMObjectPath * which contains the information on
336 * the class for which to find the instances.
337 * Returns:
338 * CCIMProperty * if found.
339 */
340
341 /* ARGSUSED */
342 CCIMProperty *
cp_getProperty_Solaris_RealizesExtent(CCIMObjectPath * pOP,char * pPropName)343 cp_getProperty_Solaris_RealizesExtent(CCIMObjectPath *pOP,
344 char *pPropName)
345 {
346
347 CCIMProperty *prop = NULL;
348 CCIMInstance *inst = NULL;
349 int error = 0;
350
351 if (pOP == NULL) {
352 util_handleError(REALIZES_GETPROPERTY,
353 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
354 return ((CCIMProperty *)NULL);
355 }
356
357 inst = cp_getInstance_Solaris_RealizesExtent(pOP);
358 if (inst == NULL) {
359 return ((CCIMProperty *)NULL);
360 }
361
362 prop = cim_getProperty(inst, pPropName);
363 cim_freeInstance(inst);
364 return (prop);
365 }
366
367 /*
368 * Setting an instance of a Solaris_RealizesExtent is not supported.
369 */
370
371 /* ARGSUSED */
372 CIMBool
cp_setInstance_Solaris_RealizesExtent(CCIMObjectPath * pOP,CCIMInstance * pInst)373 cp_setInstance_Solaris_RealizesExtent(
374 CCIMObjectPath* pOP, CCIMInstance* pInst)
375 {
376 int error;
377
378 util_handleError(REALIZES_SETINSTANCE, CIM_ERR_NOT_SUPPORTED, NULL,
379 NULL, &error);
380 return (cim_false);
381 }
382
383
384 /*
385 * Setting a property on a Solaris_RealizesExtent is not supported.
386 */
387
388 /* ARGSUSED */
389 CIMBool
cp_setProperty_Solaris_RealizesExtent(CCIMObjectPath * pOP,CCIMProperty * pProp)390 cp_setProperty_Solaris_RealizesExtent(
391 CCIMObjectPath* pOP, CCIMProperty* pProp)
392 {
393 int error;
394
395 util_handleError(REALIZES_SETPROPERTY, CIM_ERR_NOT_SUPPORTED, NULL,
396 NULL, &error);
397 return (cim_false);
398 }
399
400 /*
401 * No Methods for Solaris_RealizesExtent.
402 */
403
404 /* ARGSUSED */
405 CCIMProperty*
cp_invokeMethod_Solaris_RealizesExtent(CCIMObjectPath * op,cimchar * methodName,CCIMPropertyList * inParams,CCIMPropertyList * outParams)406 cp_invokeMethod_Solaris_RealizesExtent(
407 CCIMObjectPath* op, cimchar* methodName,
408 CCIMPropertyList* inParams, CCIMPropertyList* outParams)
409 {
410 CCIMProperty *retVal = (CCIMProperty *)NULL;
411 return (retVal);
412 }
413
414 /*
415 * Name: cp_execQuery_Solaris_RealizesExtent
416 *
417 * Description:
418 * Returns an instance list which matches the query if any are found.
419 *
420 * Parameters:
421 * CCIMObjectPath *op - An CCIMObjectPath * which contains the
422 * information on the class for which to find the instances.
423 *
424 * selectList - Not used
425 * nonJoinExp - Not used
426 *
427 * Returns:
428 * CCIMInstance * if matched instance is found. Otherwise, NULL.
429 */
430 /*
431 * Currently, there is no WQL parser for the C providers. As a result,
432 * what is returned to the CIMOM is a list of instances with
433 * a NULL value at the beginning of the list. This NULL value indicates
434 * to the CIMOM that it must do the filtering for the client.
435 */
436
437 /* ARGSUSED */
438 CCIMInstanceList*
cp_execQuery_Solaris_RealizesExtent(CCIMObjectPath * op,cimchar * selectList,cimchar * nonJoinExp,cimchar * queryExp,int queryType)439 cp_execQuery_Solaris_RealizesExtent(
440 CCIMObjectPath *op, cimchar *selectList, cimchar *nonJoinExp,
441 cimchar *queryExp, int queryType)
442 {
443 CCIMInstanceList *instList = NULL;
444 CCIMInstanceList *result;
445 CCIMInstance *emptyInst;
446 CCIMException *ex;
447 int error;
448
449 if (op == NULL) {
450 util_handleError(REALIZES_EXECQUERY,
451 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
452 return ((CCIMInstanceList *)NULL);
453 }
454
455 instList = cp_enumInstances_Solaris_RealizesExtent(op);
456
457 if (instList == NULL) {
458 return ((CCIMInstanceList *)NULL);
459 }
460 /*
461 * Create a null instance and add it to the beginning
462 * of the list to indicate to the CIMOM that no filtering
463 * was done.
464 */
465
466 emptyInst = cim_createInstance("");
467 if (emptyInst == NULL) {
468 ex = cim_getLastError();
469 util_handleError(REALIZES_EXECQUERY, CIM_ERR_FAILED,
470 CREATE_INSTANCE_FAILURE, ex, &error);
471 return ((CCIMInstanceList *)NULL);
472 }
473
474 result = cim_createInstanceList();
475 if (result == NULL) {
476 ex = cim_getLastError();
477 util_handleError(REALIZES_EXECQUERY, CIM_ERR_FAILED,
478 CREATE_INSTANCE_LIST_FAILURE, ex, &error);
479 cim_freeInstance(emptyInst);
480 cim_freeInstanceList(instList);
481 return ((CCIMInstanceList *)NULL);
482 }
483
484 result = cim_addInstance(result, emptyInst);
485 if (result == NULL) {
486 ex = cim_getLastError();
487 util_handleError(REALIZES_EXECQUERY, CIM_ERR_FAILED,
488 ADD_INSTANCE_FAILURE, ex, &error);
489 cim_freeInstance(emptyInst);
490 cim_freeInstanceList(instList);
491 return ((CCIMInstanceList *)NULL);
492 }
493
494 /*
495 * Since copying the original list to the new list will
496 * leave no way to free the original list, manually
497 * concatenate the original list to the new one.
498 */
499
500 result->mNext = instList;
501 return (result);
502 }
503
504 /*
505 * Name: cp_associators_Solaris_RealizesExtent
506 *
507 * Description:
508 * Returns a instances of objects associated with the passed in
509 * object if there are any.
510 *
511 * Parameters:
512 *
513 * CCIMObjectPath *pAssocName - The name of the association that
514 * the client wants information about.
515 *
516 * CCIMObjectPath *pObjectName - An CCIMObjectPath * which contains the
517 * information on the class for which to find the associated instances.
518 *
519 * cimchar *pResultClass - If specified, only return instances that
520 * are of this class type.
521 *
522 * cimchar *pRole - If specified, must be valid for the object path
523 * passed in requesting the associated instances.
524 *
525 * cimchar *pResultRole - If specified, only return instances that
526 * are playing this role in the association.
527 *
528 *
529 * Returns:
530 * CCIMInstanceList * if associated objects are found. NULL otherwise.
531 */
532
533 /* ARGSUSED */
534 CCIMInstanceList *
cp_associators_Solaris_RealizesExtent(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,cimchar * pResultClass,cimchar * pRole,cimchar * pResultRole)535 cp_associators_Solaris_RealizesExtent(CCIMObjectPath *pAssocName,
536 CCIMObjectPath *pObjectName, cimchar *pResultClass, cimchar *pRole,
537 cimchar *pResultRole)
538 {
539 CCIMPropertyList *pCurPropList;
540 CCIMInstanceList *instList = NULL;
541 CCIMInstance *inst;
542 CCIMException *ex;
543 dm_descriptor_t obj_desc;
544 char *name;
545 int error = 0;
546 int isAntecedent = 0;
547
548
549 if (pObjectName == NULL ||
550 pObjectName->mName == NULL ||
551 pObjectName->mKeyProperties == NULL) {
552 util_handleError(REALIZES_ASSOCIATORS, CIM_ERR_INVALID_PARAMETER,
553 NULL, NULL, &error);
554 }
555
556 if (strcasecmp(pObjectName->mName, DISK) == 0) {
557 isAntecedent = 1;
558 }
559
560 if (pRole != NULL) {
561 if (strcasecmp(pRole, ANTECEDENT) == 0) {
562 if (isAntecedent != 1) {
563 util_handleError(REALIZES_ASSOCIATORS,
564 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
565 return ((CCIMInstanceList *)NULL);
566 }
567 }
568 }
569
570 pCurPropList = pObjectName->mKeyProperties;
571
572 /*
573 * Get the key. It will either be deviceid or tag. These are
574 * mutually exclusive.
575 */
576
577 if (isAntecedent) {
578 name = (cimchar *)util_getKeyValue(pCurPropList, string, TAG,
579 &error);
580 } else {
581 name = (cimchar *)util_getKeyValue(pCurPropList, string, DEVICEID,
582 &error);
583 }
584
585 /*
586 * We went through the whole list and didn't find the necessary
587 * key value.
588 */
589
590 if (error != 0 || name == NULL) {
591 util_handleError(REALIZES_ASSOCIATORS,
592 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
593 return ((CCIMInstanceList *)NULL);
594 }
595
596 obj_desc = dm_get_descriptor_by_name(DM_MEDIA, name, &error);
597 /*
598 * No device found.
599 */
600 if (error == ENODEV || obj_desc == NULL) {
601 return (instList);
602 }
603
604 if (error != 0) {
605 util_handleError(REALIZES_ASSOCIATORS, CIM_ERR_FAILED,
606 DM_GET_DESC_BYNAME_FAILURE, NULL, &error);
607 return ((CCIMInstanceList *)NULL);
608 }
609
610 if (isAntecedent == 1) {
611 /*
612 * Physical disk calling this method, return instances of the
613 * logical disk associated with this disk.
614 */
615
616 inst = logicaldisk_descriptor_toCCIMInstance(hostName,
617 obj_desc, LOGICAL_DISK, &error);
618 dm_free_descriptor(obj_desc);
619
620 if (error != 0) {
621 util_handleError(REALIZES_ASSOCIATORS, CIM_ERR_FAILED,
622 LOGICALDISK_DESC_TO_INSTANCE_FAILURE, NULL, &error);
623 return ((CCIMInstanceList *)NULL);
624 }
625
626 instList = cim_createInstanceList();
627 if (instList == NULL) {
628 ex = cim_getLastError();
629 util_handleError(REALIZES_ASSOCIATORS, CIM_ERR_FAILED,
630 CREATE_INSTANCE_FAILURE, ex, &error);
631 return ((CCIMInstanceList *)NULL);
632 }
633 instList = cim_addInstance(instList, inst);
634 if (instList == NULL) {
635 ex = cim_getLastError();
636 util_handleError(REALIZES_ASSOCIATORS, CIM_ERR_FAILED,
637 ADD_INSTANCE_FAILURE, ex, &error);
638 cim_freeInstance(inst);
639 return ((CCIMInstanceList *)NULL);
640 }
641 } else {
642 /*
643 * This is the logical disk calling this function. Return the
644 * disk that this belongs to.
645 */
646
647 inst = disk_descriptor_toCCIMInstance(hostName, obj_desc,
648 DISK, &error);
649 dm_free_descriptor(obj_desc);
650
651 if (error != 0) {
652 util_handleError(REALIZES_ASSOCIATORS, CIM_ERR_FAILED,
653 DISK_DESC_TO_INSTANCE_FAILURE, NULL, &error);
654 return ((CCIMInstanceList *)NULL);
655 }
656
657 instList = cim_createInstanceList();
658 if (instList == NULL) {
659 ex = cim_getLastError();
660 util_handleError(REALIZES_ASSOCIATORS, CIM_ERR_FAILED,
661 CREATE_INSTANCE_FAILURE, ex, &error);
662 cim_freeInstance(inst);
663 return ((CCIMInstanceList *)NULL);
664 }
665 instList = cim_addInstance(instList, inst);
666 if (instList == NULL) {
667 ex = cim_getLastError();
668 util_handleError(REALIZES_ASSOCIATORS, CIM_ERR_FAILED,
669 ADD_INSTANCE_FAILURE, ex, &error);
670 return ((CCIMInstanceList *)NULL);
671 }
672 }
673
674 return (instList);
675 }
676
677 /*
678 * Name: cp_associatorNames_Solaris_RealizesExtent
679 *
680 * Description:
681 * Returns a list of objects associated with the passed in
682 * object if there are any via the object CCIMObjectPath.
683 *
684 * Parameters:
685 *
686 * CCIMObjectPath *pAssocName - The name of the association that
687 * the client wants information about.
688 *
689 * CCIMObjectPath *pObjectName - An CCIMObjectPath * which contains the
690 * information on the class for which to find the associated instances.
691 *
692 * cimchar *pResultClass - If specified, only return instances that
693 * are of this class type.
694 *
695 * cimchar *pRole - If specified, must be valid for the object path
696 * passed in requesting the associated instances.
697 *
698 * cimchar *pResultRole - If specified, only return instances that
699 * are playing this role in the association.
700 *
701 *
702 * Returns:
703 * CCIMObjectPathList * if associated objects are found. NULL otherwise.
704 */
705
706 /* ARGSUSED */
707 CCIMObjectPathList *
cp_associatorNames_Solaris_RealizesExtent(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,cimchar * pResultClass,cimchar * pRole,cimchar * pResultRole)708 cp_associatorNames_Solaris_RealizesExtent(CCIMObjectPath *pAssocName,
709 CCIMObjectPath *pObjectName, cimchar *pResultClass, cimchar *pRole,
710 cimchar *pResultRole)
711 {
712
713 CCIMInstanceList *instList;
714 CCIMObjectPathList *objList = NULL;
715 int error;
716
717
718 if (pObjectName == NULL) {
719 util_handleError(REALIZES_ASSOCIATORNAMES,
720 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
721 return ((CCIMObjectPathList *)NULL);
722 }
723
724 instList =
725 cp_associators_Solaris_RealizesExtent(
726 pAssocName, pObjectName, pResultClass, pRole, pResultRole);
727
728 if (instList != NULL) {
729 objList = cim_createObjectPathList(instList);
730 cim_freeInstanceList(instList);
731 }
732
733 return (objList);
734 }
735
736 /*
737 * Name: cp_references_Solaris_RealizesExtent
738 *
739 * Description:
740 * Returns a instances of objects that have references to the passed in
741 * object if there are any.
742 *
743 * Parameters:
744 *
745 * CCIMObjectPath *pAssocName - The name of the association that
746 * the client wants information about.
747 *
748 * CCIMObjectPath *pObjectName - An CCIMObjectPath * which contains the
749 * information on the class for which to find the associated instances.
750 *
751 * cimchar *pRole - If specified, must be valid for the object path
752 * passed in requesting the associated instances.
753 *
754 * Returns:
755 * CCIMObjectPathList * if associated objects are found. NULL otherwise.
756 */
757
758 /* ARGSUSED */
759 CCIMInstanceList *
cp_references_Solaris_RealizesExtent(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,char * pRole)760 cp_references_Solaris_RealizesExtent(CCIMObjectPath *pAssocName,
761 CCIMObjectPath *pObjectName, char *pRole)
762 {
763
764 CCIMInstanceList *instList;
765 CCIMObjectPathList *objList = NULL;
766 int error;
767
768
769 if (pObjectName == NULL) {
770 util_handleError(REALIZES_REFERENCES,
771 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
772 return ((CCIMInstanceList *)NULL);
773 }
774 /*
775 * Get the list of those objects that are referred to by
776 * the calling object.
777 */
778
779 objList =
780 cp_associatorNames_Solaris_RealizesExtent(
781 pAssocName, pObjectName, NULL, NULL, NULL);
782
783 if (objList == NULL) {
784 return ((CCIMInstanceList *)NULL);
785 }
786
787 /*
788 * Now generate the list of instances to return.
789 */
790
791 if (strcasecmp(pObjectName->mName, DISK) == 0) {
792 instList = createRealizesExtentList(pObjectName,
793 ANTECEDENT, objList, DEPENDENT, &error);
794 } else {
795 instList = createRealizesExtentList(pObjectName,
796 DEPENDENT, objList, ANTECEDENT, &error);
797 }
798
799 cim_freeObjectPathList(objList);
800 return (instList);
801 }
802
803 /*
804 * Name: cp_referenceNames_Solaris_RealizesExtent
805 *
806 * Description:
807 * Returns a instances of objects that have references to the passed in
808 * object if there are any.
809 *
810 * Parameters:
811 *
812 * CCIMObjectPath *pAssocName - The name of the association that
813 * the client wants information about.
814 *
815 * CCIMObjectPath *pObjectName - An CCIMObjectPath * which contains the
816 * information on the class for which to find the associated instances.
817 *
818 * cimchar *pRole - If specified, must be valid for the object path
819 * passed in requesting the associated instances.
820 *
821 *
822 * Returns:
823 * CCIMObjectPathList * if associated objects are found. NULL otherwise.
824 *
825 */
826
827 /* ARGSUSED */
828 CCIMObjectPathList *
cp_referenceNames_Solaris_RealizesExtent(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,cimchar * pRole)829 cp_referenceNames_Solaris_RealizesExtent(CCIMObjectPath *pAssocName,
830 CCIMObjectPath *pObjectName, cimchar *pRole)
831 {
832
833 CCIMInstanceList *instList = NULL;
834 CCIMObjectPathList *objList = NULL;
835 int error;
836
837 if (pObjectName == NULL) {
838 util_handleError(REALIZES_REFERENCENAMES,
839 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &error);
840 return ((CCIMObjectPathList *)NULL);
841 }
842
843 instList =
844 cp_references_Solaris_RealizesExtent(pAssocName,
845 pObjectName, pRole);
846
847 if (instList != NULL) {
848 objList = cim_createObjectPathList(instList);
849 cim_freeInstanceList(instList);
850 }
851
852 return (objList);
853 }
854
855 /*
856 * Create the association class with the passed in attributes.
857 */
858 static
859 CCIMInstanceList *
createRealizesExtentList(CCIMObjectPath * pObjectName,cimchar * pObjectNameRole,CCIMObjectPathList * objList,cimchar * objRole,int * error)860 createRealizesExtentList(CCIMObjectPath *pObjectName,
861 cimchar *pObjectNameRole,
862 CCIMObjectPathList *objList, cimchar *objRole, int *error)
863 {
864
865 CCIMObjectPathList *tmpList;
866 CCIMInstanceList *instList = NULL;
867 CCIMInstance *inst;
868 CCIMObjectPath *obj1;
869 CCIMObjectPath *obj2;
870 CCIMException *ex;
871
872 *error = 0;
873
874 /*
875 * If no objects associated with this one, return NULL.
876 */
877 if (objList == NULL) {
878 return ((CCIMInstanceList *)NULL);
879 }
880
881 instList = cim_createInstanceList();
882 if (instList == NULL) {
883 ex = cim_getLastError();
884 util_handleError(REALIZES_EXTENT, CIM_ERR_FAILED,
885 CREATE_INSTANCE_FAILURE, ex, error);
886 return ((CCIMInstanceList *)NULL);
887 }
888
889 tmpList = objList;
890 while (tmpList != NULL) {
891 obj1 = tmpList->mDataObject;
892 obj2 = cim_copyObjectPath(pObjectName);
893 if (obj2 == NULL) {
894 ex = cim_getLastError();
895 util_handleError(REALIZES_EXTENT, CIM_ERR_FAILED,
896 COPY_OBJPATH_FAILURE, ex, error);
897 return ((CCIMInstanceList *)NULL);
898 }
899
900 inst = cim_createInstance(REALIZES_EXTENT);
901 if (inst == NULL) {
902 ex = cim_getLastError();
903 util_handleError(REALIZES_EXTENT, CIM_ERR_FAILED,
904 CREATE_INSTANCE_FAILURE, ex, error);
905 return ((CCIMInstanceList *)NULL);
906 }
907
908 util_doReferenceProperty(pObjectNameRole, obj2, cim_true, inst,
909 error);
910 cim_freeObjectPath(obj2);
911
912 if (*error != 0) {
913 ex = cim_getLastError();
914 util_handleError(REALIZES_EXTENT, CIM_ERR_FAILED,
915 ADD_PROPERTY_FAILURE, ex, error);
916 cim_freeInstance(inst);
917 return ((CCIMInstanceList *)NULL);
918 }
919
920 util_doReferenceProperty(objRole, obj1, cim_true, inst, error);
921
922 if (*error != 0) {
923 ex = cim_getLastError();
924 util_handleError(REALIZES_EXTENT, CIM_ERR_FAILED,
925 ADD_PROPERTY_FAILURE, ex, error);
926 cim_freeInstance(inst);
927 return ((CCIMInstanceList *)NULL);
928 }
929
930 instList = cim_addInstance(instList, inst);
931 if (instList == NULL) {
932 ex = cim_getLastError();
933 util_handleError(REALIZES_EXTENT, CIM_ERR_FAILED,
934 ADD_INSTANCE_FAILURE, ex, error);
935 cim_freeInstance(inst);
936 return ((CCIMInstanceList *)NULL);
937 }
938
939 tmpList = tmpList->mNext;
940 }
941 return (instList);
942 }
943