/** Merge config properties specified on the command line */ void ConfigManager::mergeCommandLine(int& argc, char**& argv) { // Remove the command name from the command line if (argc > 0) { memmove(&argv[0], &argv[1], (argc) * sizeof(char*)); argc--; } // // Merge properties from the command line // for (Sint32 i = 0; i < argc; ) { const char* arg = argv[i]; if (*arg == '-') { throw UnrecognizedCommandLineOption(); } // Get the config option //const char* configOption = argv[i]; if (!_initPropertyWithCommandLineOption(arg)) { throw UnrecognizedConfigProperty(arg); } // Remove the option from the command line memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*)); argc--; } }
/** Initialize the current value of a config property */ Boolean ConfigManager::initCurrentValue( const String& propertyName, const String& propertyValue) { ConfigPropertyOwner* propertyOwner = 0; // // get property owner object from the config table. // if (!_propertyTable->ownerTable.lookup(propertyName, propertyOwner)) { throw UnrecognizedConfigProperty(propertyName); } if (useConfigFiles && !propertyOwner->isValid(propertyName, propertyValue)) { throw InvalidPropertyValue(propertyName, propertyValue); } // // update the value with the property owner // propertyOwner->initCurrentValue(propertyName, propertyValue); if (useConfigFiles) { // // update the value in the current config file // return _configFileHandler->updateCurrentValue( propertyName, propertyValue, false); } return true; }
/** Checks to see if the given value is valid or not. */ Boolean ShutdownPropertyOwner::isValid( const String& name, const String& value) const { // // convert timeout string to integer // long timeoutValue = strtol(value.getCString(), (char **)0, 10); if (String::equal(_shutdownTimeout->propertyName, name)) { // Check if the timeout value is greater than the minimum allowed // if ( timeoutValue >= MIN_SHUTDOWN_TIMEOUT ) { return true; } else { return false; } } else { throw UnrecognizedConfigProperty(name); } }
/** Update planned value of a property. */ Boolean ConfigManager::updatePlannedValue( const String& name, const String& value, Boolean unset) { String prevValue; // // get property owner object from the config table. // ConfigPropertyOwner* propertyOwner; if (!_propertyTable->ownerTable.lookup(name, propertyOwner)) { throw UnrecognizedConfigProperty(name); } // // keep a copy of the existing config value // prevValue = propertyOwner->getPlannedValue(name); // // ask owner to update the planned value to new value // if (unset) { propertyOwner->updatePlannedValue(name, propertyOwner->getDefaultValue(name)); } else { if (useConfigFiles && !propertyOwner->isValid(name, value)) { throw InvalidPropertyValue(name, value); } propertyOwner->updatePlannedValue(name, value); } if (useConfigFiles) { // // update the new value in the planned config file // if (!_configFileHandler->updatePlannedValue(name, value, unset)) { // Failed to update the planned value, so roll back. propertyOwner->updatePlannedValue(name, prevValue); return false; } } return true; }
struct ConfigProperty* ProviderDirPropertyOwner::_lookupConfigProperty( const String& name) const { if (String::equal(_providerDir->propertyName, name)) { return _providerDir; } else { throw UnrecognizedConfigProperty(name); } }
struct ConfigProperty* ShutdownPropertyOwner::_lookupConfigProperty( const String& name) const { if (String::equal(_shutdownTimeout->propertyName, name)) { return _shutdownTimeout.get(); } else { throw UnrecognizedConfigProperty(name); } }
/** Checks to see if the specified property is dynamic or not. */ Boolean DefaultPropertyOwner::isDynamic(const String& name) const { for (Uint32 i = 0; i < NUM_PROPERTIES; i++) { if (String::equal(_configProperties.get()[i].propertyName, name)) { return (_configProperties.get()[i].dynamic == IS_DYNAMIC); } } // // Specified property name could not be found // throw UnrecognizedConfigProperty(name); }
/** Get planned value of the specified property */ String DefaultPropertyOwner::getPlannedValue(const String& name) const { for (Uint32 i = 0; i < NUM_PROPERTIES; i++) { if (String::equal(_configProperties.get()[i].propertyName, name)) { return _configProperties.get()[i].plannedValue; } } // // Specified property name could not be found // throw UnrecognizedConfigProperty(name); }
/** Validate the value of a specified property. */ Boolean ConfigManager::validatePropertyValue( const String& name, const String& value) { // // get property owner object from config table // ConfigPropertyOwner* propertyOwner; if (!_propertyTable->ownerTable.lookup(name, propertyOwner)) { throw UnrecognizedConfigProperty(name); } return propertyOwner->isValid(name, value); }
/** Get all the attributes of the specified property. */ void ConfigManager::getPropertyInfo( const String& name, Array<String>& propertyInfo) const { // // get property owner object from config table // ConfigPropertyOwner* propertyOwner; if (!_propertyTable->ownerTable.lookup(name, propertyOwner)) { throw UnrecognizedConfigProperty(name); } propertyOwner->getPropertyInfo(name, propertyInfo); }
struct ConfigProperty * NormalizationPropertyOwner::_lookupConfigProperty(const String & name) const { if(String::equalNoCase(name, _providerObjectNormalizationEnabled->propertyName)) { return(_providerObjectNormalizationEnabled.get()); } else if(String::equalNoCase(name, _providerObjectNormalizationModuleExclusions->propertyName)) { return(_providerObjectNormalizationModuleExclusions.get()); } else { throw UnrecognizedConfigProperty(name); } PEGASUS_UNREACHABLE( return(0); ) }
struct ConfigProperty* NormalizationPropertyOwner::_lookupConfigProperty( const String& name) const { if (String::equal( name, _providerObjectNormalizationEnabled->propertyName)) { return _providerObjectNormalizationEnabled.get(); } else if (String::equal( name, _providerObjectNormalizationModuleExclusions->propertyName)) { return _providerObjectNormalizationModuleExclusions.get(); } else { throw UnrecognizedConfigProperty(name); } }
/** Get information about the specified property. */ void DefaultPropertyOwner::getPropertyInfo( const String& name, Array<String>& propertyInfo) const { propertyInfo.clear(); for (Uint32 i = 0; i < NUM_PROPERTIES; i++) { if (String::equal(_configProperties.get()[i].propertyName, name)) { propertyInfo.append(_configProperties.get()[i].propertyName); propertyInfo.append(_configProperties.get()[i].defaultValue); propertyInfo.append(_configProperties.get()[i].currentValue); propertyInfo.append(_configProperties.get()[i].plannedValue); if (_configProperties.get()[i].dynamic) { propertyInfo.append(STRING_TRUE); } else { propertyInfo.append(STRING_FALSE); } if (_configProperties.get()[i].externallyVisible) { propertyInfo.append(STRING_TRUE); } else { propertyInfo.append(STRING_FALSE); } propertyInfo.append(getPropertyHelp(name)); return; } } // // specified property name is not found // throw UnrecognizedConfigProperty(name); }
/** Initialize config property with the value specified in the command line. */ Boolean ConfigManager::_initPropertyWithCommandLineOption( const String& option) { Uint32 pos = option.find('='); if (pos == PEG_NOT_FOUND) { // // The property value was not specified // throw UnrecognizedConfigProperty(option); } // // Get the property name and value // String propertyName = option.subString(0, pos); String propertyValue = option.subString(pos + 1); return initCurrentValue(propertyName, propertyValue); }
/** Get current value of the specified property */ String DefaultPropertyOwner::getCurrentValue(const String& name) const { for (Uint32 i = 0; i < NUM_PROPERTIES; i++) { if (String::equal(_configProperties.get()[i].propertyName, name)) { if (String::equalNoCase(name, "hostname")) { if (0 == _configProperties.get()[i].currentValue.size()) { _configProperties.get()[i].currentValue= System::getHostName(); } } if (String::equalNoCase(name, "fullyQualifiedHostName")) { if (0 == _configProperties.get()[i].currentValue.size()) { _configProperties.get()[i].currentValue= System::getFullyQualifiedHostName(); } } if (String::equalNoCase(name, "maxProviderProcesses") || String::equalNoCase(name, "maxFailedProviderModuleRestarts")) { AutoMutex lock(_dynamicConfigPropertyMutex); return _configProperties.get()[i].currentValue; } else { return _configProperties.get()[i].currentValue; } } } // // Specified property name could not be found // throw UnrecognizedConfigProperty(name); }
struct ConfigProperty* LogPropertyOwner::_lookupConfigProperty( const String& name) const { #if !defined(PEGASUS_USE_SYSLOGS) if (String::equal(_logdir->propertyName, name)) { return _logdir.get(); } else if (String::equal(_maxLogFileSizeKBytes->propertyName, name)) { return _maxLogFileSizeKBytes.get(); } else #endif if (String::equal(_logLevel->propertyName, name)) { return _logLevel.get(); } else { throw UnrecognizedConfigProperty(name); } }
/** Get planned value of the specified property. */ String ConfigManager::getPlannedValue(const String& name) const { // // Check for a property with a fixed value // const char* fixedValue; if (_propertyTable->fixedValueTable.lookup(name, fixedValue)) { return fixedValue; } // // get property owner object from config table // ConfigPropertyOwner* propertyOwner; if (!_propertyTable->ownerTable.lookup(name, propertyOwner)) { throw UnrecognizedConfigProperty(name); } return propertyOwner->getPlannedValue(name); }
/** load config properties from the file */ void ConfigManager::_loadConfigProperties() { PEGASUS_ASSERT(useConfigFiles); // // load all the properties from the current and planned // config files in to tables. // _configFileHandler->loadAllConfigProperties(); Array<CIMName> propertyNames; Array<String> propertyValues; _configFileHandler->getAllCurrentProperties(propertyNames, propertyValues); Uint32 size = propertyNames.size(); // // initialize all the property owners with the values // from the config files. // for (Uint32 i = 0; i < size; i++) { // // initialize the current value of the property owner // with the value from the config file handler // try { // // get property owner object from the config table. // ConfigPropertyOwner* propertyOwner; String propertyName = propertyNames[i].getString(); if (_propertyTable->ownerTable.lookup( propertyName, propertyOwner)) { if (propertyOwner->isValid( propertyName, propertyValues[i])) { propertyOwner->initCurrentValue( propertyName, propertyValues[i]); propertyOwner->initPlannedValue( propertyName, propertyValues[i]); } else { throw InvalidPropertyValue(propertyName, propertyValues[i]); } } else { // if the property is a fixed property then just log that // this property is not supported and continue. In all other // cases terminate the cimserver if (_propertyTable->fixedValueTable.contains(propertyName)) { Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, MessageLoaderParms( "Config.ConfigManager.NOTSUPPORTED_CONFIG_PROPERTY", "Configuration property $0 is not supported. " "Setting ignored.", propertyName)); } else { throw UnrecognizedConfigProperty(propertyName); } } } catch (UnrecognizedConfigProperty& ucp) { PEG_TRACE_CSTRING(TRC_CONFIG, Tracer::LEVEL1, (const char*)ucp.getMessage().getCString()); throw; } catch (InvalidPropertyValue& ipv) { PEG_TRACE_CSTRING(TRC_CONFIG, Tracer::LEVEL1, (const char*)ipv.getMessage().getCString()); throw; } } }
/** Init current value of the specified property to the specified value */ void DefaultPropertyOwner::initCurrentValue( const String& name, const String& value) { Uint32 index; for (index = 0; index < NUM_PROPERTIES; index++) { if (String::equal( _configProperties.get()[index].propertyName, name)) { if (String::equalNoCase(name, "maxProviderProcesses") || String::equalNoCase(name, "maxFailedProviderModuleRestarts")) { AutoMutex lock(_dynamicConfigPropertyMutex); _configProperties.get()[index].currentValue = value; } else if (String::equalNoCase(name, "hostname")) { if (0 == value.size()) { _configProperties.get()[index].currentValue= System::getHostName(); } else { System::setHostName(value); _configProperties.get()[index].currentValue=value; } } else if (String::equalNoCase(name, "fullyQualifiedHostName")) { if (0 == value.size()) { _configProperties.get()[index].currentValue= System::getFullyQualifiedHostName(); } else { System::setFullyQualifiedHostName(value); _configProperties.get()[index].currentValue=value; } } else { _configProperties.get()[index].currentValue = value; } break; } } if (index >= NUM_PROPERTIES) { // // Specified property name could not be found // throw UnrecognizedConfigProperty(name); } else if (String::equal(name, "idleConnectionTimeout")) { Uint64 v; StringConversion::decimalStringToUint64(value.getCString(), v); HTTPConnection::setIdleConnectionTimeout((Uint32)v); } else if (String::equal(name, "socketWriteTimeout")) { Uint64 v; StringConversion::decimalStringToUint64(value.getCString(), v); HTTPAcceptor::setSocketWriteTimeout((Uint32)v); } return; }