os-cmpi-xen

view src/Xen_ComputerSystemIndication.c @ 121:4868ace2726b

Add initial consistence checks in test suite for Xen_MemoryPool, Xen_ProcessorPool and Xen_VirtualSystemManagementService.

Signed-off-by: Luke Szymanski <Lukasz.Szymanski@Unisys.com>
author Jim Fehlig <jfehlig@novell.com>
date Fri Jun 08 10:22:05 2007 -0600 (2007-06-08)
parents 1faa76de765e
children
line source
1 // Copyright (C) 2006 IBM Corporation
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 // ============================================================================
17 // Authors: Dr. Gareth S. Bestor, <bestor@us.ibm.com>
18 // Contributors:
19 // Description:
20 // ============================================================================
22 #include <string.h>
24 /* Include the required CMPI data types, function headers, and macros */
25 #include "cmpidt.h"
26 #include "cmpift.h"
27 #include "cmpimacs.h"
30 // ----------------------------------------------------------------------------
31 // COMMON GLOBAL VARIABLES
32 // ----------------------------------------------------------------------------
34 /* Handle to the CIM broker. Initialized when the provider lib is loaded. */
35 static CMPIBroker *_BROKER;
37 /* Include utility functions */
38 #include "cmpiutil.h"
40 /* Include _SBLIM_TRACE() logging support */
41 #include "cmpitrace.h"
44 // ============================================================================
45 // CMPI INDICATION PROVIDER FUNCTION TABLE
46 // ============================================================================
48 /* Flag indicating if indications are currently enabled */
49 static int enabled = 0;
51 /* Number of active indication filters (i.e. # registered subscriptions) */
52 static int numActiveFilters = 0;
54 /* Number of seconds to wait between polling to generate indications. */
55 static int pollingInterval = 30;
57 /* Handle to the asynchronous indication generator thread */
58 static CMPI_THREAD_TYPE indicationThreadId = 0;
60 static char * _NAMESPACE = "root/cimv2";
61 static char * _CLASSNAME = "Xen_ComputerSystem";
63 static CMPIArray * currentinstances = NULL;
64 static CMPIArray * previousinstances = NULL;
66 // ----------------------------------------------------------------------------
67 // _indicationThread()
68 // Runtime thread to periodically poll to generate indications.
69 // ----------------------------------------------------------------------------
70 CMPI_THREAD_RETURN _indicationThread( void * parameters )
71 {
72 CMPIContext * context = (CMPIContext *)parameters; /* Indication thread context */
73 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */
74 CMPIInstance * indication; /* CIM instance for each new indication */
75 int i,j;
77 _SBLIM_ENTER("_indicationThread");
79 /* Register this thread to the CMPI runtime. */
80 CBAttachThread(_BROKER, context);
82 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
84 /* Periodically poll while there is at least one indication subscriber. */
85 while (numActiveFilters > 0) {
86 _SBLIM_TRACE(3, ("--- Sleeping for %d seconds", pollingInterval));
87 sleep(pollingInterval);
89 /* Check if indications are still enabled. */
90 if (!enabled) continue;
92 /* Free the previous instances list. */
93 _SBLIM_TRACE(1,("--- before CMRelease()"));
94 if (previousinstances != NULL) CMRelease(previousinstances);
95 _SBLIM_TRACE(1,("--- after CMRelease()"));
97 /* Move the (old) current instances list to the previous. */
98 previousinstances = currentinstances;
100 /* Create an object path for the monitored class. */
101 CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, _NAMESPACE, _CLASSNAME, &status);
102 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
103 _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
104 goto exit;
105 }
107 /* Get the current list of instances of the monitored class. */
108 CMPIEnumeration * instances = CBEnumInstances(_BROKER, context, objectpath, NULL, &status);
109 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instances)) {
110 _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
111 goto exit;
112 }
114 /* Save a copy of the array of instances. */
115 currentinstances = CMToArray(instances, &status);
116 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(currentinstances)) {
117 _SBLIM_TRACE(1,("--- CMToArray() failed - %s", CMGetCharPtr(status.msg)));
118 currentinstances = NULL;
119 goto exit;
120 }
122 //_SBLIM_TRACE(4,("before CMClone()"));
123 // currentinstances = CMClone(currentinstances, &status);
124 //_SBLIM_TRACE(4,("after CMClone()"));
125 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(currentinstances)) {
126 _SBLIM_TRACE(1,("--- CMClone() failed - %s", CMGetCharPtr(status.msg)));
127 if (currentinstances != NULL) CMRelease(currentinstances);
128 currentinstances = NULL;
129 goto exit;
130 }
132 /* Go thru the list of current instances and look for changes. */
133 if (currentinstances != NULL) {
134 for (i=0; i<CMGetArrayCount(currentinstances,NULL); i++) {
135 CMPIData newinstancedata = CMGetArrayElementAt(currentinstances, i, NULL);
136 CMPIObjectPath * newobjectpath = CMGetObjectPath(newinstancedata.value.inst, NULL);
137 CMPIData oldinstancedata;
139 _SBLIM_TRACE(3, ("--- Checking objectpath =\"%s\"", CMGetCharPtr(CDToString(_BROKER, newobjectpath, NULL))));
141 /* Find the matching instance in the previous list, if any. */
142 int found = 0;
143 if (previousinstances != NULL) {
144 for (j=0; j<CMGetArrayCount(previousinstances, NULL); j++) {
145 oldinstancedata = CMGetArrayElementAt(previousinstances, j, NULL);
146 CMPIObjectPath * oldobjectpath = CMGetObjectPath(oldinstancedata.value.inst, NULL);
147 if (_CMSameObject(oldobjectpath, newobjectpath)) {
148 found = 1;
149 break;
150 }
151 }
152 }
154 /* InstCreation: If no matching old instance then this is a brand new instance. */
155 if (!found) {
156 _SBLIM_TRACE(4, ("--- New instance!"));
157 indication = _CMNewInstance(_BROKER, _NAMESPACE, "Xen_ComputerSystemCreation", &status);
158 if (status.rc != CMPI_RC_OK) goto exit;
160 /* Set the indication properties. */
161 CMSetProperty(indication, "SourceInstance",(CMPIValue *)&(newinstancedata.value.inst), CMPI_instance);
162 }
164 else {
165 /* InstModification: Check if old instance has different property values. */
166 CMPIData oldstatusdata = CMGetProperty(oldinstancedata.value.inst,"Status",NULL);
167 CMPIData newstatusdata = CMGetProperty(newinstancedata.value.inst,"Status",NULL);
168 char * oldstatus = CMGetCharPtr(oldstatusdata.value.string);
169 char * newstatus = CMGetCharPtr(newstatusdata.value.string);
171 if (strcmp(oldstatus,newstatus) != 0) {
172 _SBLIM_TRACE(4, ("--- Modified instance! Old status=%s New status=%s", oldstatus, newstatus));
173 indication = _CMNewInstance(_BROKER, _NAMESPACE, "Xen_ComputerSystemModification", &status);
174 if (status.rc != CMPI_RC_OK) goto exit;
176 /* Set the indication properties. */
177 CMSetProperty(indication, "SourceInstance",(CMPIValue *)&(newinstancedata.value.inst), CMPI_instance);
178 CMSetProperty(indication, "PreviousInstance",(CMPIValue *)&(oldinstancedata.value.inst), CMPI_instance);
179 }
180 /* No changes so no indication. */
181 else {
182 continue;
183 }
184 }
186 /* Deliver the indication to all subscribers. */
187 _SBLIM_TRACE(2, ("--- Delivering indication"));
188 // _SBLIM_TRACE(3, ("--- indication=\"%s\"", CMGetCharPtr(CDToString(_BROKER, indication, NULL))));
189 status = CBDeliverIndication(_BROKER, context, _NAMESPACE, indication);
190 if (status.rc != CMPI_RC_OK) {
191 _SBLIM_TRACE(1, ("--- Failed to deliver indication"));
192 goto exit;
193 }
194 }
195 }
197 /* Check for instances that have been deleted. */
198 if (previousinstances != NULL) {
199 _SBLIM_TRACE(3, ("--- Scanning for deleted instances"));
200 for (i=0; i<CMGetArrayCount(previousinstances,NULL); i++) {
201 CMPIData oldinstancedata = CMGetArrayElementAt(previousinstances, i, NULL);
202 CMPIObjectPath * oldobjectpath = CMGetObjectPath(oldinstancedata.value.inst, NULL);
203 CMPIData newinstancedata;
205 _SBLIM_TRACE(3, ("--- Checking objectpath =\"%s\"", CMGetCharPtr(CDToString(_BROKER, oldobjectpath, NULL))));
207 /* Find the matching instance in the previous list, if any. */
208 int found = 0;
209 if (currentinstances != NULL) {
210 for (j=0; j<CMGetArrayCount(currentinstances, NULL); j++) {
211 newinstancedata = CMGetArrayElementAt(currentinstances, j, NULL);
212 CMPIObjectPath * newobjectpath = CMGetObjectPath(newinstancedata.value.inst, NULL);
213 if (_CMSameObject(oldobjectpath, newobjectpath)) {
214 found = 1;
215 break;
216 }
217 }
218 }
220 /* InstDeletion: If no matching new instance then the instance was deleted. */
221 if (!found) {
222 _SBLIM_TRACE(4, ("--- Deleted instance!"));
223 indication = _CMNewInstance(_BROKER, _NAMESPACE, "Xen_ComputerSystemDeletion", &status);
224 if (status.rc != CMPI_RC_OK) goto exit;
226 /* Set the indication properties. */
227 CMSetProperty(indication, "SourceInstance",(CMPIValue *)&(oldinstancedata.value.inst), CMPI_instance);
229 /* Deliver the indication to all subscribers. */
230 _SBLIM_TRACE(2, ("--- Delivering indication"));
231 // _SBLIM_TRACE(3, ("--- indication=\"%s\"", CMGetCharPtr(CDToString(_BROKER, indication, NULL))));
232 status = CBDeliverIndication(_BROKER, context, _NAMESPACE, indication);
233 if (status.rc != CMPI_RC_OK) {
234 _SBLIM_TRACE(1, ("--- Failed to deliver indication"));
235 goto exit;
236 }
237 }
238 }
239 }
240 }
241 _SBLIM_TRACE(2, ("--- No more active filters"));
243 exit:
244 indicationThreadId = 0;
245 _SBLIM_RETURN(NULL);
246 }
248 // ----------------------------------------------------------------------------
249 // IndicationCleanup()
250 // Perform any necessary cleanup immediately before this provider is unloaded.
251 // ----------------------------------------------------------------------------
252 static CMPIStatus IndicationCleanup(
253 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
254 CMPIContext * context) /* [in] Additional context info, if any. */
255 {
256 CMPIStatus status = { CMPI_RC_OK, NULL }; /* Return status of CIM operations. */
258 _SBLIM_ENTER("IndicationCleanup");
259 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
260 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
262 /* Nothing needs to be done for cleanup. */
264 exit:
265 _SBLIM_RETURNSTATUS(status);
266 }
268 // ----------------------------------------------------------------------------
269 // AuthorizeFilter()
270 // Check whether the requested filter is valid/permitted.
271 // ----------------------------------------------------------------------------
272 static CMPIStatus AuthorizeFilter(
273 CMPIIndicationMI * self, /* [in] Handle to this provider (i.e. 'self') */
274 CMPIContext * context, /* [in] Additional context info, if any */
275 CMPIResult * results, /* [out] Results of this operation */
276 CMPISelectExp * filter, /* [in] Indication filter query */
277 const char * eventtype, /* [in] Target indication class(es) of filter. */
278 CMPIObjectPath * reference, /* [in] Namespace and classname of monitored class */
279 const char * username ) /* [in] Name of principle requesting the filter */
280 {
281 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */
282 CMPIBoolean authorized = CMPI_true;
283 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
284 char * classname = CMGetCharPtr(CMGetClassName(reference, NULL)); /* Target class. */
286 _SBLIM_ENTER("AuthorizeFilter");
287 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
288 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
289 _SBLIM_TRACE(2, ("--- filter=\"%s\"", CMGetCharPtr(CMGetSelExpString(filter, NULL))));
290 _SBLIM_TRACE(2, ("--- eventtype=\"%s\"", eventtype));
291 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
292 _SBLIM_TRACE(2, ("--- username=\"%s\"", username));
293 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
294 _SBLIM_TRACE(2, ("--- classname=\"%s\"", classname));
296 /* Check that the filter indication class is supported. */
297 if ((strcmp(eventtype,"Xen_ComputerSystemCreation") != 0) &&
298 (strcmp(eventtype,"Xen_ComputerSystemDeletion") != 0) &&
299 (strcmp(eventtype,"Xen_ComputerSystemModification") != 0)) {
300 authorized = CMPI_false;
301 }
303 exit:
304 CMReturnData(results, (CMPIValue *)&authorized, CMPI_boolean);
305 CMReturnDone(results);
306 _SBLIM_RETURNSTATUS(status);
307 }
309 // ----------------------------------------------------------------------------
310 // MustPoll()
311 // Specify if the CIMOM should generate indications instead, by polling the
312 // instance data for any changes.
313 // ----------------------------------------------------------------------------
314 static CMPIStatus MustPoll(
315 CMPIIndicationMI * self, /* [in] Handle to this provider (i.e. 'self') */
316 CMPIContext * context, /* [in] Additional context info, if any */
317 CMPIResult * results, /* [out] Results of this operation */
318 CMPISelectExp * filter, /* [in] Indication filter query */
319 const char * eventtype, /* [in] Filter target class(es) */
320 CMPIObjectPath * reference ) /* [in] Namespace and classname of monitored class */
321 {
322 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */
323 CMPIBoolean poll = CMPI_false;
324 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
325 char * classname = CMGetCharPtr(CMGetClassName(reference, NULL)); /* Target class. */
327 _SBLIM_ENTER("MustPoll");
328 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
329 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
330 _SBLIM_TRACE(2, ("--- filter=\"%s\"", CMGetCharPtr(CMGetSelExpString(filter, NULL))));
331 _SBLIM_TRACE(2, ("--- eventtype=\"%s\"", eventtype));
332 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
333 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
334 _SBLIM_TRACE(2, ("--- classname=\"%s\"", classname));
336 /* Polling not required for this indication provider */
338 exit:
339 CMReturnData(results, (CMPIValue *)&poll, CMPI_boolean);
340 CMReturnDone(results);
341 _SBLIM_RETURNSTATUS(status);
342 }
344 // ----------------------------------------------------------------------------
345 // ActivateFilter()
346 // Add another subscriber and start generating indications.
347 // ----------------------------------------------------------------------------
348 static CMPIStatus ActivateFilter(
349 CMPIIndicationMI * self, /* [in] Handle to this provider (i.e. 'self') */
350 CMPIContext * context, /* [in] Additional context info, if any */
351 CMPIResult * results, /* [out] Results of this operation */
352 CMPISelectExp * filter, /* [in] Indication filter query */
353 const char * eventtype, /* [in] Filter target class(es) */
354 CMPIObjectPath * reference, /* [in] Namespace and classname of monitored class */
355 CMPIBoolean first ) /* [in] Is this the first filter for this eventtype? */
356 {
357 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */
358 // CMPIBoolean activated = CMPI_true;
359 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
360 char * classname = CMGetCharPtr(CMGetClassName(reference, NULL)); /* Target class. */
362 _SBLIM_ENTER("ActivateFilter");
363 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
364 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
365 _SBLIM_TRACE(2, ("--- filter=\"%s\"", CMGetCharPtr(CMGetSelExpString(filter, NULL))));
366 _SBLIM_TRACE(2, ("--- eventtype=\"%s\"", eventtype));
367 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
368 _SBLIM_TRACE(2, ("--- first=%s", (first)? "TRUE":"FALSE"));
369 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
370 _SBLIM_TRACE(2, ("--- classname=\"%s\"", classname));
372 numActiveFilters++;
373 _SBLIM_TRACE(2, ("--- numActiveFilters=%d", numActiveFilters));
375 /* Startup the indication generator if it isn't already running */
376 if (indicationThreadId == 0) {
377 /* Get the context for the new indication generator thread */
378 CMPIContext * indicationContext = CBPrepareAttachThread(_BROKER, context);
379 _SBLIM_TRACE(2, ("--- indicationcontext=\"%s\"", CMGetCharPtr(CDToString(_BROKER, indicationContext, NULL))));
381 /* Statup a new non-detached thread to run the indication generator */
382 _SBLIM_TRACE(1,("--- Starting up indication generator thread"));
383 indicationThreadId = _BROKER->xft->newThread(_indicationThread, indicationContext, 0);
384 }
386 exit:
387 // CMReturnData(results, (CMPIValue *)&activated, CMPI_boolean);
388 // CMReturnDone(results);
389 _SBLIM_RETURNSTATUS(status);
390 }
392 // ----------------------------------------------------------------------------
393 // DeActivateFilter()
394 // Remove a subscriber and if necessary stop generating indications.
395 // ----------------------------------------------------------------------------
396 static CMPIStatus DeActivateFilter(
397 CMPIIndicationMI * self, /* [in] Handle to this provider (i.e. 'self') */
398 CMPIContext * context, /* [in] Additional context info, if any */
399 CMPIResult * results, /* [out] Results of this operation */
400 CMPISelectExp * filter, /* [in] Indication filter query */
401 const char * eventtype, /* [in] Filter target class(es) */
402 CMPIObjectPath * reference, /* [in] Namespace and classname of monitored class */
403 CMPIBoolean last ) /* [in] Is this the last filter for this eventtype? */
404 {
405 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */
406 CMPIContext * indicationContext;
407 // CMPIBoolean deactivated = CMPI_true;
408 char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL)); /* Target namespace. */
409 char * classname = CMGetCharPtr(CMGetClassName(reference, NULL)); /* Target class. */
411 _SBLIM_ENTER("DeActivateFilter");
412 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
413 _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
414 _SBLIM_TRACE(2, ("--- filter=\"%s\"", CMGetCharPtr(CMGetSelExpString(filter, NULL))));
415 _SBLIM_TRACE(2, ("--- eventtype=\"%s\"", eventtype));
416 _SBLIM_TRACE(2, ("--- reference=\"%s\"", CMGetCharPtr(CDToString(_BROKER, reference, NULL))));
417 _SBLIM_TRACE(2, ("--- last=%s", (last)? "TRUE":"FALSE"));
418 _SBLIM_TRACE(2, ("--- namespace=\"%s\"", namespace));
419 _SBLIM_TRACE(2, ("--- classname=\"%s\"", classname));
421 if (numActiveFilters == 0) {
422 // deactivated = CMPI_false;
423 CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "No active filters");
424 goto exit;
425 }
427 numActiveFilters--;
428 _SBLIM_TRACE(2,("--- numActiveFilters=%d", numActiveFilters));
430 /* If no active filters then shutdown the indication generator thread */
431 if ((numActiveFilters == 0) && indicationThreadId != 0) {
432 _SBLIM_TRACE(1,("--- Shutting down indication generator thread"));
433 _BROKER->xft->cancelThread(indicationThreadId);
434 indicationThreadId = 0;
435 }
437 exit:
438 // CMReturnData(results, (CMPIValue *)&deactivated, CMPI_boolean);
439 // CMReturnDone(results);
440 _SBLIM_RETURNSTATUS(status);
441 }
443 // ----------------------------------------------------------------------------
444 // EnableIndications()
445 // ----------------------------------------------------------------------------
446 static void EnableIndications( CMPIIndicationMI * self )
447 {
448 _SBLIM_ENTER("EnableIndications");
449 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
451 /* Enable indication generation */
452 enabled = 1;
454 _SBLIM_RETURN();
455 }
457 // ----------------------------------------------------------------------------
458 // DisableIndications()
459 // ----------------------------------------------------------------------------
460 static void DisableIndications( CMPIIndicationMI * self )
461 {
462 _SBLIM_ENTER("DisableIndications");
463 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
465 /* Disable indication generation */
466 enabled = 0;
468 _SBLIM_RETURN();
469 }
471 // ----------------------------------------------------------------------------
472 // IndicationInitialize()
473 // Perform any necessary initialization immediately after this provider is
474 // first loaded.
475 // ----------------------------------------------------------------------------
476 static void IndicationInitialize(
477 CMPIInstanceMI * self, /* [in] Handle to this provider (i.e. 'self'). */
478 CMPIContext * context) /* [in] Additional context info, if any. */
479 {
480 CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */
482 _SBLIM_ENTER("IndicationInitialize");
483 _SBLIM_TRACE(2, ("--- self=\"%s\"", self->ft->miName));
484 // _SBLIM_TRACE(2, ("--- context=\"%s\"", CMGetCharPtr(CDToString(_BROKER, context, NULL))));
486 /* Create an object path for the monitored class. */
487 CMPIObjectPath * objectpath = CMNewObjectPath(_BROKER, _NAMESPACE, _CLASSNAME, &status);
488 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(objectpath)) {
489 _SBLIM_TRACE(1,("--- CMNewObjectPath() failed - %s", CMGetCharPtr(status.msg)));
490 goto exit;
491 }
493 /* Get the current list of instances of the monitored class. */
494 CMPIEnumeration * instances = CBEnumInstances(_BROKER, context, objectpath, NULL, &status);
495 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(instances)) {
496 _SBLIM_TRACE(1,("--- CBEnumInstanceNames() failed - %s", CMGetCharPtr(status.msg)));
497 goto exit;
498 }
500 /* Save a copy of the array of instances. */
501 currentinstances = CMToArray(instances, &status);
502 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(currentinstances)) {
503 _SBLIM_TRACE(1,("--- CMToArray() failed - %s", CMGetCharPtr(status.msg)));
504 currentinstances = NULL;
505 goto exit;
506 }
508 _SBLIM_TRACE(4,("before CMClone()"));
509 currentinstances = CMClone(currentinstances, &status);
510 _SBLIM_TRACE(4,("after CMClone()"));
511 if ((status.rc != CMPI_RC_OK) || CMIsNullObject(currentinstances)) {
512 _SBLIM_TRACE(1,("--- CMClone() failed - %s", CMGetCharPtr(status.msg)));
513 if (currentinstances != NULL) CMRelease(currentinstances);
514 currentinstances = NULL;
515 goto exit;
516 }
518 exit:
519 _SBLIM_RETURN();
520 }
522 // ============================================================================
523 // CMPI INDICATION PROVIDER FUNCTION TABLE SETUP
524 // ============================================================================
525 CMIndicationMIStub( , Xen_ComputerSystemIndication, _BROKER, IndicationInitialize(&mi, ctx));