1 karl 1.15 //%2003////////////////////////////////////////////////////////////////////////
|
2 chip 1.1 //
|
3 karl 1.15 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 chip 1.1 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
|
14 chip 1.17 //
|
15 chip 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Chip Vincent (cvincent@us.ibm.com)
27 //
28 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
29 // (carolann_graves@hp.com)
30 // Mike Day, IBM (mdday@us.ibm.com)
31 // Karl Schopmeyer(k.schopmeyer@opengroup.org) - Fix associators.
|
32 chip 1.9 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
|
33 schuur 1.19 // Adrian Schuur, IBM (schuur@de.ibm.com)
|
34 a.arora 1.37 // Amit K Arora (amita@in.ibm.com) for PEP-101
|
35 kumpf 1.39 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
36 se.gupta 1.41 // Seema Gupta (gseema@in.ibm.com for PEP135)
|
37 chip 1.1 //
38 //%/////////////////////////////////////////////////////////////////////////////
39
40 #include "ProviderManagerService.h"
41
42 #include <Pegasus/Common/Config.h>
43 #include <Pegasus/Common/Constants.h>
44 #include <Pegasus/Common/CIMMessage.h>
|
45 kumpf 1.39 #include <Pegasus/Common/Thread.h>
|
46 chip 1.1 #include <Pegasus/Common/Tracer.h>
47 #include <Pegasus/Common/Logger.h>
|
48 a.arora 1.37 #include <Pegasus/Common/AutoPtr.h>
|
49 chip 1.1
|
50 chip 1.6 #include <Pegasus/Config/ConfigManager.h>
51
|
52 kumpf 1.39 #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h>
|
53 chip 1.17
|
54 chip 1.1 PEGASUS_NAMESPACE_BEGIN
55
|
56 kumpf 1.38 static const Uint16 _MODULE_OK = 2;
57 static const Uint16 _MODULE_STOPPING = 9;
58 static const Uint16 _MODULE_STOPPED = 10;
59
|
60 chip 1.11 inline Boolean _isSupportedRequestType(const Message * message)
61 {
62 // ATTN: needs implementation
63
64 // for now, assume all requests are valid
65
66 return(true);
|
67 chip 1.3 }
68
69 inline Boolean _isSupportedResponseType(const Message * message)
70 {
|
71 chip 1.11 // ATTN: needs implementation
72
73 // for now, assume all responses are invalid
|
74 chip 1.3
|
75 chip 1.11 return(false);
|
76 chip 1.3 }
77
|
78 schuur 1.19 ProviderManagerService* ProviderManagerService::providerManagerService=NULL;
|
79 kumpf 1.39 Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND;
|
80 schuur 1.19
|
81 chip 1.1 ProviderManagerService::ProviderManagerService(void)
82 : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)
83 {
|
84 schuur 1.19 providerManagerService=this;
|
85 chip 1.1 }
86
|
87 schuur 1.25 ProviderManagerService::ProviderManagerService(
88 ProviderRegistrationManager * providerRegistrationManager,
89 CIMRepository * repository)
|
90 chip 1.1 : MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP)
91 {
|
92 schuur 1.19 providerManagerService=this;
|
93 schuur 1.25 _repository=repository;
|
94 dj.gorey 1.31
|
95 kumpf 1.38 _providerRegistrationManager = providerRegistrationManager;
|
96 kumpf 1.44
97 _unloadIdleProvidersBusy = 0;
98
|
99 kumpf 1.39 _providerManagerRouter =
100 new BasicProviderManagerRouter(indicationCallback);
|
101 chip 1.1 }
102
103 ProviderManagerService::~ProviderManagerService(void)
104 {
|
105 kumpf 1.39 delete _providerManagerRouter;
|
106 schuur 1.19 providerManagerService=NULL;
|
107 chip 1.1 }
108
109 Boolean ProviderManagerService::messageOK(const Message * message)
110 {
111 PEGASUS_ASSERT(message != 0);
112
|
113 chip 1.3 if(_isSupportedRequestType(message))
|
114 chip 1.1 {
|
115 chip 1.3 return(MessageQueueService::messageOK(message));
|
116 chip 1.1 }
117
|
118 chip 1.3 return(false);
|
119 chip 1.1 }
120
121 void ProviderManagerService::handleEnqueue(void)
122 {
123 Message * message = dequeue();
124
125 handleEnqueue(message);
126 }
127
128 void ProviderManagerService::handleEnqueue(Message * message)
129 {
130 PEGASUS_ASSERT(message != 0);
131
132 AsyncLegacyOperationStart * asyncRequest;
133
134 if(message->_async != NULL)
135 {
136 asyncRequest = static_cast<AsyncLegacyOperationStart *>(message->_async);
137 }
138 else
139 {
140 chip 1.1 asyncRequest = new AsyncLegacyOperationStart(
141 get_next_xid(),
142 0,
143 this->getQueueId(),
144 message,
145 this->getQueueId());
146 }
147
148 _handle_async_request(asyncRequest);
149 }
150
151 void ProviderManagerService::_handle_async_request(AsyncRequest * request)
152 {
153 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
154 "ProviderManagerService::_handle_async_request");
155
156 PEGASUS_ASSERT((request != 0) && (request->op != 0));
157
158 if(request->getType() == async_messages::ASYNC_LEGACY_OP_START)
159 {
160 request->op->processing();
161 chip 1.1
162 _incomingQueue.enqueue(request->op);
163
|
164 schuur 1.32 while (!_thread_pool->allocate_and_awaken(
165 (void *)this, ProviderManagerService::handleCimOperation))
166 {
167 pegasus_yield();
168 }
|
169 chip 1.1 }
170 else
171 {
172 // pass all other operations to the default handler
173 MessageQueueService::_handle_async_request(request);
174 }
175
176 PEG_METHOD_EXIT();
177
178 return;
179 }
180
|
181 kumpf 1.39 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
182 ProviderManagerService::handleCimOperation(void * arg) throw()
|
183 chip 1.1 {
|
184 kumpf 1.39 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
185 "ProviderManagerService::handleCimOperation");
|
186 chip 1.1
|
187 chip 1.8 if(arg == 0)
188 {
189 // thread started with invalid argument.
190 return(PEGASUS_THREAD_RETURN(1));
191 }
192
|
193 chip 1.1 // get the service from argument
|
194 kumpf 1.39 ProviderManagerService * service =
195 reinterpret_cast<ProviderManagerService *>(arg);
|
196 chip 1.1
197 if(service->_incomingQueue.size() == 0)
198 {
199 PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4,
|
200 kumpf 1.39 "ProviderManagerService::handleCimOperation() called with no "
201 "op node in queue");
|
202 chip 1.1
203 PEG_METHOD_EXIT();
204
205 // thread started with no message in queue.
206 return(PEGASUS_THREAD_RETURN(1));
207 }
208
209 AsyncOpNode * op = service->_incomingQueue.dequeue();
210
|
211 chip 1.8 if((op == 0) || (op->_request.count() == 0))
|
212 chip 1.1 {
|
213 kumpf 1.39 // ATTN: This may dereference a null pointer!
|
214 chip 1.1 MessageQueue * queue = MessageQueue::lookup(op->_source_queue);
215
216 PEGASUS_ASSERT(queue != 0);
217
218 PEG_METHOD_EXIT();
219
220 // no request in op node
221 return(PEGASUS_THREAD_RETURN(1));
222 }
223
224 AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0));
225
|
226 kumpf 1.39 if ((request == 0) ||
227 (request->getType() != async_messages::ASYNC_LEGACY_OP_START))
|
228 chip 1.1 {
229 // reply with NAK
230 PEG_METHOD_EXIT();
231 return(PEGASUS_THREAD_RETURN(0));
232 }
233
|
234 chip 1.8 try
|
235 chip 1.1 {
|
236 kumpf 1.39 Message* legacy =
237 static_cast<AsyncLegacyOperationStart *>(request)->get_action();
|
238 chip 1.1
|
239 chip 1.8 if(_isSupportedRequestType(legacy))
|
240 chip 1.1 {
|
241 a.arora 1.37 AutoPtr<Message> xmessage(legacy);
|
242 chip 1.1
|
243 chip 1.8 // Set the client's requested language into this service thread.
244 // This will allow functions in this service to return messages
245 // in the correct language.
|
246 kumpf 1.39 CIMMessage* msg = dynamic_cast<CIMMessage *>(legacy);
|
247 chip 1.8
|
248 kumpf 1.39 if (msg != 0)
|
249 chip 1.8 {
|
250 kumpf 1.39 AcceptLanguages* langs =
251 new AcceptLanguages(msg->acceptLanguages);
|
252 chip 1.8 Thread::setLanguages(langs);
253 }
254 else
255 {
256 Thread::clearLanguages();
257 }
|
258 chip 1.1
259 service->handleCimRequest(op, legacy);
|
260 chip 1.3 }
|
261 chip 1.8 }
262 catch(...)
263 {
264 // ATTN: log error
|
265 chip 1.1 }
266
267 PEG_METHOD_EXIT();
268
269 return(PEGASUS_THREAD_RETURN(0));
270 }
271
|
272 kumpf 1.39 void ProviderManagerService::handleCimRequest(
273 AsyncOpNode * op,
274 Message * message)
|
275 chip 1.1 {
|
276 kumpf 1.39 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
277 "ProviderManagerService::handleCimRequest");
|
278 chip 1.1
|
279 kumpf 1.38 CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message);
280 PEGASUS_ASSERT(request != 0);
|
281 chip 1.1
282 // get request from op node
283 AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0));
|
284 kumpf 1.38 PEGASUS_ASSERT(async != 0);
285
286 Message * response = 0;
|
287 chip 1.1
|
288 kumpf 1.38 if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) ||
|
289 kumpf 1.40 (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) ||
|
290 kumpf 1.45 (request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE))
|
291 kumpf 1.38 {
|
292 kumpf 1.45 // Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage,
293 // and CIMInitializeProviderRequestMessage
294
295 // Note: The provider ID container is added to the OperationContext
296 // by the CIMOperationRequestDispatcher for all CIM operation
297 // requests to providers, so it does not need to be added again.
298
299 // Get a ProviderIdContainer for ExportIndicationRequestMessage
300 if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE)
301 {
302 ProviderIdContainer pidc = _getProviderIdContainer(request);
|
303 se.gupta 1.41 request->operationContext.insert(pidc);
|
304 kumpf 1.45 }
|
305 kumpf 1.38
|
306 kumpf 1.45 //
307 // Check if the target provider is disabled
308 //
309 Boolean moduleDisabled = false;
310 ProviderIdContainer pidc =
311 request->operationContext.get(ProviderIdContainer::NAME);
312 const CIMInstance providerModule = pidc.getModule();
313 Uint32 pos = providerModule.findProperty(CIMName("OperationalStatus"));
314 PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
315 Array<Uint16> operationalStatus;
316 providerModule.getProperty(pos).getValue().get(operationalStatus);
317
318 for(Uint32 i = 0; i < operationalStatus.size(); i++)
319 {
320 if ((operationalStatus[i] == _MODULE_STOPPED) ||
321 (operationalStatus[i] == _MODULE_STOPPING))
322 {
323 moduleDisabled = true;
324 break;
325 }
326 }
327 kumpf 1.45
328 if (moduleDisabled)
329 {
330 //
331 // Send a "provider blocked" response
332 //
333 CIMResponseMessage* cimResponse = request->buildResponse();
334 cimResponse->cimException = PEGASUS_CIM_EXCEPTION_L(
335 CIM_ERR_ACCESS_DENIED,
336 MessageLoaderParms(
337 "ProviderManager.ProviderManagerService.PROVIDER_BLOCKED",
338 "provider blocked."));
339 response = cimResponse;
340 }
341 else
342 {
343 //
344 // Forward the request to the appropriate ProviderManagerRouter
345 //
346 response = _providerManagerRouter->processMessage(request);
347 }
|
348 schuur 1.19 }
|
349 kumpf 1.38 else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE)
350 {
351 // Handle CIMEnableModuleRequestMessage
352 CIMEnableModuleRequestMessage * emReq =
353 dynamic_cast<CIMEnableModuleRequestMessage*>(request);
354
355 CIMInstance providerModule = emReq->providerModule;
|
356 dj.gorey 1.31
|
357 kumpf 1.38 try
358 {
|
359 kumpf 1.39 // Forward the request to the ProviderManager
360 response = _providerManagerRouter->processMessage(request);
|
361 kumpf 1.38
362 // If successful, update provider module status to OK
363 // ATTN: Use CIMEnableModuleResponseMessage operationalStatus?
364 CIMEnableModuleResponseMessage * emResp =
365 dynamic_cast<CIMEnableModuleResponseMessage*>(response);
366 if (emResp->cimException.getCode() == CIM_ERR_SUCCESS)
367 {
368 _updateProviderModuleStatus(
369 providerModule, _MODULE_STOPPED, _MODULE_OK);
370 }
371 }
372 catch (Exception& e)
373 {
374 // Get the OperationalStatus property from the provider module
375 Array<Uint16> operationalStatus;
376 CIMValue itValue = emReq->providerModule.getProperty(
377 emReq->providerModule.findProperty("OperationalStatus"))
378 .getValue();
379 itValue.get(operationalStatus);
380
381 if (response != 0)
382 kumpf 1.38 {
383 delete response;
384 }
385
386 response = new CIMEnableModuleResponseMessage(
387 request->messageId,
388 CIMException(CIM_ERR_FAILED, e.getMessage()),
389 request->queueIds.copyAndPop(),
390 operationalStatus);
391 }
392 }
393 else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE)
394 {
395 // Handle CIMDisableModuleRequestMessage
396 CIMDisableModuleRequestMessage * dmReq =
397 dynamic_cast<CIMDisableModuleRequestMessage*>(request);
398
399 CIMInstance providerModule = dmReq->providerModule;
400 Boolean updateModuleStatus = !dmReq->disableProviderOnly;
401
402 try
403 kumpf 1.38 {
404 // Change module status from OK to STOPPING
405 if (updateModuleStatus)
406 {
407 _updateProviderModuleStatus(
408 providerModule, _MODULE_OK, _MODULE_STOPPING);
409 }
410
|
411 kumpf 1.39 // Forward the request to the ProviderManager
412 response = _providerManagerRouter->processMessage(request);
|
413 kumpf 1.38
414 // Update provider module status based on success or failure
415 if (updateModuleStatus)
416 {
417 CIMDisableModuleResponseMessage * dmResp =
418 dynamic_cast<CIMDisableModuleResponseMessage*>(response);
419 if (dmResp->cimException.getCode() != CIM_ERR_SUCCESS)
420 {
421 // Disable operation failed. Module not stopped.
422 _updateProviderModuleStatus(
423 providerModule, _MODULE_STOPPING, _MODULE_OK);
424 }
425 else
426 {
427 // Disable may or may not have been successful,
428 // depending on whether there are outstanding requests.
429 // Use last operationalStatus entry.
430 _updateProviderModuleStatus(
431 providerModule, _MODULE_STOPPING,
432 dmResp->operationalStatus[
433 dmResp->operationalStatus.size()-1]);
434 kumpf 1.38 }
435 }
436 }
437 catch (Exception& e)
438 {
439 // Get the OperationalStatus property from the provider module
440 Array<Uint16> operationalStatus;
441 CIMValue itValue = dmReq->providerModule.getProperty(
442 dmReq->providerModule.findProperty("OperationalStatus"))
443 .getValue();
444 itValue.get(operationalStatus);
445
446 if (response != 0)
447 {
448 delete response;
449 }
450
451 response = new CIMDisableModuleResponseMessage(
452 request->messageId,
453 CIMException(CIM_ERR_FAILED, e.getMessage()),
454 request->queueIds.copyAndPop(),
455 kumpf 1.38 operationalStatus);
456 }
457 }
458 else
459 {
|
460 kumpf 1.39 response = _providerManagerRouter->processMessage(request);
|
461 schuur 1.23 }
|
462 chip 1.13
|
463 schuur 1.19 AsyncLegacyOperationResult * async_result =
464 new AsyncLegacyOperationResult(
465 async->getKey(),
466 async->getRouting(),
467 op,
468 response);
|
469 chip 1.13
|
470 schuur 1.19 _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);
|
471 chip 1.13
|
472 schuur 1.19 PEG_METHOD_EXIT();
473 }
|
474 chip 1.13
|
475 kumpf 1.44 void ProviderManagerService::unloadIdleProviders()
476 {
477 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
478 "ProviderManagerService::unloadIdleProviders");
479
480 // Ensure that only one _unloadIdleProvidersHandler thread runs at a time
481 _unloadIdleProvidersBusy++;
482 if ((_unloadIdleProvidersBusy.value() == 1) &&
483 (_thread_pool->allocate_and_awaken(
484 (void*)this, ProviderManagerService::_unloadIdleProvidersHandler)))
485 {
486 // _unloadIdleProvidersBusy is decremented in
487 // _unloadIdleProvidersHandler
488 }
489 else
490 {
491 // If we fail to allocate a thread, don't retry now.
492 _unloadIdleProvidersBusy--;
493 }
494
495 PEG_METHOD_EXIT();
496 kumpf 1.44 }
497
498 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL
499 ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw()
|
500 chip 1.1 {
|
501 kumpf 1.44 try
502 {
503 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
504 "ProviderManagerService::unloadIdleProvidersHandler");
505
506 ProviderManagerService* myself =
507 reinterpret_cast<ProviderManagerService*>(arg);
508
509 try
510 {
511 myself->_providerManagerRouter->unloadIdleProviders();
512 }
513 catch (...)
514 {
515 // Ignore errors
516 PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
517 "Unexpected exception in _unloadIdleProvidersHandler");
518 }
519
520 myself->_unloadIdleProvidersBusy--;
521 PEG_METHOD_EXIT();
522 kumpf 1.44 }
523 catch (...)
524 {
525 // Ignore errors
526 PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,
527 "Unexpected exception in _unloadIdleProvidersHandler");
528 }
529
530 return(PEGASUS_THREAD_RETURN(0));
|
531 kumpf 1.38 }
532
533 ProviderIdContainer ProviderManagerService::_getProviderIdContainer(
534 const CIMRequestMessage* message)
535 {
536 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
537 "ProviderManagerService::_getProviderIdContainer");
538
539 CIMInstance providerModule;
540 CIMInstance provider;
541
542 switch (message->getType())
543 {
544 case CIM_GET_CLASS_REQUEST_MESSAGE:
545 case CIM_DELETE_CLASS_REQUEST_MESSAGE:
546 case CIM_CREATE_CLASS_REQUEST_MESSAGE:
547 case CIM_MODIFY_CLASS_REQUEST_MESSAGE:
548 case CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE:
549 case CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE:
550 case CIM_GET_QUALIFIER_REQUEST_MESSAGE:
551 case CIM_SET_QUALIFIER_REQUEST_MESSAGE:
552 kumpf 1.38 case CIM_DELETE_QUALIFIER_REQUEST_MESSAGE:
553 case CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE:
554 // The ProviderManagerService does not support class operations
555 PEGASUS_ASSERT(0);
556 break;
557
558 case CIM_GET_INSTANCE_REQUEST_MESSAGE:
559 case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:
560 case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:
561 case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:
562 case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:
563 case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:
564 case CIM_GET_PROPERTY_REQUEST_MESSAGE:
565 case CIM_SET_PROPERTY_REQUEST_MESSAGE:
566 {
567 // Look up instance provider
568 const CIMOperationRequestMessage* request =
569 dynamic_cast<const CIMOperationRequestMessage*>(message);
570 _providerRegistrationManager->lookupInstanceProvider(
571 request->nameSpace, request->className, provider, providerModule);
572 break;
573 kumpf 1.38 }
574
575 case CIM_EXEC_QUERY_REQUEST_MESSAGE:
576 {
577 // Look up instance query provider
578 const CIMOperationRequestMessage* request =
579 dynamic_cast<const CIMOperationRequestMessage*>(message);
580 Boolean hasNoQuery;
581 _providerRegistrationManager->lookupInstanceProvider(
582 request->nameSpace, request->className, provider, providerModule,
583 0, &hasNoQuery);
584 // We shouldn't have gotten this far if this isn't a query provider
585 PEGASUS_ASSERT(!hasNoQuery);
586 break;
587 }
588
589 case CIM_ASSOCIATORS_REQUEST_MESSAGE:
590 {
591 // Look up association provider
592 const CIMAssociatorsRequestMessage* request =
593 dynamic_cast<const CIMAssociatorsRequestMessage*>(message);
594 kumpf 1.38 Array<CIMInstance> providerModules;
595 Array<CIMInstance> providers;
596 _providerRegistrationManager->lookupAssociationProvider(
|
597 kumpf 1.39 request->nameSpace, request->assocClass,
598 providers, providerModules);
|
599 kumpf 1.38 providerModule = providerModules[0];
600 provider = providers[0];
601 break;
602 }
603
604 case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE:
605 {
606 // Look up association provider
607 const CIMAssociatorNamesRequestMessage* request =
608 dynamic_cast<const CIMAssociatorNamesRequestMessage*>(message);
609 Array<CIMInstance> providerModules;
610 Array<CIMInstance> providers;
611 _providerRegistrationManager->lookupAssociationProvider(
|
612 kumpf 1.39 request->nameSpace, request->assocClass,
613 providers, providerModules);
|
614 kumpf 1.38 providerModule = providerModules[0];
615 provider = providers[0];
616 break;
617 }
618
619 case CIM_REFERENCES_REQUEST_MESSAGE:
620 {
621 // Look up association provider
622 const CIMReferencesRequestMessage* request =
623 dynamic_cast<const CIMReferencesRequestMessage*>(message);
624 Array<CIMInstance> providerModules;
625 Array<CIMInstance> providers;
626 _providerRegistrationManager->lookupAssociationProvider(
|
627 kumpf 1.39 request->nameSpace, request->resultClass,
628 providers, providerModules);
|
629 kumpf 1.38 providerModule = providerModules[0];
630 provider = providers[0];
631 break;
632 }
633
634 case CIM_REFERENCE_NAMES_REQUEST_MESSAGE:
635 {
636 // Look up association provider
637 const CIMReferenceNamesRequestMessage* request =
638 dynamic_cast<const CIMReferenceNamesRequestMessage*>(message);
639 Array<CIMInstance> providerModules;
640 Array<CIMInstance> providers;
641 _providerRegistrationManager->lookupAssociationProvider(
|
642 kumpf 1.39 request->nameSpace, request->resultClass,
643 providers, providerModules);
|
644 kumpf 1.38 providerModule = providerModules[0];
645 provider = providers[0];
646 break;
647 }
648
649 case CIM_INVOKE_METHOD_REQUEST_MESSAGE:
650 {
651 // Look up method provider
652 const CIMInvokeMethodRequestMessage* request =
653 dynamic_cast<const CIMInvokeMethodRequestMessage*>(message);
654 _providerRegistrationManager->lookupMethodProvider(
655 request->nameSpace, request->className, request->methodName,
656 provider, providerModule);
657 break;
658 }
659
660 case CIM_EXPORT_INDICATION_REQUEST_MESSAGE:
661 {
662 const CIMExportIndicationRequestMessage* request =
663 dynamic_cast<const CIMExportIndicationRequestMessage*>(message);
664 _providerRegistrationManager->lookupIndicationConsumer(
665 kumpf 1.38 request->destinationPath, provider, providerModule);
666 break;
667 }
668
669 case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE:
670 case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE:
671 case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE:
672 case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE:
673 case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE:
674 {
675 // Provider information is already in the message
676 const CIMIndicationRequestMessage* request =
677 dynamic_cast<const CIMIndicationRequestMessage*>(message);
678 providerModule = request->providerModule;
679 provider = request->provider;
680 break;
681 }
682
683 case CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:
684 case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:
685 case CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE:
686 kumpf 1.38 case CIM_PROCESS_INDICATION_REQUEST_MESSAGE:
687 case CIM_HANDLE_INDICATION_REQUEST_MESSAGE:
688 case CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE:
689 case CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE:
690 // These messages are not handled by the ProviderManagerService
691 PEGASUS_ASSERT(0);
692 break;
693
694 case CIM_DISABLE_MODULE_REQUEST_MESSAGE:
695 case CIM_ENABLE_MODULE_REQUEST_MESSAGE:
696 case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE:
697 // These messages are handled specially by the ProviderManagerService
698 PEGASUS_ASSERT(0);
699 break;
|
700 kumpf 1.40
701 case CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE:
702 {
703 // Provider information is already in the message
704 const CIMInitializeProviderRequestMessage* request =
705 dynamic_cast<const CIMInitializeProviderRequestMessage*>(message);
|
706 kumpf 1.43
707 const ProviderIdContainer container =
708 request->operationContext.get(ProviderIdContainer::NAME);
709 providerModule = container.getModule();
710 provider = container.getProvider();
|
711 kumpf 1.40 break;
712 }
713
|
714 kumpf 1.38 }
715
716 PEGASUS_ASSERT(!providerModule.isUninitialized());
717 PEGASUS_ASSERT(!provider.isUninitialized());
718
719 PEG_METHOD_EXIT();
720 return ProviderIdContainer(providerModule, provider);
721 }
722
723 // Updates the providerModule instance and the ProviderRegistrationManager
724 void ProviderManagerService::_updateProviderModuleStatus(
725 CIMInstance& providerModule,
726 Uint16 fromStatus,
727 Uint16 toStatus)
728 {
729 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
730 "ProviderManagerService::_updateProviderModuleStatus");
731
732 Array<Uint16> operationalStatus;
733 String providerModuleName;
734
735 kumpf 1.38 Uint32 pos = providerModule.findProperty(CIMName("Name"));
736 PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
737 providerModule.getProperty(pos).getValue().get(providerModuleName);
738
739 //
740 // get operational status
741 //
742 pos = providerModule.findProperty(CIMName("OperationalStatus"));
743 PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
744 CIMProperty operationalStatusProperty = providerModule.getProperty(pos);
745 CIMValue operationalStatusValue = operationalStatusProperty.getValue();
746
747 if (!operationalStatusValue.isNull())
748 {
749 operationalStatusValue.get(operationalStatus);
750 }
751
752 //
753 // update module status
754 //
755 for (Uint32 i = operationalStatus.size(); i > 0; i--)
756 kumpf 1.38 {
757 if (operationalStatus[i-1] == fromStatus)
758 {
759 operationalStatus.remove(i-1);
760 }
761 }
762
763 operationalStatus.append(toStatus);
764
765 if (_providerRegistrationManager->setProviderModuleStatus(
766 providerModuleName, operationalStatus) == false)
767 {
768 throw PEGASUS_CIM_EXCEPTION_L(
769 CIM_ERR_FAILED,
770 MessageLoaderParms(
771 "ProviderManager.ProviderManagerService."
772 "SET_MODULE_STATUS_FAILED",
773 "set module status failed."));
774 }
775
776 operationalStatusProperty.setValue(CIMValue(operationalStatus));
777 kumpf 1.38
778 PEG_METHOD_EXIT();
|
779 kumpf 1.39 }
780
781 void ProviderManagerService::indicationCallback(
782 CIMProcessIndicationRequestMessage* request)
783 {
784 if (_indicationServiceQueueId == PEG_NOT_FOUND)
785 {
786 Array<Uint32> serviceIds;
787
788 providerManagerService->find_services(
789 PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);
790 PEGASUS_ASSERT(serviceIds.size() != 0);
791
792 _indicationServiceQueueId = serviceIds[0];
793 }
794
795 request->queueIds = QueueIdStack(
796 _indicationServiceQueueId, providerManagerService->getQueueId());
797
798 AsyncLegacyOperationStart * asyncRequest =
799 new AsyncLegacyOperationStart(
800 kumpf 1.39 providerManagerService->get_next_xid(),
801 0,
802 _indicationServiceQueueId,
803 request,
804 _indicationServiceQueueId);
805
806 providerManagerService->SendForget(asyncRequest);
|
807 chip 1.1 }
808
|
809 a.arora 1.37 PEGASUS_NAMESPACE_END
|