]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: add LibCephFS.create_with_rados
authorJohn Spray <john.spray@redhat.com>
Fri, 18 Sep 2015 16:45:48 +0000 (17:45 +0100)
committerJohn Spray <john.spray@redhat.com>
Tue, 5 Jan 2016 00:47:53 +0000 (00:47 +0000)
Enable setting up cephfs while borrowing
the CephContext from an already-set-up
rados python client.

Signed-off-by: John Spray <john.spray@redhat.com>
src/pybind/cephfs.py

index 1216f68bcaa03b51925e57eb098510d9d59b5c87..747f273b9722bfa857001ec5795eb4fce6db6ca3 100644 (file)
@@ -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')