From c384b9e3796821db5ff7adbc57a04eac8480dee2 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Fri, 24 Mar 2023 21:06:52 +0530 Subject: [PATCH] qa/cephfs: upgrade gen_mds_cap_str() in caps_helper 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 (cherry picked from commit 0934845a3889d6ac5d2c631f00ebb074bc7ece0e) --- qa/tasks/cephfs/caps_helper.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/qa/tasks/cephfs/caps_helper.py b/qa/tasks/cephfs/caps_helper.py index 771bc12aedb..9e3ddcc6c80 100644 --- a/qa/tasks/cephfs/caps_helper.py +++ b/qa/tasks/cephfs/caps_helper.py @@ -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 -- 2.47.3