CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OptionsManager Class Referenceabstract

#include <options.h>

Inheritance diagram for OptionsManager:
Collaboration diagram for OptionsManager:

Classes

struct  ConfigValue
 

Public Member Functions

 OptionsManager (OptionsTemplateManager *opt_templ_mgr_param)
 
 OptionsManager (const OptionsManager &opt_mgr)
 
virtual ~OptionsManager ()
 
void SwitchTemplateManager (OptionsTemplateManager *opt_templ_mgr_param)
 
virtual void ParsePath (const std::string &config_file, const bool external)=0
 
void ParseDefault (const std::string &fqrn)
 
void ClearConfig ()
 
bool IsDefined (const std::string &key)
 
bool GetValue (const std::string &key, std::string *value) const
 
std::string GetValueOrDie (const std::string &key)
 
bool GetSource (const std::string &key, std::string *value)
 
bool IsOn (const std::string &param_value) const
 
bool IsOff (const std::string &param_value) const
 
std::vector< std::string > GetAllKeys ()
 
std::vector< std::string > GetEnvironmentSubset (const std::string &key_prefix, bool strip_prefix)
 
std::string Dump ()
 
bool HasConfigRepository (const std::string &fqrn, std::string *config_path)
 
void ProtectParameter (const std::string &param)
 
void SetValue (const std::string &key, const std::string &value)
 
void SetValueFromTalk (const std::string &key, const std::string &value)
 
void UnsetValue (const std::string &key)
 
void set_taint_environment (bool value)
 

Protected Member Functions

std::string TrimParameter (const std::string &parameter)
 
std::string SanitizeParameterAssignment (std::string *line, std::vector< std::string > *tokens)
 
void PopulateParameter (const std::string &param, const ConfigValue val)
 
void ParseValue (const std::string param, ConfigValue *val)
 
void UpdateEnvironment (const std::string &param, ConfigValue val)
 

Protected Attributes

std::map< std::string,
ConfigValue
config_
 
std::map< std::string,
std::string > 
protected_parameters_
 
std::map< std::string,
std::string > 
templatable_values_
 
OptionsTemplateManageropt_templ_mgr_
 
bool taint_environment_
 

Private Member Functions

OptionsManageroperator= (const OptionsManager &)
 

Detailed Description

This is the abstract base class for the different option parsers. It parses and stores the information contained in different config files, keeping the last parsed file that changed each property. It stores the information in a key-value map so that for each variable name the value and last source are stored, and makes each property part of the program's environments

Definition at line 47 of file options.h.

Constructor & Destructor Documentation

OptionsManager::OptionsManager ( OptionsTemplateManager opt_templ_mgr_param)
inlineexplicit

Definition at line 49 of file options.h.

OptionsManager::OptionsManager ( const OptionsManager opt_mgr)
inline

Definition at line 58 of file options.h.

virtual OptionsManager::~OptionsManager ( )
inlinevirtual

Definition at line 67 of file options.h.

Member Function Documentation

void OptionsManager::ClearConfig ( )

Cleans all information about the variables

Definition at line 365 of file options.cc.

string OptionsManager::Dump ( )

Gets all stored key-values of the map in an string format. This format follows the following pattern:

"KEY=VALUE # from SOURCE"

Returns
a vector containing all key-values in a string format

Definition at line 454 of file options.cc.

Referenced by FileSystem::Create(), cvmcache_options_dump(), cvmfs_options_dump(), FuseMain(), TalkManager::MainResponder(), and publish::CmdEnter::WriteCvmfsConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

vector< string > OptionsManager::GetAllKeys ( )

Retrieves a vector containing all stored keys

Returns
a vector with all keys contained in the map

Definition at line 423 of file options.cc.

Referenced by publish::SettingsBuilder::GetSessionEnvironment().

Here is the caller graph for this function:

vector< string > OptionsManager::GetEnvironmentSubset ( const std::string &  key_prefix,
bool  strip_prefix 
)

Returns key=value strings from the options array for all keys that match key_prefix. Can be used to construct an environment pointer for execve.

Definition at line 434 of file options.cc.

Referenced by AuthzExternalFetcher::ExecHelper().

Here is the call graph for this function:

Here is the caller graph for this function:

bool OptionsManager::GetSource ( const std::string &  key,
std::string *  value 
)

Gets the stored last source of a concrete variable

Parameters
keyvariable to be accessed in the map
valuecontainer of the received value, if it exists
Returns
true if that variable was previously defined in at least one source

