📄 providerregistrationprovider.cpp
字号:
MessageQueueService * _service = _getProviderManagerService(); if (_service != NULL) { // create CIMDisableModuleRequestMessage CIMDisableModuleRequestMessage * disable_req = new CIMDisableModuleRequestMessage( XmlWriter::getNextMessageId (), mInstance, instances, disableProviderOnly, indicationProviders, QueueIdStack(_service->getQueueId()));// l10n disable_req->operationContext.set(AcceptLanguageListContainer(al));; Array<Uint16> _opStatus = _sendDisableMessageToProviderManager(disable_req); if (!disableProviderOnly) // disable provider module { for (Uint32 i = 0; i<_opStatus.size(); i++) { // module was disabled successfully if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED) { if (indProvider) { // send termination message to subscription service _sendTerminationMessageToSubscription(objectReference, moduleName, false, al); } return (0); } // module is not disabled since there are pending // requests for the providers in the module if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK) { return (-2); } } } else // disable provider { if (indProvider) { _sendTerminationMessageToSubscription(objectReference, moduleName, true, al); } return (0); } } // disable failed return (-1);}// enable provider module // return 0 if module is enabled successfully,// return 1 if module is already enabled,// return 2 if module can not be enabled since module is stopping,// otherwise, return -1 Sint16 ProviderRegistrationProvider::_enableModule( const CIMObjectPath & moduleRef, const String & moduleName, const AcceptLanguageList & al){ // // get module status // Array<Uint16> _OperationalStatus = _providerRegistrationManager->getProviderModuleStatus( moduleName); for (Uint32 i = 0; i<_OperationalStatus.size(); i++) { // retValue equals 1 if module is already enabled if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK) { return (1); } // retValue equals 2 if module is stopping // at this stage, module can not be started if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING) { return (2); } } // get module instance CIMInstance mInstance = _providerRegistrationManager->getInstance(moduleRef); // // get provider manager service // MessageQueueService * _service = _getProviderManagerService(); Boolean enabled = false; if (_service != NULL) { // create CIMEnableModuleRequestMessage CIMEnableModuleRequestMessage * enable_req = new CIMEnableModuleRequestMessage( XmlWriter::getNextMessageId (), mInstance, QueueIdStack(_service->getQueueId()));// l10n enable_req->operationContext.set(AcceptLanguageListContainer(al));; Array<Uint16> _opStatus; _opStatus = _sendEnableMessageToProviderManager(enable_req); for (Uint32 i = 0; i<_opStatus.size(); i++) { // module is enabled successfully if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK) { enabled = true; } } } if (enabled) { // // Since module is enabled, need get updated module instance // CIMInstance updatedModuleInstance = _providerRegistrationManager->getInstance(moduleRef); // module is enabled, initialize providers as necessary _providerRegistrationManager->initializeProviders( updatedModuleInstance); // // The module is enabled, need to send enable message to // subscription service if the provider is an indication provider // CIMObjectPath providerRef = CIMObjectPath(String::EMPTY, moduleRef.getNameSpace(), PEGASUS_CLASSNAME_PROVIDER, Array<CIMKeyBinding>()); // // get all provider instances which have same module name as // moduleName // Array<CIMObjectPath> instanceNames = _providerRegistrationManager->enumerateInstanceNamesForClass( providerRef); CIMInstance pInstance; String _moduleName; String _providerName; Array<CIMInstance> capInstances; for(Uint32 i = 0, n=instanceNames.size(); i < n; i++) { Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings(); for(Uint32 j=0; j < keys.size(); j++) { // // get provider module name from reference // if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME)) { _moduleName = keys[j].getValue(); } // // get provider name from reference // if(keys[j].getName().equal (_PROPERTY_PROVIDER_NAME)) { _providerName = keys[j].getValue(); } } if (String::equalNoCase(_moduleName, moduleName)) { providerRef.setKeyBindings(keys); pInstance = _providerRegistrationManager->getInstance (providerRef); // // get all the indication capability instances which belongs // to this provider // capInstances = _getIndicationCapInstances( moduleName, pInstance, providerRef); // // if there are indication capability instances // if (capInstances.size() != 0) { _sendEnableMessageToSubscription(updatedModuleInstance, pInstance, capInstances, al); } } } return (0); } // enable failed return (-1);}// send enable message to indication servicevoid ProviderRegistrationProvider::_sendEnableMessageToSubscription( const CIMInstance & mInstance, const CIMInstance & pInstance, const Array<CIMInstance> & capInstances, const AcceptLanguageList & al){ // // get indication server queueId // MessageQueueService * _service = _getIndicationService(); if (_service != NULL) { Uint32 _queueId = _service->getQueueId(); CIMNotifyProviderEnableRequestMessage * enable_req = new CIMNotifyProviderEnableRequestMessage ( XmlWriter::getNextMessageId (), capInstances, QueueIdStack(_service->getQueueId())); enable_req->operationContext.set(AcceptLanguageListContainer(al)); enable_req->operationContext.insert(ProviderIdContainer(mInstance,pInstance)); // create request envelope AsyncLegacyOperationStart * asyncRequest = new AsyncLegacyOperationStart ( NULL, _queueId, enable_req, _queueId); AsyncReply * asyncReply = _controller->ClientSendWait(_queueId, asyncRequest); CIMNotifyProviderEnableResponseMessage * response = reinterpret_cast<CIMNotifyProviderEnableResponseMessage *>( (dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result()); if (response->cimException.getCode() != CIM_ERR_SUCCESS) { CIMException e = response->cimException; delete asyncRequest; delete asyncReply; delete response; throw e; } delete asyncRequest; delete asyncReply; delete response; }}// If provider is an indication provider, return true,// otherwise, return falseBoolean ProviderRegistrationProvider::_isIndicationProvider( const String & moduleName, const CIMInstance & instance){ // get provider name String providerName; Uint32 pos = instance.findProperty(_PROPERTY_PROVIDER_NAME); if (pos != PEG_NOT_FOUND) { instance.getProperty(pos).getValue().get(providerName); } return (_providerRegistrationManager->isIndicationProvider( moduleName, providerName));}//// get all the capability instances whose provider type is indication // Array<CIMInstance> ProviderRegistrationProvider::_getIndicationCapInstances( const String & moduleName, const CIMInstance & instance, const CIMObjectPath & providerRef){ // get provider name String providerName; Uint32 pos = instance.findProperty(CIMName (_PROPERTY_PROVIDER_NAME)); if (pos != PEG_NOT_FOUND) { instance.getProperty(pos).getValue().get(providerName); } CIMObjectPath capabilityRef; capabilityRef = CIMObjectPath(providerRef.getHost(), providerRef.getNameSpace(), PEGASUS_CLASSNAME_PROVIDERCAPABILITIES, providerRef.getKeyBindings()); // get all Capabilities instances Array<CIMObjectPath> instanceNames = _providerRegistrationManager->enumerateInstanceNamesForClass( capabilityRef); String _moduleName, _providerName; CIMInstance capInstance; Array<Uint16> providerTypes; Array<CIMInstance> indCapInstances = 0; for(Uint32 i = 0, n=instanceNames.size(); i < n; i++) { Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings(); for(Uint32 j=0; j < keys.size(); j++) { if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME)) { _moduleName = keys[j].getValue(); } if(keys[j].getName().equal (_PROPERTY_PROVIDERNAME)) { _providerName = keys[j].getValue(); } } // // if capability instance has same module name as moduleName // and same provider name as providerName, get provider type // if(String::equal(_moduleName, moduleName) && String::equal(_providerName, providerName)) { capInstance = _providerRegistrationManager->getInstance (instanceNames[i]); Uint32 pos = capInstance.findProperty(CIMName (_PROPERTY_PROVIDERTYPE)); if (pos != PEG_NOT_FOUND) { capInstance.getProperty(pos).getValue().get(providerTypes); for (Uint32 k=0; k < providerTypes.size(); k++) { // // if provider type of the instance is indication, // append the instance // if (providerTypes[k] == _INDICATION_PROVIDER) { indCapInstances.append(capInstance); } } } } } return (indCapInstances);}PEGASUS_NAMESPACE_END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -