From: Dan Mick Date: Wed, 24 Jul 2013 21:32:41 +0000 (-0700) Subject: ceph_rest_api.py: allow config section fallback X-Git-Tag: v0.67-rc2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0b8cad1805bd72c7359b21cfdbc05c2c7b887e44;p=ceph.git ceph_rest_api.py: allow config section fallback Try clientname, then 'client', then 'global Fixes: #5743 Signed-off-by: Dan Mick Reviewed-by: Sage Weil --- diff --git a/src/pybind/ceph_rest_api.py b/src/pybind/ceph_rest_api.py index fdfe84ee3cb3..a379e352b1ff 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