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