From fc9a0b13eba33a69c775096151bf9baacfe68213 Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 18 Sep 2015 17:45:48 +0100 Subject: [PATCH] pybind: add LibCephFS.create_with_rados Enable setting up cephfs while borrowing the CephContext from an already-set-up rados python client. Signed-off-by: John Spray --- src/pybind/cephfs.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pybind/cephfs.py b/src/pybind/cephfs.py index 1216f68bcaa..747f273b972 100644 --- a/src/pybind/cephfs.py +++ b/src/pybind/cephfs.py @@ -194,10 +194,25 @@ class LibCephFS(object): raise LibCephFSStateError("You cannot perform that operation on a " "CephFS object in state %s." % (self.state)) - def __init__(self, conf=None, conffile=None, auth_id=None): + def __init__(self, conf=None, conffile=None, auth_id=None, rados_inst=None): self.libcephfs = load_libcephfs() self.cluster = c_void_p() + self.state = "uninitialized" + if rados_inst is not None: + return self.create_with_rados(rados_inst) + else: + return self.create(conf, conffile, auth_id) + + def create_with_rados(self, rados_inst): + ret = self.libcephfs.ceph_create_from_rados( + byref(self.cluster), + rados_inst.cluster) + if ret != 0: + raise Error("libcephfs_initialize failed with error code: %d" % ret) + self.state = "configuring" + + def create(self, conf=None, conffile=None, auth_id=None, rados_inst=None): if conffile is not None and not isinstance(conffile, basestring): raise TypeError('conffile must be a string or None') -- 2.47.3