summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Mick <dan.mick@inktank.com>2013-07-24 14:32:41 -0700
committerDan Mick <dan.mick@inktank.com>2013-07-24 14:38:15 -0700
commit0b8cad1805bd72c7359b21cfdbc05c2c7b887e44 (patch)
tree9917026a1dffb8cb28c77efb3ae95f448f5fb426
parentd7df620b5723d6d7d41338be330ca293f62aa23c (diff)
downloadceph-0b8cad1805bd72c7359b21cfdbc05c2c7b887e44.tar.gz
ceph_rest_api.py: allow config section fallback
Try clientname, then 'client', then 'global Fixes: #5743 Signed-off-by: Dan Mick <dan.mick@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
-rwxr-xr-xsrc/pybind/ceph_rest_api.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/pybind/ceph_rest_api.py b/src/pybind/ceph_rest_api.py
index fdfe84ee3cb..a379e352b1f 100755
--- a/src/pybind/ceph_rest_api.py
+++ b/src/pybind/ceph_rest_api.py
@@ -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