Skip to content

Commit de6d6ff

Browse files
committed
testhelper: add directmnt and get_share()
Add an additional entity directmnt which points to the mount to the underlying filesystem. Also add get_share() to get the share entity. Signed-off-by: Sachin Prabhu <[email protected]>
1 parent d1b8d55 commit de6d6ff

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

testhelper/testhelper.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,58 @@ def get_shares(test_info: dict) -> typing.List[dict]:
9393
default_fs = test_info.get("test_backend", None)
9494
arr = []
9595
for sharename in test_info.get("exported_sharenames", []):
96-
arr.append({"name": sharename, "mntdir": None, "fs": default_fs})
96+
arr.append(
97+
{
98+
"name": sharename,
99+
"mntdir": None,
100+
"fs": default_fs,
101+
"directmnt": None,
102+
}
103+
)
97104
for share in test_info.get("exported_shares", []):
98105
arr.append(
99106
{
100107
"name": share.get("name", None),
101108
"mntdir": share.get("mntdir", None),
102109
"fs": share.get("fs", default_fs),
110+
"directmnt": share.get("directmnt", None),
103111
}
104112
)
105113
test_info["shares"] = arr
106114
return arr
107115

108116

117+
def get_share(test_info: dict, sharename: str) -> dict:
118+
"""
119+
Get share dict for a given sharename
120+
121+
Parameters:
122+
test_info: Dict containing the parsed yaml file.
123+
sharename: name of the share
124+
Returns:
125+
dict of the share
126+
"""
127+
for share in get_shares(test_info):
128+
if share["name"] == sharename:
129+
return share
130+
return {}
131+
132+
def get_shares_with_directmnt(test_info: dict) -> typing.List[dict]:
133+
"""
134+
Get list of shares with directmnt enabled
135+
136+
Parameters:
137+
test_info: Dict containing the parsed yaml file.
138+
Returns:
139+
list of shares
140+
"""
141+
arr = []
142+
for share in get_shares(test_info):
143+
if share["directmnt"] is not None:
144+
arr.append(share)
145+
return arr
146+
147+
109148
def is_premounted_share(share: dict) -> bool:
110149
"""
111150
Is the share dict a premounted share

0 commit comments

Comments
 (0)