From d348cf5d135d099fe0490c1519196cd83a04831e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 19 Aug 2013 12:48:40 -0700 Subject: [PATCH] rados pybind: add conf_parse_env() Signed-off-by: Sage Weil Reviewed-by: Dan Mick (cherry picked from commit eef7cacdb19313907a9367187b742db5382ee584) --- src/pybind/rados.py | 13 +++++++++++++ src/test/pybind/test_rados.py | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/pybind/rados.py b/src/pybind/rados.py index 7768f8c39d3fb..a0e5bf42ba927 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 4628a44a652ce..a8df299c879fa 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: -- 2.39.5