]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: upgrade gen_mds_cap_str() in caps_helper
authorRishabh Dave <ridave@redhat.com>
Fri, 24 Mar 2023 15:36:52 +0000 (21:06 +0530)
committerRishabh Dave <ridave@redhat.com>
Fri, 28 Jun 2024 11:47:54 +0000 (17:17 +0530)
Modify get_mds_cap_str() to accept a tuple with a single member. In this
case, the only member is assumed to be a permission, FS name is assigned
None type and cephfs_mntpt is assigned '/'.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit 0934845a3889d6ac5d2c631f00ebb074bc7ece0e)

qa/tasks/cephfs/caps_helper.py

index 771bc12aedbc4848e31c82ee708a1ddce8077f07..9e3ddcc6c80c4861a354b9b51720aa395eab1bb7 100644 (file)
@@ -23,8 +23,10 @@ def gen_mon_cap_str(caps):
             perm, fsname = c[0], None
         elif len(c) == 2:
             perm, fsname = c
-        else:
-            raise RuntimeError('caps tuple received isn\'t right')
+        elif len(c) < 1:
+            raise RuntimeError('received no items caps tuple')
+        else: # len(c) > 2
+            raise RuntimeError('received too many items in caps tuple')
         return perm, fsname
 
     def _gen_mon_cap_str(c):
@@ -78,14 +80,16 @@ def gen_mds_cap_str(caps):
     caps = ((perm1, fsname1, cephfs_mntpt1), (perm2, fsname2, cephfs_mntpt2))
     """
     def _unpack_tuple(c):
-        if len(c) == 2:
+        if len(c) == 1:
+            perm, fsname, cephfs_mntpt = c[0], None, '/'
+        elif len(c) == 2:
             perm, fsname, cephfs_mntpt = c[0], c[1], '/'
         elif len(c) == 3:
             perm, fsname, cephfs_mntpt = c
-        elif len(c) < 2:
-            raise RuntimeError('received items are too less in caps')
+        elif len(c) < 1:
+            raise RuntimeError('received no items caps tuple')
         else: # len(c) > 3
-            raise RuntimeError('received items are too many in caps')
+            raise RuntimeError('received too many items in caps tuple')
 
         return perm, fsname, cephfs_mntpt