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