diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 6687cb86a15..3a9352dc7f3 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -597,13 +597,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): @@ -621,10 +626,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.items(): diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index 2bda6d315d7..8fe9f1ebeaa 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -708,10 +708,15 @@ cdef class Rados(object): PyEval_InitThreads() self.__setup(*args, **kwargs) + 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)), ('name', opt(str)), ('clustername', opt(str)), - ('conffile', opt(str))) + ('conffile', (str, 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 @@ -753,10 +758,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():