Skip to content

Commit 35342d5

Browse files
author
成渭滨
committed
fix When returns None
1 parent 111ca38 commit 35342d5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

avocado/utils/multipath.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,12 @@ def fail_path(path):
273273

274274
def is_failed():
275275
path_stat = get_path_status(path)
276-
if path_stat[0] == "failed" and path_stat[2] == "faulty":
277-
return True
278-
return False
279-
276+
return (
277+
path_stat is not None
278+
and path_stat[0] == "failed"
279+
and path_stat[2] == "faulty"
280+
)
281+
280282
cmd = f'multipathd -k"fail path {path}"'
281283
if not process.system(cmd):
282284
return wait.wait_for(is_failed, timeout=10) or False
@@ -293,10 +295,12 @@ def reinstate_path(path):
293295

294296
def is_reinstated():
295297
path_stat = get_path_status(path)
296-
if path_stat[0] == "active" and path_stat[2] == "ready":
297-
return True
298-
return False
299-
298+
return (
299+
path_stat is not None
300+
and path_stat[0] == "active"
301+
and path_stat[2] == "ready"
302+
)
303+
300304
cmd = f'multipathd -k"reinstate path {path}"'
301305
if not process.system(cmd):
302306
return wait.wait_for(is_reinstated, timeout=10) or False

0 commit comments

Comments
 (0)