]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs/pybind: Add set_uuid, set_session_timeout
authorKotresh HR <khiremat@redhat.com>
Wed, 4 Mar 2020 12:11:19 +0000 (17:41 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 14 Apr 2020 10:39:34 +0000 (16:09 +0530)
Fixes: https://tracker.ceph.com/issues/44171
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/pybind/cephfs/cephfs.pyx
src/test/pybind/test_cephfs.py

index 44658b00d8283bd518a87e3630aa699641af92ca..146a195e51a3702ca0039ad9785ffca46cb44cd3 100644 (file)
@@ -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)
index a5b08102cb7d2e59e502b5f19167e47b189a86b1..97e8c5c8ac9caacddc29dd1ed48f9e19185dae39 100644 (file)
@@ -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)