summaryrefslogtreecommitdiffstats
path: root/src/python
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2013-09-18 08:00:08 +0200
committerRadek Novacek <rnovacek@redhat.com>2013-09-18 08:00:38 +0200
commite4d72c3b72f2f363ec556c5f0ec6d94bd4f038ed (patch)
treed50d5e7ba4d238725a48c97659a7c40e1131729a /src/python
parent87ac9c8b710ff016ac6db4311503a5b699b91c41 (diff)
downloadopenlmi-providers-e4d72c3b72f2f363ec556c5f0ec6d94bd4f038ed.tar.gz
openlmi-providers-e4d72c3b72f2f363ec556c5f0ec6d94bd4f038ed.tar.xz
openlmi-providers-e4d72c3b72f2f363ec556c5f0ec6d94bd4f038ed.zip
Introduce toplevel openlmi config file
Toplevel openlmi configuration file (/etc/openlmi/openlmi.conf) now contains common configuration options for all providers. Configuration for each provider could be overriden in provider-specific config (/etc/openlmi/$provider/$provider.conf). This patch also modify config file handling in python providers to include this config file. There is also support for C providers (in libopenlmicommon) for reading these config files and providing default configuration options.
Diffstat (limited to 'src/python')
-rw-r--r--src/python/lmi/base/BaseConfiguration.py40
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)