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

📄 configsettingprovider.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());            }        }        try        {            //            // Update the current value, if requested            //            if (currentValueModified)            {                preValue = _configManager->getCurrentValue(configPropertyName);                if ( !_configManager->updateCurrentValue(                    configPropertyName, currentValue, currentValueIsNull) )                {                    handler.complete();                    PEG_METHOD_EXIT();                    //l10n                    //throw PEGASUS_CIM_EXCEPTION(                        //CIM_ERR_FAILED,                        //"Failed to update the current value.");                    throw PEGASUS_CIM_EXCEPTION_L(                        CIM_ERR_FAILED,                        MessageLoaderParms("ControlProviders.ConfigSettingProvider.ConfigSettingProvider.UPDATE_CURRENT_VALUE_FAILED",                        				   "Failed to update the current value."));                }				// It is unset, get current value which is default                if (currentValueIsNull)                {                    currentValue = _configManager->getCurrentValue(                        configPropertyName);                }                // send notify config change message to ProviderManager Service                _sendNotifyConfigChangeMessage(configPropertyName,                                                currentValue,                                               true);               PEG_AUDIT_LOG(logSetConfigProperty(userName, configPropertyName,                   preValue, currentValue, false));            }            //            // Update the planned value, if requested            //            if (plannedValueModified)            {                preValue = _configManager->getPlannedValue(configPropertyName);                if ( !_configManager->updatePlannedValue(                    configPropertyName, plannedValue, plannedValueIsNull) )                {		    handler.complete();                    PEG_METHOD_EXIT();                    //l10n                    //throw PEGASUS_CIM_EXCEPTION(                        //CIM_ERR_FAILED,                        //"Failed to update the planned value.");                    throw PEGASUS_CIM_EXCEPTION_L(                        CIM_ERR_FAILED,                        MessageLoaderParms("ControlProviders.ConfigSettingProvider.ConfigSettingProvider.UPDATE_PLANNED_VALUE_FAILED",                        				   "Failed to update the planned value."));                }		// It is unset, get planned value which is default                if (plannedValueIsNull)                {                    plannedValue = _configManager->getPlannedValue(                        configPropertyName);                }                // send notify config change message to ProviderManager Service                _sendNotifyConfigChangeMessage(configPropertyName,                                                plannedValue,                                               false);               PEG_AUDIT_LOG(logSetConfigProperty(userName, configPropertyName,                   preValue, plannedValue, true));            }        }        catch (const NonDynamicConfigProperty& ndcp)        {            PEG_METHOD_EXIT();            throw PEGASUS_CIM_EXCEPTION(                CIM_ERR_NOT_SUPPORTED, ndcp.getMessage());        }        catch (const InvalidPropertyValue& ipv)        {            PEG_METHOD_EXIT();            throw PEGASUS_CIM_EXCEPTION(                CIM_ERR_FAILED, ipv.getMessage());        }        catch (const UnrecognizedConfigProperty&)        {            PEG_METHOD_EXIT();            //l10n            //throw PEGASUS_CIM_EXCEPTION(                //CIM_ERR_NOT_FOUND,                //String("Configuration property \"") +                    //configPropertyName + "\"");            throw PEGASUS_CIM_EXCEPTION_L(                CIM_ERR_NOT_FOUND,                MessageLoaderParms("ControlProviders.ConfigSettingProvider.ConfigSettingProvider.CONFIG_PROPERTY_NOT_FOUND",                			       "Configuration property \"$0\"",                 			       configPropertyName));        }        handler.complete();        PEG_METHOD_EXIT();        return;    }void ConfigSettingProvider::enumerateInstances(	const OperationContext & context,	const CIMObjectPath & ref,	const Boolean includeQualifiers,	const Boolean includeClassOrigin,        const CIMPropertyList& propertyList,	InstanceResponseHandler & handler)    {        PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::enumerateInstances()");        Array<CIMInstance> instanceArray;        Array<String> propertyNames;        //        // check if the class name requested is PG_ConfigSetting        //        if (!ref.getClassName().equal (PG_CONFIG_SETTING))        {            PEG_METHOD_EXIT();            throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,                                        ref.getClassName().getString());        }	// begin processing the request	handler.processing();        try        {            _configManager->getAllPropertyNames(propertyNames, false);            for (Uint32 i = 0; i < propertyNames.size(); i++)            {                 Array<String> propertyInfo;                 CIMInstance        instance(PG_CONFIG_SETTING);                 propertyInfo.clear();                 _configManager->getPropertyInfo(                 propertyNames[i], propertyInfo);                 Array<CIMKeyBinding> keyBindings;                 keyBindings.append(CIMKeyBinding(PROPERTY_NAME,                  propertyInfo[0], CIMKeyBinding::STRING));                 CIMObjectPath instanceName(ref.getHost(),                  ref.getNameSpace(),                 PG_CONFIG_SETTING, keyBindings);                 // construct the instance                 instance.addProperty(CIMProperty(PROPERTY_NAME,                                          propertyInfo[0]));                 instance.addProperty(CIMProperty(DEFAULT_VALUE,                                          propertyInfo[1]));                 instance.addProperty(CIMProperty(CURRENT_VALUE,                                          propertyInfo[2]));                 instance.addProperty(CIMProperty(PLANNED_VALUE,                                          propertyInfo[3]));                 instance.addProperty(CIMProperty(DYNAMIC_PROPERTY,                 Boolean(propertyInfo[4]=="true"?true:false)));                 instance.setPath(instanceName);                 instanceArray.append(instance);            }        }        catch(Exception& e)        {            PEG_METHOD_EXIT();            throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());        }	handler.deliver(instanceArray);	// complete processing the request	handler.complete();        PEG_METHOD_EXIT();    }void ConfigSettingProvider::enumerateInstanceNames(	const OperationContext & context,	const CIMObjectPath & classReference,        ObjectPathResponseHandler & handler)    {        PEG_METHOD_ENTER(TRC_CONFIG,            "ConfigSettingProvider::enumerateInstanceNames()");        Array<CIMObjectPath> instanceRefs;        Array<String>       propertyNames;        Array<CIMKeyBinding>   keyBindings;        CIMKeyBinding          kb;        String              hostName;        hostName.assign(System::getHostName());	const CIMName& className = classReference.getClassName();	const CIMNamespaceName& nameSpace = classReference.getNameSpace();        if (!className.equal (PG_CONFIG_SETTING))        {            PEG_METHOD_EXIT();            throw PEGASUS_CIM_EXCEPTION( CIM_ERR_NOT_SUPPORTED,                 className.getString());        }	// begin processing the request	handler.processing();        try        {            _configManager->getAllPropertyNames(propertyNames, false);            Uint32 size = propertyNames.size();            for (Uint32 i = 0; i < size; i++)            {                 keyBindings.append(                              CIMKeyBinding(PROPERTY_NAME, propertyNames[i],                              CIMKeyBinding::STRING));                 //                 // Convert instance names to References                 //                 CIMObjectPath ref(hostName, nameSpace, className,                                     keyBindings);                 instanceRefs.append(ref);                 keyBindings.clear();            }        }        catch(Exception& e)        {            PEG_METHOD_EXIT();            throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());        }	handler.deliver(instanceRefs);	// complete processing the request	handler.complete();        PEG_METHOD_EXIT();    }//// Verify user authorization//void ConfigSettingProvider::_verifyAuthorization(const String& userName)    {        PEG_METHOD_ENTER(TRC_CONFIG,            "ConfigSettingProvider::_verifyAuthorization()");        if ( System::isPrivilegedUser(userName) == false )        {            PEG_METHOD_EXIT();            //l10n            //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,                //"Must be a privileged user to do this CIM operation.");            throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,                MessageLoaderParms("ControlProviders.ConfigSettingProvider.ConfigSettingProvider.USER_NOT_PRIVILEGED",                				   "Must be a privileged user to do this CIM operation."));        }        PEG_METHOD_EXIT();    }//// send notify config change message to provider manager service//void ConfigSettingProvider::_sendNotifyConfigChangeMessage(    const String& propertyName,    const String& newPropertyValue,    Boolean currentValueModified){    PEG_METHOD_ENTER(TRC_CONFIG,        "ConfigSettingProvider::_sendNotifyConfigChangeMessage");    ModuleController* controller = ModuleController::getModuleController();    MessageQueue * queue = MessageQueue::lookup(        PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);    MessageQueueService * service = dynamic_cast<MessageQueueService *>(queue);    if (service != NULL)    {        // create CIMNotifyConfigChangeRequestMessage        CIMNotifyConfigChangeRequestMessage * notify_req =            new CIMNotifyConfigChangeRequestMessage (            XmlWriter::getNextMessageId (),            propertyName,            newPropertyValue,            currentValueModified,            QueueIdStack(service->getQueueId()));        // create request envelope        AsyncLegacyOperationStart asyncRequest(            NULL,            service->getQueueId(),            notify_req,            service->getQueueId());        AutoPtr<AsyncReply> asyncReply(             controller->ClientSendWait(service->getQueueId(), &asyncRequest));        AutoPtr<CIMNotifyConfigChangeResponseMessage> response(            reinterpret_cast<CIMNotifyConfigChangeResponseMessage *>(            (static_cast<AsyncLegacyOperationResult *>            (asyncReply.get()))->get_result()));        if (response->cimException.getCode() != CIM_ERR_SUCCESS)        {            CIMException e = response->cimException;            throw (e);	}    }}PEGASUS_NAMESPACE_END

⌨️ 快捷键说明

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