version 1.2, 2003/08/18 04:39:22
|
version 1.62, 2005/01/26 23:09:09
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2004//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000 - 2003 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// 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.; |
|
// 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. |
// | // |
// 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 |
|
|
// Mike Day, IBM (mdday@us.ibm.com) | // Mike Day, IBM (mdday@us.ibm.com) |
// Karl Schopmeyer(k.schopmeyer@opengroup.org) - Fix associators. | // Karl Schopmeyer(k.schopmeyer@opengroup.org) - Fix associators. |
// Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) | // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com) |
|
// Adrian Schuur, IBM (schuur@de.ibm.com) |
|
// Amit K Arora (amita@in.ibm.com) for PEP-101 |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Seema Gupta (gseema@in.ibm.com for PEP135) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.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/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
|
#include <Pegasus/Common/AutoPtr.h> |
|
#include <Pegasus/Common/Constants.h> |
|
|
|
#include <Pegasus/Config/ConfigManager.h> |
| |
#include <Pegasus/Common/Destroyer.h> |
#include <Pegasus/ProviderManager2/BasicProviderManagerRouter.h> |
|
#include <Pegasus/ProviderManager2/OOPProviderManagerRouter.h> |
|
#include <Pegasus/ProviderManager2/OperationResponseHandler.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
ProviderManagerService::ProviderManagerService(void) |
inline Boolean _isSupportedRequestType(const Message * message) |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
|
{ | { |
|
// ATTN: needs implementation |
|
|
|
// for now, assume all requests are valid |
|
|
|
return(true); |
} | } |
| |
ProviderManagerService::ProviderManagerService(ProviderRegistrationManager * providerRegistrationManager) |
inline Boolean _isSupportedResponseType(const Message * message) |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
|
{ |
|
try |
|
{ | { |
ProviderManagerModule module("DefaultProviderManager"); |
// ATTN: needs implementation |
| |
// ATTN: ensure module loaded |
// for now, assume all responses are invalid |
module.load(); |
|
| |
// ATTN: ensure entry point returned valid response |
return(false); |
ProviderManager * manager = module.getProviderManager("Default"); |
} |
| |
// ATTN: only set the hacked/cached provider registration manager pointer after the module |
ProviderManagerService* ProviderManagerService::providerManagerService=NULL; |
// has loaded. |
Uint32 ProviderManagerService::_indicationServiceQueueId = PEG_NOT_FOUND; |
manager->setProviderRegistrationManager(providerRegistrationManager); |
|
| |
_providerManagers.append(Pair<ProviderManager *, ProviderManagerModule>(manager, module)); |
ProviderManagerService::ProviderManagerService(void) |
} |
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
catch(...) |
|
{ | { |
|
providerManagerService=this; |
} | } |
| |
try |
ProviderManagerService::ProviderManagerService( |
|
ProviderRegistrationManager * providerRegistrationManager, |
|
CIMRepository * repository) |
|
: MessageQueueService(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP) |
{ | { |
ProviderManagerModule module("CMPIProviderManager"); |
providerManagerService=this; |
|
_repository=repository; |
|
|
|
_providerRegistrationManager = providerRegistrationManager; |
|
|
|
_unloadIdleProvidersBusy = 0; |
| |
// ATTN: ensure module loaded |
_basicProviderManagerRouter = 0; |
module.load(); |
_oopProviderManagerRouter = 0; |
| |
// ATTN: ensure entry point returned valid response |
// Determine which ProviderManagerRouter(s) to use |
ProviderManager * manager = module.getProviderManager("CMPI"); |
|
| |
// ATTN: only set the hacked/cached provider registration manager pointer after the module |
ConfigManager* configManager = ConfigManager::getInstance(); |
// has loaded. |
Boolean forceProviderProcesses = String::equal( |
// manager->setProviderRegistrationManager(providerRegistrationManager); |
configManager->getCurrentValue("forceProviderProcesses"), "true"); |
| |
_providerManagers.append(Pair<ProviderManager *, ProviderManagerModule>(manager, module)); |
#ifdef PEGASUS_DISABLE_PROV_USERCTXT |
|
if (forceProviderProcesses) |
|
{ |
|
_oopProviderManagerRouter = |
|
new OOPProviderManagerRouter(indicationCallback); |
} | } |
catch(...) |
else |
|
{ |
|
_basicProviderManagerRouter = |
|
new BasicProviderManagerRouter(indicationCallback); |
|
} |
|
#else |
|
_oopProviderManagerRouter = |
|
new OOPProviderManagerRouter(indicationCallback); |
|
|
|
if (!forceProviderProcesses) |
{ | { |
|
_basicProviderManagerRouter = |
|
new BasicProviderManagerRouter(indicationCallback); |
} | } |
|
#endif |
} | } |
| |
ProviderManagerService::~ProviderManagerService(void) | ProviderManagerService::~ProviderManagerService(void) |
{ | { |
|
delete _basicProviderManagerRouter; |
|
delete _oopProviderManagerRouter; |
|
providerManagerService=NULL; |
} | } |
| |
Boolean ProviderManagerService::messageOK(const Message * message) | Boolean ProviderManagerService::messageOK(const Message * message) |
{ | { |
PEGASUS_ASSERT(message != 0); | PEGASUS_ASSERT(message != 0); |
| |
/* |
if(_isSupportedRequestType(message)) |
Boolean rc = false; |
|
|
|
switch(message->getType()) |
|
{ | { |
case CIM_GET_INSTANCE_REQUEST_MESSAGE: |
return(MessageQueueService::messageOK(message)); |
case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE: |
|
case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_GET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_SET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_INVOKE_METHOD_REQUEST_MESSAGE: |
|
case CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE: |
|
rc = true; |
|
|
|
break; |
|
default: |
|
rc = false; |
|
|
|
break; |
|
} | } |
| |
return(rc); |
return(false); |
*/ |
|
|
|
return(MessageQueueService::messageOK(message)); |
|
} | } |
| |
void ProviderManagerService::handleEnqueue(void) | void ProviderManagerService::handleEnqueue(void) |
|
|
{ | { |
PEGASUS_ASSERT(message != 0); | PEGASUS_ASSERT(message != 0); |
| |
//*FIXME* Markus |
|
// catch response messages that should never appear here |
|
|
|
// if (message->getType() == CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE) |
|
// abort(); // handle double provider callback ! |
|
|
|
AsyncLegacyOperationStart * asyncRequest; | AsyncLegacyOperationStart * asyncRequest; |
| |
if(message->_async != NULL) | if(message->_async != NULL) |
|
|
| |
_incomingQueue.enqueue(request->op); | _incomingQueue.enqueue(request->op); |
| |
_thread_pool->allocate_and_awaken((void *)this, ProviderManagerService::handleCimOperation); |
while (!_thread_pool->allocate_and_awaken( |
|
(void *)this, ProviderManagerService::handleCimOperation)) |
|
{ |
|
pegasus_yield(); |
|
} |
} | } |
else | else |
{ | { |
|
|
return; | return; |
} | } |
| |
/* |
// Note: This method should not throw an exception. It is used as a thread |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ProviderManagerService::handleServiceOperation(void * arg) throw() |
// entry point, and any exceptions thrown are ignored. |
{ |
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
// get the service from argument |
ProviderManagerService::handleCimOperation(void * arg) |
ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg); |
|
|
|
PEGASUS_ASSERT(service != 0); |
|
|
|
// get message from service queue |
|
Message * message = service->_incomingQueue.dequeue(); |
|
|
|
PEGASUS_ASSERT(message != 0); |
|
|
|
if(service->_incomingQueue.size() == 0) |
|
{ | { |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
"ProviderManagerService::handleCimOperation() called with no op node in queue" ); |
"ProviderManagerService::handleCimOperation"); |
|
|
PEG_METHOD_EXIT(); |
|
|
|
// thread started with no message in queue. |
|
return(PEGASUS_THREAD_RETURN(1)); |
|
} |
|
|
|
AsyncOpNode * op = service->_incomingQueue.dequeue(); |
|
|
|
PEGASUS_ASSERT(op != 0 ); |
|
| |
if(op->_request.count() == 0) |
if(arg == 0) |
{ | { |
MessageQueue * queue = MessageQueue::lookup(op->_source_queue); |
// thread started with invalid argument. |
|
|
PEGASUS_ASSERT(queue != 0); |
|
|
|
PEG_METHOD_EXIT(); |
|
|
|
// no request in op node |
|
return(PEGASUS_THREAD_RETURN(1)); | return(PEGASUS_THREAD_RETURN(1)); |
} | } |
| |
return(0); |
|
} |
|
*/ |
|
|
|
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL ProviderManagerService::handleCimOperation(void * arg) throw() |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimOperation"); |
|
|
|
// get the service from argument | // get the service from argument |
ProviderManagerService * service = reinterpret_cast<ProviderManagerService *>(arg); |
ProviderManagerService * service = |
|
reinterpret_cast<ProviderManagerService *>(arg); |
PEGASUS_ASSERT(service != 0); |
|
| |
if(service->_incomingQueue.size() == 0) | if(service->_incomingQueue.size() == 0) |
{ | { |
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, | PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL4, |
"ProviderManagerService::handleCimOperation() called with no op node in queue" ); |
"ProviderManagerService::handleCimOperation() called with no " |
|
"op node in queue"); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
| |
|
|
| |
AsyncOpNode * op = service->_incomingQueue.dequeue(); | AsyncOpNode * op = service->_incomingQueue.dequeue(); |
| |
PEGASUS_ASSERT(op != 0 ); |
if((op == 0) || (op->_request.count() == 0)) |
|
|
if(op->_request.count() == 0) |
|
{ | { |
|
// ATTN: This may dereference a null pointer! |
MessageQueue * queue = MessageQueue::lookup(op->_source_queue); | MessageQueue * queue = MessageQueue::lookup(op->_source_queue); |
| |
PEGASUS_ASSERT(queue != 0); | PEGASUS_ASSERT(queue != 0); |
|
|
| |
AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0)); | AsyncRequest * request = static_cast<AsyncRequest *>(op->_request.next(0)); |
| |
PEGASUS_ASSERT(request != 0); |
if ((request == 0) || |
|
(request->getType() != async_messages::ASYNC_LEGACY_OP_START)) |
if(request->getType() != async_messages::ASYNC_LEGACY_OP_START) |
|
{ | { |
// reply with NAK | // reply with NAK |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
return(PEGASUS_THREAD_RETURN(0)); | return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
Message * legacy = static_cast<AsyncLegacyOperationStart *>(request)->get_action(); |
try |
|
{ |
|
Message* legacy = |
|
static_cast<AsyncLegacyOperationStart *>(request)->get_action(); |
| |
if(legacy != 0) |
if(_isSupportedRequestType(legacy)) |
{ | { |
Destroyer<Message> xmessage(legacy); |
AutoPtr<Message> xmessage(legacy); |
| |
// Set the client's requested language into this service thread. | // Set the client's requested language into this service thread. |
// This will allow functions in this service to return messages | // This will allow functions in this service to return messages |
|
|
| |
if(msg != 0) | if(msg != 0) |
{ | { |
AcceptLanguages * langs = new AcceptLanguages(msg->acceptLanguages); |
AcceptLanguages* langs = |
|
new AcceptLanguages(((AcceptLanguageListContainer)msg->operationContext.get |
|
(AcceptLanguageListContainer::NAME)).getLanguages()); |
Thread::setLanguages(langs); | Thread::setLanguages(langs); |
} | } |
else | else |
|
|
Thread::clearLanguages(); | Thread::clearLanguages(); |
} | } |
| |
// only pass valid message types to provider managers |
|
switch(legacy->getType()) |
|
{ |
|
case CIM_GET_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE: |
|
case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE: |
|
case CIM_CREATE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_DELETE_INSTANCE_REQUEST_MESSAGE: |
|
case CIM_EXEC_QUERY_REQUEST_MESSAGE: |
|
case CIM_ASSOCIATORS_REQUEST_MESSAGE: |
|
case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE: |
|
case CIM_REFERENCES_REQUEST_MESSAGE: |
|
case CIM_REFERENCE_NAMES_REQUEST_MESSAGE: |
|
case CIM_GET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_SET_PROPERTY_REQUEST_MESSAGE: |
|
case CIM_INVOKE_METHOD_REQUEST_MESSAGE: |
|
case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE: |
|
case CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE: |
|
case CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE: |
|
case CIM_DISABLE_MODULE_REQUEST_MESSAGE: |
|
case CIM_ENABLE_MODULE_REQUEST_MESSAGE: |
|
case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE: |
|
case CIM_CONSUME_INDICATION_REQUEST_MESSAGE: |
|
service->handleCimRequest(op, legacy); | service->handleCimRequest(op, legacy); |
break; |
|
|
|
default: |
|
// unsupported messages are ignored |
|
break; |
|
} | } |
} | } |
|
catch(...) |
|
{ |
|
// ATTN: log error |
|
} |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
| |
return(PEGASUS_THREAD_RETURN(0)); | return(PEGASUS_THREAD_RETURN(0)); |
} | } |
| |
void ProviderManagerService::handleCimRequest(AsyncOpNode * op, const Message * message) throw() |
void ProviderManagerService::handleCimRequest( |
|
AsyncOpNode * op, |
|
Message * message) |
{ | { |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, "ProviderManagerService::handleCimRequest"); |
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::handleCimRequest"); |
| |
// ATTN: ensure message is a request??? |
CIMRequestMessage * request = dynamic_cast<CIMRequestMessage *>(message); |
CIMMessage * request = dynamic_cast<CIMMessage *>(const_cast<Message *>(message)); |
PEGASUS_ASSERT(request != 0); |
| |
// get request from op node | // get request from op node |
AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0)); | AsyncRequest * async = static_cast<AsyncRequest *>(op->_request.next(0)); |
|
PEGASUS_ASSERT(async != 0); |
PEGASUS_ASSERT((request != 0) && (async != 0)); |
|
| |
Message * response = 0; | Message * response = 0; |
|
Boolean consumerLookupFailed = false; |
|
|
|
if (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) |
|
{ |
|
// |
|
// Get a ProviderIdContainer for ExportIndicationRequestMessage. |
|
// Note: This can be removed when the CIMExportRequestDispatcher |
|
// is updated to add the ProviderIdContainer to the message. |
|
// |
|
CIMInstance providerModule; |
|
CIMInstance provider; |
|
const CIMExportIndicationRequestMessage* expRequest = |
|
dynamic_cast<const CIMExportIndicationRequestMessage*>(request); |
|
if (_providerRegistrationManager->lookupIndicationConsumer( |
|
expRequest->destinationPath, provider, providerModule)) |
|
{ |
|
request->operationContext.insert( |
|
ProviderIdContainer(providerModule, provider)); |
|
} |
|
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 |
|
// by the CIMOperationRequestDispatcher for all CIM operation |
|
// requests to providers, so it does not need to be added again. |
|
// CIMInitializeProviderRequestMessage also has a provider ID |
|
// container. |
|
ProviderIdContainer pidc = |
|
request->operationContext.get(ProviderIdContainer::NAME); |
|
providerModule = pidc.getModule(); |
|
|
|
// |
|
// Check if the target provider is disabled |
|
// |
|
Boolean moduleDisabled = false; |
|
Uint32 pos = providerModule.findProperty(CIMName("OperationalStatus")); |
|
PEGASUS_ASSERT(pos != PEG_NOT_FOUND); |
|
Array<Uint16> operationalStatus; |
|
providerModule.getProperty(pos).getValue().get(operationalStatus); |
|
|
|
for(Uint32 i = 0; i < operationalStatus.size(); i++) |
|
{ |
|
if ((operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) || |
|
(operationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)) |
|
{ |
|
moduleDisabled = true; |
|
break; |
|
} |
|
} |
|
|
|
if (moduleDisabled) |
|
{ |
|
// |
|
// Send a "provider blocked" response |
|
// |
|
CIMResponseMessage* cimResponse = request->buildResponse(); |
|
cimResponse->cimException = PEGASUS_CIM_EXCEPTION_L( |
|
CIM_ERR_ACCESS_DENIED, |
|
MessageLoaderParms( |
|
"ProviderManager.ProviderManagerService.PROVIDER_BLOCKED", |
|
"provider blocked.")); |
|
response = cimResponse; |
|
} |
|
else |
|
{ |
|
// |
|
// Forward the request to the appropriate ProviderManagerRouter |
|
// |
|
response = _processMessage(request); |
|
} |
|
} |
|
else if (request->getType() == CIM_ENABLE_MODULE_REQUEST_MESSAGE) |
|
{ |
|
// Handle CIMEnableModuleRequestMessage |
|
CIMEnableModuleRequestMessage * emReq = |
|
dynamic_cast<CIMEnableModuleRequestMessage*>(request); |
| |
// find provider manager |
CIMInstance providerModule = emReq->providerModule; |
// ATTN: implement efficient lookup |
|
ProviderManager * manager = _providerManagers[0].first; |
|
| |
try | try |
{ | { |
// forward request |
// Forward the request to the ProviderManager |
response = manager->processMessage(request); |
response = _processMessage(request); |
|
|
|
// If successful, update provider module status to OK |
|
// ATTN: Use CIMEnableModuleResponseMessage operationalStatus? |
|
CIMEnableModuleResponseMessage * emResp = |
|
dynamic_cast<CIMEnableModuleResponseMessage*>(response); |
|
if (emResp->cimException.getCode() == CIM_ERR_SUCCESS) |
|
{ |
|
_updateProviderModuleStatus( |
|
providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPED, |
|
CIM_MSE_OPSTATUS_VALUE_OK); |
} | } |
catch(...) |
} |
|
catch (Exception& e) |
|
{ |
|
// Get the OperationalStatus property from the provider module |
|
Array<Uint16> operationalStatus; |
|
CIMValue itValue = emReq->providerModule.getProperty( |
|
emReq->providerModule.findProperty("OperationalStatus")) |
|
.getValue(); |
|
itValue.get(operationalStatus); |
|
|
|
if (response != 0) |
|
{ |
|
delete response; |
|
} |
|
|
|
response = new CIMEnableModuleResponseMessage( |
|
request->messageId, |
|
CIMException(CIM_ERR_FAILED, e.getMessage()), |
|
request->queueIds.copyAndPop(), |
|
operationalStatus); |
|
} |
|
} |
|
else if (request->getType() == CIM_DISABLE_MODULE_REQUEST_MESSAGE) |
|
{ |
|
// Handle CIMDisableModuleRequestMessage |
|
CIMDisableModuleRequestMessage * dmReq = |
|
dynamic_cast<CIMDisableModuleRequestMessage*>(request); |
|
|
|
CIMInstance providerModule = dmReq->providerModule; |
|
Boolean updateModuleStatus = !dmReq->disableProviderOnly; |
|
|
|
try |
|
{ |
|
// Change module status from OK to STOPPING |
|
if (updateModuleStatus) |
{ | { |
// ATTN: create response with error message |
_updateProviderModuleStatus( |
|
providerModule, CIM_MSE_OPSTATUS_VALUE_OK, |
|
CIM_MSE_OPSTATUS_VALUE_STOPPING); |
} | } |
| |
// preserve message key |
// Forward the request to the ProviderManager |
response->setKey(request->getKey()); |
response = _processMessage(request); |
| |
// set HTTP method in response from request |
// Update provider module status based on success or failure |
response->setHttpMethod(request->getHttpMethod()); |
if (updateModuleStatus) |
|
{ |
|
CIMDisableModuleResponseMessage * dmResp = |
|
dynamic_cast<CIMDisableModuleResponseMessage*>(response); |
|
if (dmResp->cimException.getCode() != CIM_ERR_SUCCESS) |
|
{ |
|
// Disable operation failed. Module not stopped. |
|
_updateProviderModuleStatus( |
|
providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING, |
|
CIM_MSE_OPSTATUS_VALUE_OK); |
|
} |
|
else |
|
{ |
|
// Disable may or may not have been successful, |
|
// depending on whether there are outstanding requests. |
|
// Use last operationalStatus entry. |
|
_updateProviderModuleStatus( |
|
providerModule, CIM_MSE_OPSTATUS_VALUE_STOPPING, |
|
dmResp->operationalStatus[ |
|
dmResp->operationalStatus.size()-1]); |
|
} |
|
} |
|
} |
|
catch (Exception& e) |
|
{ |
|
// Get the OperationalStatus property from the provider module |
|
Array<Uint16> operationalStatus; |
|
CIMValue itValue = dmReq->providerModule.getProperty( |
|
dmReq->providerModule.findProperty("OperationalStatus")) |
|
.getValue(); |
|
itValue.get(operationalStatus); |
|
|
|
if (response != 0) |
|
{ |
|
delete response; |
|
} |
|
|
|
response = new CIMDisableModuleResponseMessage( |
|
request->messageId, |
|
CIMException(CIM_ERR_FAILED, e.getMessage()), |
|
request->queueIds.copyAndPop(), |
|
operationalStatus); |
|
} |
|
} |
|
else |
|
{ |
|
response = _processMessage(request); |
|
} |
| |
AsyncLegacyOperationResult * async_result = | AsyncLegacyOperationResult * async_result = |
new AsyncLegacyOperationResult( | new AsyncLegacyOperationResult( |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
void ProviderManagerService::unload_idle_providers(void) |
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_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() |
{ | { |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::unloadIdleProviders"); |
|
|
|
// Ensure that only one _unloadIdleProvidersHandler thread runs at a time |
|
_unloadIdleProvidersBusy++; |
|
if ((_unloadIdleProvidersBusy.value() == 1) && |
|
(_thread_pool->allocate_and_awaken( |
|
(void*)this, ProviderManagerService::_unloadIdleProvidersHandler))) |
|
{ |
|
// _unloadIdleProvidersBusy is decremented in |
|
// _unloadIdleProvidersHandler |
|
} |
|
else |
|
{ |
|
// If we fail to allocate a thread, don't retry now. |
|
_unloadIdleProvidersBusy--; |
|
} |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL |
|
ProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw() |
|
{ |
|
try |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::unloadIdleProvidersHandler"); |
|
|
|
ProviderManagerService* myself = |
|
reinterpret_cast<ProviderManagerService*>(arg); |
|
|
|
if (myself->_basicProviderManagerRouter) |
|
{ |
|
try |
|
{ |
|
myself->_basicProviderManagerRouter->unloadIdleProviders(); |
|
} |
|
catch (...) |
|
{ |
|
// Ignore errors |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"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--; |
|
PEG_METHOD_EXIT(); |
|
} |
|
catch (...) |
|
{ |
|
// Ignore errors |
|
PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2, |
|
"Unexpected exception in _unloadIdleProvidersHandler"); |
|
} |
|
|
|
return(PEGASUS_THREAD_RETURN(0)); |
|
} |
|
|
|
// Updates the providerModule instance and the ProviderRegistrationManager |
|
void ProviderManagerService::_updateProviderModuleStatus( |
|
CIMInstance& providerModule, |
|
Uint16 fromStatus, |
|
Uint16 toStatus) |
|
{ |
|
PEG_METHOD_ENTER(TRC_PROVIDERMANAGER, |
|
"ProviderManagerService::_updateProviderModuleStatus"); |
|
|
|
Array<Uint16> operationalStatus; |
|
String providerModuleName; |
|
|
|
Uint32 pos = providerModule.findProperty(CIMName("Name")); |
|
PEGASUS_ASSERT(pos != PEG_NOT_FOUND); |
|
providerModule.getProperty(pos).getValue().get(providerModuleName); |
|
|
|
// |
|
// get operational status |
|
// |
|
pos = providerModule.findProperty(CIMName("OperationalStatus")); |
|
PEGASUS_ASSERT(pos != PEG_NOT_FOUND); |
|
CIMProperty operationalStatusProperty = providerModule.getProperty(pos); |
|
CIMValue operationalStatusValue = operationalStatusProperty.getValue(); |
|
|
|
if (!operationalStatusValue.isNull()) |
|
{ |
|
operationalStatusValue.get(operationalStatus); |
|
} |
|
|
|
// |
|
// update module status |
|
// |
|
for (Uint32 i = operationalStatus.size(); i > 0; i--) |
|
{ |
|
if (operationalStatus[i-1] == fromStatus) |
|
{ |
|
operationalStatus.remove(i-1); |
|
} |
|
} |
|
|
|
operationalStatus.append(toStatus); |
|
|
|
if (_providerRegistrationManager->setProviderModuleStatus( |
|
providerModuleName, operationalStatus) == false) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION_L( |
|
CIM_ERR_FAILED, |
|
MessageLoaderParms( |
|
"ProviderManager.ProviderManagerService." |
|
"SET_MODULE_STATUS_FAILED", |
|
"set module status failed.")); |
|
} |
|
|
|
operationalStatusProperty.setValue(CIMValue(operationalStatus)); |
|
|
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
void ProviderManagerService::indicationCallback( |
|
CIMProcessIndicationRequestMessage* request) |
|
{ |
|
try |
|
{ |
|
AcceptLanguageListContainer cntr = request->operationContext.get(AcceptLanguageListContainer::NAME); |
|
}catch(const Exception &) |
|
{ |
|
request->operationContext.insert(AcceptLanguageListContainer(AcceptLanguages::EMPTY)); |
|
} |
|
|
|
if (_indicationServiceQueueId == PEG_NOT_FOUND) |
|
{ |
|
Array<Uint32> serviceIds; |
|
|
|
providerManagerService->find_services( |
|
PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds); |
|
PEGASUS_ASSERT(serviceIds.size() != 0); |
|
|
|
_indicationServiceQueueId = serviceIds[0]; |
|
} |
|
|
|
request->queueIds = QueueIdStack( |
|
_indicationServiceQueueId, providerManagerService->getQueueId()); |
|
|
|
AsyncLegacyOperationStart * asyncRequest = |
|
new AsyncLegacyOperationStart( |
|
providerManagerService->get_next_xid(), |
|
0, |
|
_indicationServiceQueueId, |
|
request, |
|
_indicationServiceQueueId); |
|
|
|
providerManagerService->SendForget(asyncRequest); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |