]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_rest_api.py: allow config section fallback
authorDan Mick <dan.mick@inktank.com>
Wed, 24 Jul 2013 21:32:41 +0000 (14:32 -0700)
committerDan Mick <dan.mick@inktank.com>
Wed, 24 Jul 2013 21:38:15 +0000 (14:38 -0700)
Try clientname, then 'client', then 'global

Fixes: #5743
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/pybind/ceph_rest_api.py

index fdfe84ee3cb3bf312abdc4dda2620643511ff039..a379e352b1ff2154009ebc3e5bc22a27b340681a 100755 (executable)
@@ -91,10 +91,13 @@ def load_conf(clustername='ceph', conffile=None):
     raise EnvironmentError('No conf file found for "{0}"'.format(clustername))
 
 def get_conf(cfg, clientname, key):
-    try:
-        return cfg.get(clientname, 'restapi_' + key)
-    except ConfigParser.NoOptionError:
-        return None
+    fullkey = 'restapi_' + key
+    for sectionname in clientname, 'client', 'global':
+        try:
+            return cfg.get(sectionname, fullkey)
+        except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
+            pass
+    return None
 
 # XXX this is done globally, and cluster connection kept open; there
 # are facilities to pass around global info to requests and to