get_status property simplification and optimization

Property was simplified to be more readable
and optimized so it doesn't loop over all stats
if it doesn't need to.

Reference to unsupported return value was removed.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I887b6e0d1e561b965f1c6d5119c7cb54cf30f1d2
This commit is contained in:
Jiri Podivin 2021-04-26 15:47:30 +02:00
parent 5558cb0d15
commit 5fd83d3ee9
1 changed files with 8 additions and 9 deletions

View File

@ -198,17 +198,16 @@ class ValidationLog(object):
def get_status(self):
"""Return validation status
:return: 'FAILED' if there is failure(s), 'PASSED' if not.
If no tasks have been executed, it returns 'NOT_RUN'.
:return: 'FAILED' if there are any failed or unreachable validations,
'PASSED' if not.
:rtype: ``string``
"""
failed = 0
for h in self.content['stats'].keys():
if self.content['stats'][h].get('failures'):
failed += 1
if self.content['stats'][h].get('unreachable'):
failed += 1
return ('FAILED' if failed else 'PASSED')
failure_states = ['failures', 'unreachable']
for v_stats in self.content['stats'].values():
if any([v_stats[failure] != 0 for failure in failure_states]):
return 'FAILED'
return 'PASSED'
@property
def get_host_group(self):