From: Kotresh HR Date: Wed, 4 Mar 2020 12:11:19 +0000 (+0530) Subject: libcephfs/pybind: Add set_uuid, set_session_timeout X-Git-Tag: v16.1.0~2070^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=25f0e2d54775482883b895bb30aa54afe16ab271;p=ceph.git libcephfs/pybind: Add set_uuid, set_session_timeout Fixes: https://tracker.ceph.com/issues/44171 Signed-off-by: Kotresh HR --- diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 44658b00d82..146a195e51a 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -230,6 +230,8 @@ cdef extern from "cephfs/libcephfs.h" nogil: int ceph_debug_get_fd_caps(ceph_mount_info *cmount, int fd) int ceph_debug_get_file_caps(ceph_mount_info *cmount, const char *path) uint32_t ceph_get_cap_return_timeout(ceph_mount_info *cmount) + void ceph_set_uuid(ceph_mount_info *cmount, const char *uuid) + void ceph_set_session_timeout(ceph_mount_info *cmount, unsigned timeout) class Error(Exception): @@ -2300,3 +2302,34 @@ cdef class LibCephFS(object): raise make_ex(ret, "error in get_cap_return_timeout") return ret + + def set_uuid(self, uuid): + """ + Set ceph client uuid. Must be called before mount. + + :param uuid: the uuid to set + """ + + uuid = cstr(uuid, 'uuid') + + cdef: + char* _uuid = uuid + + with nogil: + ceph_set_uuid(self.cluster, _uuid) + + def set_session_timeout(self, timeout): + """ + Set ceph client session timeout. Must be called before mount. + + :param timeout: the timeout to set + """ + + if not isinstance(timeout, int): + raise TypeError('timeout must be an int') + + cdef: + int _timeout = timeout + + with nogil: + ceph_set_session_timeout(self.cluster, _timeout) diff --git a/src/test/pybind/test_cephfs.py b/src/test/pybind/test_cephfs.py index a5b08102cb7..97e8c5c8ac9 100644 --- a/src/test/pybind/test_cephfs.py +++ b/src/test/pybind/test_cephfs.py @@ -5,6 +5,7 @@ import fcntl import os import time import stat +import uuid from datetime import datetime cephfs = None @@ -586,3 +587,14 @@ def test_caps(): assert_equal(fd_caps, file_caps) cephfs.close(fd) cephfs.unlink(b'/file-caps') + +@with_setup(setup_test) +def test_setuuid(): + ses_id_uid = uuid.uuid1() + ses_id_str = str(ses_id_uid) + cephfs.set_uuid(ses_id_str) + +@with_setup(setup_test) +def test_session_timeout(): + assert_raises(TypeError, cephfs.set_session_timeout, "300") + cephfs.set_session_timeout(300)