version 1.55, 2004/07/28 01:24:50
|
version 1.67, 2005/05/06 21:44:28
|
|
|
//%2003//////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; | // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
// IBM Corp.; EMC Corporation, The Open Group. | // IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
#include "ProviderManagerService.h" | #include "ProviderManagerService.h" |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
#include <Pegasus/Common/PegasusVersion.h> |
#include <Pegasus/Common/Constants.h> | #include <Pegasus/Common/Constants.h> |
#include <Pegasus/Common/CIMMessage.h> | #include <Pegasus/Common/CIMMessage.h> |
#include <Pegasus/Common/Thread.h> | #include <Pegasus/Common/Thread.h> |
|
|
| |
#include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h> | #include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h> |
#include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h> | #include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h> |
|
#include <Pegasus/ProviderManager2/OperationResponseHandler.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
| |
_unloadIdleProvidersBusy = 0; | _unloadIdleProvidersBusy = 0; |
| |
// Determine whether Out-of-Process Provider support is enabled |
_basicProviderManagerRouter = 0; |
|
_oopProviderManagerRouter = 0; |
|
|
|
// Determine which ProviderManagerRouter(s) to use |
|
|
ConfigManager* configManager = ConfigManager::getInstance(); | ConfigManager* configManager = ConfigManager::getInstance(); |
if (String::equal( |
Boolean forceProviderProcesses = String::equal( |
configManager->getCurrentValue("enableProviderProcesses"), "true")) |
configManager->getCurrentValue("forceProviderProcesses"), "true"); |
|
|
|
#ifdef PEGASUS_DISABLE_PROV_USERCTXT |
|
if (forceProviderProcesses) |
{ | { |
_providerManagerRouter = |
_oopProviderManagerRouter = |
new OOPProviderManagerRouter(indicationCallback); | new OOPProviderManagerRouter(indicationCallback); |
} | } |
else | else |
{ | { |
_providerManagerRouter = |
_basicProviderManagerRouter = |
new BasicProviderManagerRouter(indicationCallback); | new BasicProviderManagerRouter(indicationCallback); |
} | } |
|
#else |
|
_oopProviderManagerRouter = |
|
new OOPProviderManagerRouter(indicationCallback); |
|
|
|
if (!forceProviderProcesses) |
|
{ |
|
_basicProviderManagerRouter = |
|
new BasicProviderManagerRouter(indicationCallback); |
|
} |
|
#endif |
} | } |
| |
ProviderManagerService::~ProviderManagerService(void) | ProviderManagerService::~ProviderManagerService(void) |
{ | { |
delete _providerManagerRouter; |
delete _basicProviderManagerRouter; |
|
delete _oopProviderManagerRouter; |
providerManagerService=NULL; | providerManagerService=NULL; |
} | } |
| |
|
|
return; | return; |
} | } |
| |
|
// Note: This method should not throw an exception. It is used as a thread |
|
// entry point, and any exceptions thrown are ignored. |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL | PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
ProviderManagerService::handleCimOperation(void * arg) throw() |
ProviderManagerService::handleCimOperation(void* arg) |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
"ProviderManagerService::handleCimOperation"); | "ProviderManagerService::handleCimOperation"); |
| |
if(arg == 0) |
PEGASUS_ASSERT(arg != 0); |
{ |
|
// thread started with invalid argument. |
|
return(PEGASUS_THREAD_RETURN(1)); |
|
} |
|
| |
// get the service from argument | // get the service from argument |
ProviderManagerService * service = | ProviderManagerService * service = |
reinterpret_cast<ProviderManagerService *>(arg); | reinterpret_cast<ProviderManagerService *>(arg); |
|
PEGASUS_ASSERT(service != 0); |
| |
|
try |
|
{ |
if(service->_incomingQueue.size() == 0) | if(service->_incomingQueue.size() == 0) |
{ | { |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
"ProviderManagerService::handleCimOperation() called with no " | "ProviderManagerService::handleCimOperation() called with no " |
"op node in queue"); | "op node in queue"); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
// thread started with no message in queue. |
|
return(PEGASUS_THREAD_RETURN(1)); | return(PEGASUS_THREAD_RETURN(1)); |
} | } |
| |
|
|
return(PEGASUS_THREAD_RETURN(1)); | return(PEGASUS_THREAD_RETURN(1)); |
} | } |
| |
AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0)); |
AsyncRequest* request = |
|
static_cast<AsyncRequest*>(op->_request.next(0)); |
| |
if ((request == 0) || | if ((request == 0) || |
(request->getType() != async_messages::ASYNC_LEGACY_OP_START)) | (request->getType() != async_messages::ASYNC_LEGACY_OP_START)) |
|
|
return(PEGASUS_THREAD_RETURN(0)); | return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
try |
|
{ |
|
Message* legacy = | Message* legacy = |
static_cast<AsyncLegacyOperationStart *>(request)->get_action(); | static_cast<AsyncLegacyOperationStart *>(request)->get_action(); |
| |
|
|
| |
if (msg != 0) | if (msg != 0) |
{ | { |
AcceptLanguages* langs = |
AcceptLanguages* langs = new AcceptLanguages( |
new AcceptLanguages(((AcceptLanguageListContainer)msg->operationContext.get |
((AcceptLanguageListContainer)msg->operationContext.get( |
(AcceptLanguageListContainer::NAME)).getLanguages()); |
AcceptLanguageListContainer::NAME)).getLanguages()); |
Thread::setLanguages(langs); | Thread::setLanguages(langs); |
} | } |
else | else |
|
|
service->handleCimRequest(op, legacy); | service->handleCimRequest(op, legacy); |
} | } |
} | } |
|
catch (const Exception& e) |
|
{ |
|
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
|
"Unexpected exception in handleCimOperation: " + e.getMessage()); |
|
} |
catch(...) | catch(...) |
{ | { |
// ATTN: log error |
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
|
"Unexpected exception in handleCimOperation."); |
} | } |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
PEGASUS_ASSERT(async != 0); | PEGASUS_ASSERT(async != 0); |
| |
Message * response = 0; | Message * response = 0; |
|
Boolean consumerLookupFailed = false; |
if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) || |
|
(dynamic_cast<CIMIndicationRequestMessage*>(request) != 0) || |
|
(request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) || |
|
(request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE)) |
|
{ |
|
// Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage, |
|
// CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage. |
|
// (These should be blocked when the provider module is disabled.) |
|
|
|
// |
|
// Get the provider module instance to check for a disabled module |
|
// |
|
CIMInstance providerModule; |
|
| |
if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) | if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) |
{ | { |
|
// |
// Get a ProviderIdContainer for ExportIndicationRequestMessage. | // Get a ProviderIdContainer for ExportIndicationRequestMessage. |
// Note: This can be removed when the CIMExportRequestDispatcher | // Note: This can be removed when the CIMExportRequestDispatcher |
// is updated to add the ProviderIdContainer to the message. | // is updated to add the ProviderIdContainer to the message. |
|
// |
|
CIMInstance providerModule; |
CIMInstance provider; | CIMInstance provider; |
const CIMExportIndicationRequestMessage* expRequest = | const CIMExportIndicationRequestMessage* expRequest = |
dynamic_cast<const CIMExportIndicationRequestMessage*>(request); | dynamic_cast<const CIMExportIndicationRequestMessage*>(request); |
_providerRegistrationManager->lookupIndicationConsumer( |
if (_providerRegistrationManager->lookupIndicationConsumer( |
expRequest->destinationPath, provider, providerModule); |
expRequest->destinationPath, provider, providerModule)) |
|
{ |
request->operationContext.insert( | request->operationContext.insert( |
ProviderIdContainer(providerModule, provider)); | ProviderIdContainer(providerModule, provider)); |
} | } |
else | else |
{ | { |
|
consumerLookupFailed = true; |
|
} |
|
} |
|
|
|
if (consumerLookupFailed) |
|
{ |
|
CIMResponseMessage* cimResponse = request->buildResponse(); |
|
cimResponse->cimException = PEGASUS_CIM_EXCEPTION( |
|
CIM_ERR_NOT_SUPPORTED, String::EMPTY); |
|
response = cimResponse; |
|
} |
|
else if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) || |
|
(dynamic_cast<CIMIndicationRequestMessage*>(request) != 0) || |
|
(request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) || |
|
(request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE)) |
|
{ |
|
// Handle CIMOperationRequestMessage, CIMExportIndicationRequestMessage, |
|
// CIMIndicationRequestMessage, and CIMInitializeProviderRequestMessage. |
|
// (These should be blocked when the provider module is disabled.) |
|
|
|
// |
|
// Get the provider module instance to check for a disabled module |
|
// |
|
CIMInstance providerModule; |
|
|
// The provider ID container is added to the OperationContext | // The provider ID container is added to the OperationContext |
// by the CIMOperationRequestDispatcher for all CIM operation | // by the CIMOperationRequestDispatcher for all CIM operation |
// requests to providers, so it does not need to be added again. | // requests to providers, so it does not need to be added again. |
|
|
ProviderIdContainer pidc = | ProviderIdContainer pidc = |
request->operationContext.get(ProviderIdContainer::NAME); | request->operationContext.get(ProviderIdContainer::NAME); |
providerModule = pidc.getModule(); | providerModule = pidc.getModule(); |
} |
|
| |
// | // |
// Check if the target provider is disabled | // Check if the target provider is disabled |
|
|
// | // |
// Forward the request to the appropriate ProviderManagerRouter | // Forward the request to the appropriate ProviderManagerRouter |
// | // |
response = _providerManagerRouter->processMessage(request); |
response = _processMessage(request); |
} | } |
} | } |
else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) | else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
|
|
try | try |
{ | { |
// Forward the request to the ProviderManager | // Forward the request to the ProviderManager |
response = _providerManagerRouter->processMessage(request); |
response = _processMessage(request); |
| |
// If successful, update provider module status to OK | // If successful, update provider module status to OK |
// ATTN: Use CIMEnableModuleResponseMessage operationalStatus? | // ATTN: Use CIMEnableModuleResponseMessage operationalStatus? |
|
|
} | } |
| |
// Forward the request to the ProviderManager | // Forward the request to the ProviderManager |
response = _providerManagerRouter->processMessage(request); |
response = _processMessage(request); |
| |
// Update provider module status based on success or failure | // Update provider module status based on success or failure |
if (updateModuleStatus) | if (updateModuleStatus) |
|
|
} | } |
else | else |
{ | { |
response = _providerManagerRouter->processMessage(request); |
response = _processMessage(request); |
} | } |
| |
AsyncLegacyOperationResult * async_result = | AsyncLegacyOperationResult * async_result = |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
|
void |
|
ProviderManagerService::handleCimResponse(CIMRequestMessage &request, |
|
CIMResponseMessage &response) |
|
{ |
|
CIMStatusCode code = CIM_ERR_SUCCESS; |
|
String message; |
|
|
|
try |
|
{ |
|
// only incomplete messages are processed because the caller ends up |
|
// sending the complete() stage |
|
PEGASUS_ASSERT(response.isComplete() == false); |
|
|
|
AsyncLegacyOperationStart *requestAsync = |
|
dynamic_cast<AsyncLegacyOperationStart *>(request._async); |
|
PEGASUS_ASSERT(requestAsync); |
|
AsyncOpNode *op = requestAsync->op; |
|
PEGASUS_ASSERT(op); |
|
PEGASUS_ASSERT(! response._async); |
|
response._async = new AsyncLegacyOperationResult |
|
(requestAsync->getKey(), requestAsync->getRouting(), op, &response); |
|
|
|
// set the destination |
|
op->_op_dest = op->_callback_response_q; |
|
|
|
MessageQueueService *service = |
|
dynamic_cast<MessageQueueService *>(op->_callback_response_q); |
|
|
|
PEGASUS_ASSERT(service); |
|
|
|
// the last chunk MUST be sent last, so use execute the callback |
|
// not all chunks are going through the dispatcher's chunk |
|
// resequencer, so this must be a synchronous call here |
|
// After the call is done, response and asyncResponse are now invalid |
|
// as they have been sent and deleted externally |
|
|
|
op->_async_callback(op, service, op->_callback_ptr); |
|
} |
|
|
|
catch(CIMException &e) |
|
{ |
|
code = e.getCode(); |
|
message = e.getMessage(); |
|
} |
|
catch(Exception &e) |
|
{ |
|
code = CIM_ERR_FAILED; |
|
message = e.getMessage(); |
|
} |
|
catch(...) |
|
{ |
|
code = CIM_ERR_FAILED; |
|
message = cimStatusCodeToString(code); |
|
} |
|
|
|
if (code != CIM_ERR_SUCCESS) |
|
response.cimException = PEGASUS_CIM_EXCEPTION(code, message); |
|
} |
|
|
|
Message* ProviderManagerService::_processMessage(CIMRequestMessage* request) |
|
{ |
|
Message* response = 0; |
|
|
|
if ((request->getType() == CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE) || |
|
(request->getType() == |
|
CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE) || |
|
(request->getType() == CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE)) |
|
{ |
|
if (_basicProviderManagerRouter) |
|
{ |
|
response = _basicProviderManagerRouter->processMessage(request); |
|
} |
|
|
|
if (_oopProviderManagerRouter) |
|
{ |
|
// Note: These responses do not contain interesting data, so just |
|
// use the last one. |
|
if (response) |
|
{ |
|
delete response; |
|
} |
|
|
|
response = _oopProviderManagerRouter->processMessage(request); |
|
} |
|
} |
|
else |
|
{ |
|
CIMInstance providerModule; |
|
|
|
if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
|
{ |
|
CIMEnableModuleRequestMessage* emReq = |
|
dynamic_cast<CIMEnableModuleRequestMessage*>(request); |
|
providerModule = emReq->providerModule; |
|
} |
|
else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE) |
|
{ |
|
CIMDisableModuleRequestMessage* dmReq = |
|
dynamic_cast<CIMDisableModuleRequestMessage*>(request); |
|
providerModule = dmReq->providerModule; |
|
} |
|
else |
|
{ |
|
ProviderIdContainer pidc = |
|
request->operationContext.get(ProviderIdContainer::NAME); |
|
providerModule = pidc.getModule(); |
|
} |
|
|
|
Uint16 userContext = 0; |
|
Uint32 pos = providerModule.findProperty( |
|
PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT); |
|
if (pos != PEG_NOT_FOUND) |
|
{ |
|
providerModule.getProperty(pos).getValue().get(userContext); |
|
} |
|
|
|
// Forward the request to the appropriate ProviderManagerRouter, based |
|
// on the CIM Server configuration and the UserContext setting. |
|
|
|
ConfigManager* configManager = ConfigManager::getInstance(); |
|
Boolean forceProviderProcesses = String::equal( |
|
configManager->getCurrentValue("forceProviderProcesses"), "true"); |
|
|
|
if (forceProviderProcesses |
|
#ifndef PEGASUS_DISABLE_PROV_USERCTXT |
|
|| (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR) |
|
|| (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED) |
|
|| ((userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) && |
|
!System::isPrivilegedUser(System::getEffectiveUserName())) |
|
#endif |
|
) |
|
{ |
|
response = _oopProviderManagerRouter->processMessage(request); |
|
} |
|
else |
|
{ |
|
response = _basicProviderManagerRouter->processMessage(request); |
|
} |
|
} |
|
|
|
return response; |
|
} |
|
|
void ProviderManagerService::unloadIdleProviders() | void ProviderManagerService::unloadIdleProviders() |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, | PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
|
ProviderManagerService* myself = | ProviderManagerService* myself = |
reinterpret_cast<ProviderManagerService*>(arg); | reinterpret_cast<ProviderManagerService*>(arg); |
| |
|
if (myself->_basicProviderManagerRouter) |
|
{ |
try | try |
{ | { |
myself->_providerManagerRouter->unloadIdleProviders(); |
myself->_basicProviderManagerRouter->unloadIdleProviders(); |
} | } |
catch (...) | catch (...) |
{ | { |
// Ignore errors | // Ignore errors |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, | PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
"Unexpected exception in _unloadIdleProvidersHandler"); |
"Unexpected exception from " |
|
"BasicProviderManagerRouter::_unloadIdleProviders"); |
|
} |
|
} |
|
|
|
if (myself->_oopProviderManagerRouter) |
|
{ |
|
try |
|
{ |
|
myself->_oopProviderManagerRouter->unloadIdleProviders(); |
|
} |
|
catch (...) |
|
{ |
|
// Ignore errors |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Unexpected exception from " |
|
"OOPProviderManagerRouter::_unloadIdleProviders"); |
|
} |
} | } |
| |
myself->_unloadIdleProvidersBusy--; | myself->_unloadIdleProvidersBusy--; |