⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 providermanagerservice.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        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_NOT_SUPPORTED,                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);        CIMInstance providerModule = emReq->providerModule;        try        {            // Forward the request to the ProviderManager            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)            {                //                //  On a successful enable, remove Stopped status and                //  append OK status                //                Array<Uint16> removeStatus;                Array<Uint16> appendStatus;                removeStatus.append (CIM_MSE_OPSTATUS_VALUE_STOPPED);                appendStatus.append (CIM_MSE_OPSTATUS_VALUE_OK);                _updateProviderModuleStatus(                    providerModule, removeStatus, appendStatus);            }        }        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);            delete response;            CIMEnableModuleResponseMessage* emResp =                dynamic_cast<CIMEnableModuleResponseMessage*>(                    request->buildResponse());            emResp->operationalStatus = operationalStatus;            emResp->cimException =                CIMException(CIM_ERR_FAILED, e.getMessage());            response = emResp;        }    }    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        {            //            //  On issuing a disable request, append Stopping status            //  Do not remove existing status            //            if (updateModuleStatus)            {                Array<Uint16> removeStatus;                Array<Uint16> appendStatus;                appendStatus.append (CIM_MSE_OPSTATUS_VALUE_STOPPING);                _updateProviderModuleStatus(                    providerModule, removeStatus, appendStatus);            }            // Forward the request to the ProviderManager            response = _processMessage(request);            // Update provider module status based on success or failure            if (updateModuleStatus)            {                CIMDisableModuleResponseMessage * dmResp =                    dynamic_cast<CIMDisableModuleResponseMessage*>(response);                if (dmResp->cimException.getCode() != CIM_ERR_SUCCESS)                {                    //                    //  On an unsuccessful disable, remove Stopping status                    //                    Array<Uint16> removeStatus;                    Array<Uint16> appendStatus;                    removeStatus.append (CIM_MSE_OPSTATUS_VALUE_STOPPING);                    _updateProviderModuleStatus(                        providerModule, removeStatus, appendStatus);                }                else                {                    // Disable may or may not have been successful,                    // depending on whether there are outstanding requests.                    // Remove Stopping status                    // Append status, if any, from disable module response                    Array<Uint16> removeStatus;                    Array<Uint16> appendStatus;                    removeStatus.append (CIM_MSE_OPSTATUS_VALUE_STOPPING);                    if (dmResp->operationalStatus.size() > 0)                    {                        //                        //  On a successful disable, remove an OK or a Degraded                        //  status, if present                        //                        if (dmResp->operationalStatus[                            dmResp->operationalStatus.size()-1] ==                            CIM_MSE_OPSTATUS_VALUE_STOPPED)                        {                            removeStatus.append (CIM_MSE_OPSTATUS_VALUE_OK);                            removeStatus.append                                (CIM_MSE_OPSTATUS_VALUE_DEGRADED);                        }                        appendStatus.append (dmResp->operationalStatus[                            dmResp->operationalStatus.size()-1]);                    }                    _updateProviderModuleStatus(                        providerModule, removeStatus, appendStatus);                }            }        }        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);            delete response;            CIMDisableModuleResponseMessage* dmResp =                dynamic_cast<CIMDisableModuleResponseMessage*>(                    request->buildResponse());            dmResp->operationalStatus = operationalStatus;            dmResp->cimException =                CIMException(CIM_ERR_FAILED, e.getMessage());            response = dmResp;        }    }    else    {        response = _processMessage(request);    }    AsyncLegacyOperationResult * async_result =        new AsyncLegacyOperationResult(        op,        response);    _complete_op_node(op, ASYNC_OPSTATE_COMPLETE, 0, 0);    PEG_METHOD_EXIT();}void ProviderManagerService::responseChunkCallback(    CIMRequestMessage* request,    CIMResponseMessage* response){    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,        "ProviderManagerService::responseChunkCallback");    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(            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 (Exception &e)    {        PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,            "Exception in ProviderManagerService::responseChunkCallback: " +                e.getMessage() + ".  Chunk not delivered.");    }    catch (...)    {        PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,            "Exception in ProviderManagerService::responseChunkCallback.  "                "Chunk not delivered.");    }    PEG_METHOD_EXIT();}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.            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();#ifdef PEGASUS_ZOS_SECURITY            if (request->getType() != CIM_EXPORT_INDICATION_REQUEST_MESSAGE)            {                // this is a z/OS only function                // the function checks user authorization                // based on CIM operation versus provider profile                // Input: request and Provider ID Container                //Return: failure: a response message for the client                //        success: NULL                response = checkSAFProviderProfile(request, pidc);                if (response != NULL)                {                    return response;                }            }#endif        }        Uint16 userContext = PEGASUS_DEFAULT_PROV_USERCTXT;        Uint32 pos = providerModule.findProperty(            PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);        if (pos != PEG_NOT_FOUND)        {            providerModule.getProperty(pos).getValue().get(userContext);        }        // Load proxy-provider into CIMServer, in case of remote namespace        // requests. (ie through _basicProviderManagerRouter). -V 3913#ifdef PEGASUS_ENABLE_REMOTE_CMPI        if ((dynamic_cast<CIMOperationRequestMessage*>(request) != 0) ||                (request->getType() == CIM_EXPORT_INDICATION_REQUEST_MESSAGE) ||                (request->getType() == CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE))        {            ProviderIdContainer pidc1 =            request->operationContext.get(ProviderIdContainer::NAME);            if (pidc1.isRemoteNameSpace() )            {                Tracer::trace ( TRC_PROVIDERMANAGER, Tracer::LEVEL4,                                "Processing Remote NameSpace request ");                response = _basicProviderManagerRouter->processMessage(request);                return response;            }        }#endif        // Forward the request to the appropriate ProviderManagerRouter, based        // on the CIM Server configuration and the UserContext setting.        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.get() != 1)    {        _unloadIdleProvidersBusy--;        PEG_METHOD_EXIT();        return;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -