diff options
Diffstat (limited to 'src/python')
| -rw-r--r-- | src/python/lmi/base/BaseConfiguration.py | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/python/lmi/base/BaseConfiguration.py b/src/python/lmi/base/BaseConfiguration.py index 8790acf..275fc0f 100644 --- a/src/python/lmi/base/BaseConfiguration.py +++ b/src/python/lmi/base/BaseConfiguration.py @@ -72,9 +72,12 @@ class BaseConfiguration(Singleton): There should be only one instance of this class. """ - CONFIG_DIRECTORY_TEMPLATE = '/etc/openlmi/%(provider_prefix)s/' - CONFIG_FILE_PATH_TEMPLATE = \ - CONFIG_DIRECTORY_TEMPLATE + '%(provider_prefix)s.conf' + CONFIG_DIRECTORY_TEMPLATE_TOPLEVEL = '/etc/openlmi/' + CONFIG_DIRECTORY_TEMPLATE_PROVIDER = '/etc/openlmi/%(provider_prefix)s/' + CONFIG_FILE_PATH_TEMPLATE_TOPLEVEL = \ + CONFIG_DIRECTORY_TEMPLATE_TOPLEVEL + 'openlmi.conf' + CONFIG_FILE_PATH_TEMPLATE_PROVIDER = \ + CONFIG_DIRECTORY_TEMPLATE_PROVIDER + '%(provider_prefix)s.conf' PERSISTENT_PATH_TEMPLATE = '/var/lib/openlmi-%(provider_prefix)s/' SETTINGS_DIR = 'settings/' @@ -106,11 +109,17 @@ class BaseConfiguration(Singleton): return cls.DEFAULT_OPTIONS @classmethod - def config_directory(cls): - """ Base directory with configuration settings. """ - return cls.CONFIG_DIRECTORY_TEMPLATE % { + def config_directory_toplevel(cls): + """ Base directory with toplevel configuration settings. """ + return cls.CONFIG_DIRECTORY_TEMPLATE_TOPLEVEL + + @classmethod + def config_directory_provider(cls): + """ Base directory with provider specific configuration settings. """ + return cls.CONFIG_DIRECTORY_TEMPLATE_PROVIDER % { 'provider_prefix' : cls.provider_prefix() } + @classmethod def persistent_path(cls): """ Base directory with persistent settings. """ @@ -118,11 +127,17 @@ class BaseConfiguration(Singleton): 'provider_prefix': cls.provider_prefix() } @classmethod - def config_file_path(cls): - """ File path of configuration file. """ - return cls.CONFIG_FILE_PATH_TEMPLATE % { + def config_file_path_toplevel(cls): + """ File path of toplevel configuration file. """ + return cls.CONFIG_FILE_PATH_TEMPLATE_TOPLEVEL + + @classmethod + def config_file_path_provider(cls): + """ File path of provider specific configuration file. """ + return cls.CONFIG_FILE_PATH_TEMPLATE_PROVIDER % { 'provider_prefix' : cls.provider_prefix() } + @classmethod def mandatory_sections(cls): """ @@ -163,10 +178,11 @@ class BaseConfiguration(Singleton): def load(self): """ - Load configuration from config file path. - The file does not need to exist. + Load configuration from config files. Provider specific options + overrides toplevel openlmi configuration. + The files do not need to exist. """ - self.config.read(self.config_file_path()) + self.config.read([self.config_file_path_toplevel(), self.config_file_path_provider()]) for section in self.mandatory_sections(): if not self.config.has_section(section): self.config.add_section(section) |
