Change in vdsm[master]: config: Make it easy to create default config

nsoffer at redhat.com nsoffer at redhat.com
Thu Mar 6 21:50:31 UTC 2014


Nir Soffer has uploaded a new change for review.

Change subject: config: Make it easy to create default config
......................................................................

config: Make it easy to create default config

Previously a default config object was created by invoking a private
function, modifying the global config, before reading the configuration
from the config file. This design make it impossible to create a default
config object for testing, or to reload the configuration while vdsm is
running.

This patch replace the private function with public function accepting
a config object. Now you can create a default config object by creating
a new config parser and setting the defaults:

    fake_config = ConfigParser.ConfigParser()
    config.set_defaults(fake_config)
    fake_config.set('irs', 'repository', '/my/fake/repository')

Change-Id: I80ec628d1da5c0466af28cb73564c6e63fd5ca65
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M lib/vdsm/config.py.in
1 file changed, 2 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/04/25504/1

diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index fb597a8..f01743c 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -318,9 +318,7 @@
 ]
 
 
-def __prepare_config():
-    global config
-
+def set_defaults(config):
     for section, keylist in parameters:
         config.add_section(section)
         for key, value, comment in keylist:
@@ -343,7 +341,7 @@
             print
 
 config = ConfigParser.ConfigParser()
-__prepare_config()
+set_defaults(config)
 config.read([os.path.join('@CONFDIR@', 'vdsm.conf')])
 
 if __name__ == '__main__':


-- 
To view, visit http://gerrit.ovirt.org/25504
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I80ec628d1da5c0466af28cb73564c6e63fd5ca65
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list