]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: add special values for not reading conffile 37725/head
authorKefu Chai <kchai@redhat.com>
Thu, 12 Mar 2020 10:44:19 +0000 (18:44 +0800)
committerRishabh Dave <ridave@redhat.com>
Tue, 20 Oct 2020 14:16:15 +0000 (19:46 +0530)
Fixes: https://tracker.ceph.com/issues/44415
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 7e4275390c713b8728a3deab7058bf5e21c424cb)

 Conflicts:
src/pybind/rados/rados.pyx
Now string "str_type" is used instead of str to specify type of
the argument. The PR was from the time where str was still being
        used.

src/pybind/cephfs/cephfs.pyx
src/pybind/rados/rados.pyx

index 7d8cabd004c4067cbcfb0ea5ad45102d8439a99c..d7d0c51e451133ebc09e54df84d1802ad584fbd2 100644 (file)
@@ -505,13 +505,18 @@ cdef class LibCephFS(object):
             raise Error("libcephfs_initialize failed with error code: %d" % ret)
         self.state = "configuring"
 
-    def create(self, conf=None, conffile=None, auth_id=None):
+    NO_CONF_FILE = -1
+    "special value that indicates no conffile should be read when creating a mount handle"
+    DEFAULT_CONF_FILES = -2
+    "special value that indicates the default conffiles should be read when creating a mount handle"
+
+    def create(self, conf=None, conffile=NO_CONF_FILE, auth_id=None):
         """
         Create a mount handle for interacting with Ceph.  All libcephfs
         functions operate on a mount info handle.
         
         :param conf dict opt: settings overriding the default ones and conffile
-        :param conffile str opt: the path to ceph.conf to override the default settings
+        :param conffile Union[int,str], optional: the path to ceph.conf to override the default settings
         :auth_id str opt: the id used to authenticate the client entity
         """
         if conf is not None and not isinstance(conf, dict):
@@ -529,10 +534,11 @@ cdef class LibCephFS(object):
             raise Error("libcephfs_initialize failed with error code: %d" % ret)
 
         self.state = "configuring"
-        if conffile is not None:
-            # read the default conf file when '' is given
-            if conffile == '':
-                conffile = None
+        if conffile in (self.NO_CONF_FILE, None):
+            pass
+        elif conffile in (self.DEFAULT_CONF_FILES, ''):
+            self.conf_read_file(None)
+        else:
             self.conf_read_file(conffile)
         if conf is not None:
             for key, value in conf.iteritems():
index cfead757677518f054c7d094dd9d0539aa76f111..c8e20b7c8e0fb40f5c32f8a55406b7e51dacf941 100644 (file)
@@ -625,10 +625,15 @@ cdef class Rados(object):
         PyEval_InitThreads()
         self.__setup(*args, **kwargs)
 
-    @requires(('rados_id', opt(str_type)), ('name', opt(str_type)), ('clustername', opt(str_type)),
-              ('conffile', opt(str_type)))
+    NO_CONF_FILE = -1
+    "special value that indicates no conffile should be read when creating a mount handle"
+    DEFAULT_CONF_FILES = -2
+    "special value that indicates the default conffiles should be read when creating a mount handle"
+
+    @requires(('rados_id', opt(str_type)), ('name', opt(str_type)),
+              ('clustername', opt(str_type)), ('conffile', (str_type, int)))
     def __setup(self, rados_id=None, name=None, clustername=None,
-                conf_defaults=None, conffile=None, conf=None, flags=0,
+                conf_defaults=None, conffile=NO_CONF_FILE, conf=None, flags=0,
                 context=None):
         self.monitor_callback = None
         self.monitor_callback2 = None
@@ -670,10 +675,11 @@ cdef class Rados(object):
         if conf_defaults:
             for key, value in conf_defaults.items():
                 self.conf_set(key, value)
-        if conffile is not None:
-            # read the default conf file when '' is given
-            if conffile == '':
-                conffile = None
+        if conffile in (self.NO_CONF_FILE, None):
+            pass
+        elif conffile in (self.DEFAULT_CONF_FILES, ''):
+            self.conf_read_file(None)
+        else:
             self.conf_read_file(conffile)
         if conf:
             for key, value in conf.items():