Definition at line 398 of file options.cc.

bool OptionsManager::GetValue ( const std::string &  key,
std::string *  value 
) const

Gets the stored value for a concrete variable

Parameters
keyvariable to be accessed in the map
valuecontainer of the received value, if it exists
Returns
true if there was a value stored in the map for key

Definition at line 376 of file options.cc.

Referenced by publish::SettingsBuilder::ApplyOptionsFromServerPath(), MountPoint::CheckBlacklists(), CheckProxy(), CheckStrictMount(), MountPoint::CreateAuthz(), MountPoint::CreateCatalogManager(), MountPoint::CreateDownloadManagers(), MountPoint::CreateResolvConfWatcher(), publish::SettingsBuilder::CreateSettingsPublisherFromSession(), publish::SettingsBuilder::CreateSettingsRepository(), MountPoint::CreateSignatureManager(), FileSystem::CreateStatistics(), MountPoint::CreateTables(), MountPoint::CreateTracer(), cvmcache_options_get(), cvmfs_attach_repo(), cvmfs_options_get(), FileSystem::DetermineNfsMode(), InstanceInfo::DeterminePaths(), FileSystem::DeterminePosixCacheSettings(), MountPoint::DetermineRootHash(), FileSystem::FileSystem(), FuseMain(), StatisticsDatabase::GcExtendedStats(), GetCacheDir(), GetCvmfsUser(), StatisticsDatabase::GetDBParams(), InstanceInfo::GetDefaultDomain(), receiver::GetParamsFromFile(), publish::SettingsBuilder::GetSessionEnvironment(), GetWorkspace(), anonymous_namespace{cmd_sub.cc}::SwissknifeSubscriber::Init(), Init(), LibGlobals::Initialize(), publish::CmdInfo::Main(), main(), TalkManager::MainResponder(), MkFqrn(), upload::S3Uploader::ParseSpoolerDefinition(), MountPoint::SetupBehavior(), FileSystem::SetupCacheMgr(), MountPoint::SetupDnsTuning(), FileSystem::SetupExternalCacheMgr(), MountPoint::SetupExternalDownloadMgr(), MountPoint::SetupHttpTuning(), MountPoint::SetupInodeAnnotation(), FileSystem::SetupLoggingStandalone(), FileSystem::SetupNfsMaps(), MountPoint::SetupOwnerMaps(), FileSystem::SetupRamCacheMgr(), FileSystem::SetupTieredCacheMgr(), FileSystem::SetupWorkspace(), perf::TelemetryAggregatorInflux::TelemetryAggregatorInflux(), FileSystem::TriageCacheMgr(), and WaitForReload().

std::string OptionsManager::GetValueOrDie ( const std::string &  key)

Gets the stored value for a concrete variable. Panics if the value is missing.

Parameters
keyvariable to be accessed in the map
valuecontainer of the received value, if it exists

Definition at line 387 of file options.cc.

Referenced by publish::SettingsBuilder::CreateSettingsPublisher(), and publish::SettingsBuilder::GetSessionEnvironment().

Here is the caller graph for this function:

bool OptionsManager::HasConfigRepository ( const std::string &  fqrn,
std::string *  config_path 
)

Definition at line 256 of file options.cc.

Referenced by MountPoint::CheckBlacklists().

Here is the call graph for this function:

Here is the caller graph for this function:

bool OptionsManager::IsDefined ( const std::string &  key)

Checks if a concrete key (variable) is defined

Parameters
keyvariable to be checked in the map
Returns
true if there is a value for key, false otherwise

Definition at line 370 of file options.cc.

Referenced by MountPoint::CreateResolvConfWatcher(), cvmfs_options_clone_legacy(), MountPoint::DetermineRootHash(), receiver::GetParamsFromFile(), Init(), main(), FileSystem::MkCacheParm(), upload::S3Uploader::ParseSpoolerDefinition(), and FileSystem::SetupWorkspace().

Here is the caller graph for this function:

bool OptionsManager::IsOff ( const std::string &  param_value) const

Checks if a variable contains a boolean value

Parameters
param_valuevariable to be accessed in the map
Returns
true if param has as value "NO", "OFF", "0", or "FALSE".

Definition at line 416 of file options.cc.

Referenced by FileSystem::DeterminePosixCacheSettings(), and MountPoint::SetupBehavior().

Here is the call graph for this function:

Here is the caller graph for this function:

OptionsManager& OptionsManager::operator= ( const OptionsManager )
inlineprivate

Definition at line 231 of file options.h.

Here is the call graph for this function:

void OptionsManager::ParseDefault ( const std::string &  fqrn)

Parses the default config files for cvmfs

Definition at line 282 of file options.cc.

Referenced by cvmfs_options_parse_default(), InstanceInfo::DeterminePaths(), FuseMain(), InstanceInfo::GetDefaultDomain(), InitOptionsMgr(), main(), and publish::CmdEnter::WriteCvmfsConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void OptionsManager::ParsePath ( const std::string &  config_file,
const bool  external 
)
pure virtual

Opens the config_file and extracts all contained variables and their corresponding values. The new variables are set (and overwritten in case they were previously defined) as environment variables

Parameters
config_fileabsolute path to the configuration file
externalif true it indicates the configuration file is in the repository. If false the configuration file is in /etc

Implemented in BashOptionsManager.

Referenced by publish::SettingsBuilder::CreateSettingsPublisher(), publish::SettingsBuilder::CreateSettingsRepository(), FuseMain(), and InitOptionsMgr().

Here is the caller graph for this function:

void OptionsManager::ParseValue ( const std::string  param,
ConfigValue val 
)
protected

Definition at line 347 of file options.cc.

void OptionsManager::PopulateParameter ( const std::string &  param,
const ConfigValue  val 
)
protected

Definition at line 322 of file options.cc.

Here is the call graph for this function:

void OptionsManager::ProtectParameter ( const std::string &  param)

Similar to a bash "read-only" parameter: the current value will be locked and cannot be changed anymore by succeeding parsings of config files.

Definition at line 356 of file options.cc.

string OptionsManager::SanitizeParameterAssignment ( std::string *  line,
std::vector< std::string > *  tokens 
)
protected

Definition at line 75 of file options.cc.

Here is the call graph for this function:

void OptionsManager::SetValue ( const std::string &  key,
const std::string &  value 
)

Artificially inject values in the option manager.

Definition at line 479 of file options.cc.

Referenced by cvmcache_options_init(), cvmcache_options_set(), cvmfs_options_clone_legacy(), cvmfs_options_init_legacy(), cvmfs_options_init_v2(), cvmfs_options_set(), and publish::CmdEnter::WriteCvmfsConfig().

Here is the caller graph for this function:

void OptionsManager::SetValueFromTalk ( const std::string &  key,
const std::string &  value 
)

Artificially inject values in the option manager, marking cvmfs_talk as the source.

Definition at line 472 of file options.cc.

Referenced by TalkManager::MainResponder().

Here is the caller graph for this function:

void OptionsManager::SwitchTemplateManager ( OptionsTemplateManager opt_templ_mgr_param)

Switches the Options Templating Manager and reparses the set options

Definition at line 92 of file options.cc.

Referenced by cvmfs_attach_repo_v2(), cvmfs_options_clone_legacy(), and main().

Here is the caller graph for this function:

string OptionsManager::TrimParameter ( const std::string &  parameter)
protected

Definition at line 59 of file options.cc.

Here is the call graph for this function:

void OptionsManager::UnsetValue ( const std::string &  key)

Purge a value from the parameter map. Used in unit tests.

Definition at line 487 of file options.cc.

Referenced by cvmcache_options_unset(), and cvmfs_options_unset().

Here is the caller graph for this function:

void OptionsManager::UpdateEnvironment ( const std::string &  param,
ConfigValue  val 
)
protected

Definition at line 338 of file options.cc.

Here is the call graph for this function:

Member Data Documentation

std::map<std::string, ConfigValue> OptionsManager::config_
protected

Definition at line 218 of file options.h.

Referenced by OptionsManager().

OptionsTemplateManager* OptionsManager::opt_templ_mgr_
protected

Definition at line 222 of file options.h.

Referenced by OptionsManager().

std::map<std::string, std::string> OptionsManager::protected_parameters_
protected

Definition at line 219 of file options.h.

Referenced by OptionsManager().

bool OptionsManager::taint_environment_
protected

Whether to add environment variables to the process' environment or not. In libcvmfs, we don't want a tainted environment.

Definition at line 227 of file options.h.

Referenced by OptionsManager().

std::map<std::string, std::string> OptionsManager::templatable_values_
protected

Definition at line 220 of file options.h.

Referenced by OptionsManager().


The documentation for this class was generated from the following files: