From: John Spray Date: Fri, 18 Sep 2015 16:45:48 +0000 (+0100) Subject: pybind: add LibCephFS.create_with_rados X-Git-Tag: v10.0.3~16^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fc9a0b13eba33a69c775096151bf9baacfe68213;p=ceph.git 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 --- diff --git a/src/pybind/cephfs.py b/src/pybind/cephfs.py index 1216f68bcaa0..747f273b9722 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')