void ConfigSettingProvider::_modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance& modifiedIns, const CIMPropertyList& propertyList, Uint32 timeoutSeconds) { PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::_modifyInstance()"); // // get userName // String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } // // verify user authorizations // z/OS: authorization check is done in CIMOpReqAuth already // #ifndef PEGASUS_OS_ZOS if (userName != String::EMPTY) { _verifyAuthorization(userName); } #endif // NOTE: Qualifiers are not processed by this provider, so the // IncludeQualifiers flag is ignored. // // check if the class name requested is PG_ConfigSetting // if (!instanceReference.getClassName().equal (PG_CONFIG_SETTING)) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString()); } // // validate key bindings // Array<CIMKeyBinding> kbArray = instanceReference.getKeyBindings(); if ( (kbArray.size() != 1) || (!kbArray[0].getName().equal (PROPERTY_NAME))) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "INVALID_INSTANCE_NAME", "Invalid instance name")); } String configPropertyName = kbArray[0].getValue(); // Modification of the entire instance is not supported by this provider if (propertyList.isNull()) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, //"Modification of entire instance"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "MODIFICATION_OF_ENTIRE_INSTANCE", "Modification of entire instance")); } Boolean currentValueModified = false; Boolean plannedValueModified = false; for (Uint32 i = 0; i < propertyList.size(); ++i) { CIMName propertyName = propertyList[i]; if (propertyName.equal (CURRENT_VALUE)) { currentValueModified = true; } else if (propertyName.equal (PLANNED_VALUE)) { plannedValueModified = true; } else { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "MODIFICATION_NOT_SUPPORTED", "Modification of property \"$0\"", propertyName.getString())); } } String preValue; String currentValue; String plannedValue; Boolean currentValueIsNull = false; Boolean plannedValueIsNull = false; // // Get the current value from the instance // Uint32 pos = modifiedIns.findProperty(CURRENT_VALUE); if (pos == PEG_NOT_FOUND) { currentValueIsNull = true; } else { CIMConstProperty prop = modifiedIns.getProperty(pos); try { prop.getValue().get(currentValue); } catch (Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } // // Get the planned value from the instance // pos = modifiedIns.findProperty(PLANNED_VALUE); if (pos == PEG_NOT_FOUND) { plannedValueIsNull = true; } else { CIMConstProperty prop = modifiedIns.getProperty(pos); try { prop.getValue().get(plannedValue); } catch (Exception& e) { PEG_METHOD_EXIT(); 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, userName, timeoutSeconds, currentValueIsNull)) { PEG_METHOD_EXIT(); 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 Handler Service if(String::equal(configPropertyName, "maxIndicationDeliveryRetryAttempts")|| String::equal(configPropertyName, "minIndicationDeliveryRetryInterval")) { _sendNotifyConfigChangeMessage( configPropertyName, currentValue, userName, PEGASUS_QUEUENAME_INDHANDLERMANAGER, true); } // send notify config change message to ProviderManager Service _sendNotifyConfigChangeMessage( configPropertyName, currentValue, userName, PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP, 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) ) { PEG_METHOD_EXIT(); 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); if (String::equal(configPropertyName, "maxIndicationDeliveryRetryAttempts") || String::equal(configPropertyName, "minIndicationDeliveryRetryInterval")) { _sendNotifyConfigChangeMessage( configPropertyName, plannedValue, userName, PEGASUS_QUEUENAME_INDHANDLERMANAGER, false); } } // send notify config change message to ProviderManager Service _sendNotifyConfigChangeMessage( configPropertyName, plannedValue, userName, PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP, 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(); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_NOT_FOUND, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "CONFIG_PROPERTY_NOT_FOUND", "Configuration property \"$0\"", configPropertyName)); } PEG_METHOD_EXIT(); return; }
void ZOSConsoleManager::_updateConfiguration( const String& configProperty, const String& propertyValue, Boolean currentValueIsNull, Boolean planned) { PEG_METHOD_ENTER(TRC_SERVER,"ZOSConsoleManager::_updateConfiguration"); String preValue; String currentValue; String displayValue; String defaultValue; try { ConfigManager* _configManager = ConfigManager::getInstance(); preValue = _configManager->getCurrentValue(configProperty); defaultValue = _configManager->getDefaultValue(configProperty); //If currentValueIsNull is true, the updateCurrentValue() will use the // default value, so we need the default value for the messages. if(currentValueIsNull) { displayValue = defaultValue; } else { displayValue = propertyValue; } if (!planned) { // // Update the current value // if ( !_configManager->updateCurrentValue( configProperty, propertyValue, System::getEffectiveUserName(), 0, currentValueIsNull) ) { Logger::put_l( Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Server.ConsoleManager_zOS." "CON_MODIFY_FAILED.PEGASUS_OS_ZOS", "Failed to update CONFIG value.")); } else { Logger::put_l( Logger::STANDARD_LOG, System::CIMSERVER,Logger::INFORMATION, MessageLoaderParms( "Server.ConsoleManager_zOS." "CON_MODIFY_UPDATED.PEGASUS_OS_ZOS", "Updated current value for $0 to $1", configProperty, displayValue)); } } else { // // Update the planned value // if ( !_configManager->updatePlannedValue(configProperty, propertyValue, currentValueIsNull) ) { Logger::put_l( Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Server.ConsoleManager_zOS." "CON_MODIFY_FAILED.PEGASUS_OS_ZOS", "Failed to update CONFIG value.")); } else { Logger::put_l( Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, MessageLoaderParms( "Server.ConsoleManager_zOS." "CON_MODIFY_PLANNED.PEGASUS_OS_ZOS", "Updated planned value for $0 to $1", configProperty, displayValue)); Logger::put_l( Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, MessageLoaderParms( "Server.ConsoleManager_zOS." "CON_MODIFY_PLANNED2.PEGASUS_OS_ZOS", "This change will become effective " "after CIM Server restart.")); } } // send notify config change message to ProviderManager Service _sendNotifyConfigChangeMessage(displayValue, currentValue, !planned); PEG_AUDIT_LOG(logSetConfigProperty("OPERATOR", displayValue, preValue, currentValue, planned)); } catch(const Exception& e) { Logger::put_l( Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, MessageLoaderParms( "Server.ConsoleManager_zOS.CON_MODIFY_ERR.PEGASUS_OS_ZOS", "MODIFY command failed: \"$0\"", e.getMessage())); } PEG_METHOD_EXIT(); }