From: Sage Weil Date: Mon, 19 Aug 2013 19:48:40 +0000 (-0700) Subject: rados pybind: add conf_parse_env() X-Git-Tag: v0.67.2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d348cf5d135d099fe0490c1519196cd83a04831e;p=ceph.git rados pybind: add conf_parse_env() Signed-off-by: Sage Weil Reviewed-by: Dan Mick (cherry picked from commit eef7cacdb19313907a9367187b742db5382ee584) --- diff --git a/src/pybind/rados.py b/src/pybind/rados.py index 7768f8c39d3f..a0e5bf42ba92 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -294,6 +294,19 @@ Rados object in state %s." % (self.state)) retargs = [a for a in cretargs if a is not None] return retargs + def conf_parse_env(self, var='CEPH_ARGS'): + """ + Parse known arguments from an environment variable, normally + CEPH_ARGS. + """ + self.require_state("configuring", "connected") + if not var: + return + ret = run_in_thread(self.librados.rados_conf_parse_env, + (self.cluster, c_char_p(var))) + if (ret != 0): + raise make_ex(ret, "error calling conf_parse_env") + def conf_get(self, option): """ Get the value of a configuration option diff --git a/src/test/pybind/test_rados.py b/src/test/pybind/test_rados.py index 4628a44a652c..a8df299c879f 100644 --- a/src/test/pybind/test_rados.py +++ b/src/test/pybind/test_rados.py @@ -31,6 +31,12 @@ def test_rados_init(): with Rados(conffile='', name='client.admin'): pass +def test_rados_parse_conf(): + with Rados(conffile='', rados_id='admin') as rados: + rados.parse_env() + rados.parse_env('FOO_DOES_NOT_EXIST_BLAHBLAH') + pass + def test_ioctx_context_manager(): with Rados(conffile='', rados_id='admin') as conn: with conn.open_ioctx('data') as ioctx: