]> git.apps.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>
Wed, 29 Mar 2023 12:39:29 +0000 (18:09 +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>
qa/tasks/cephfs/caps_helper.py

index abcb0bfd96a010ba4c303b4e857330cdb38e2146..c35d460fb938fa7be8ee46027f65055cfedc9678 100644 (file)
@@ -24,8 +24,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):
@@ -79,14 +81,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