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:
parent
5558cb0d15
commit
5fd83d3ee9
|
@ -198,17 +198,16 @@ class ValidationLog(object):
|
||||||
def get_status(self):
|
def get_status(self):
|
||||||
"""Return validation status
|
"""Return validation status
|
||||||
|
|
||||||
:return: 'FAILED' if there is failure(s), 'PASSED' if not.
|
:return: 'FAILED' if there are any failed or unreachable validations,
|
||||||
If no tasks have been executed, it returns 'NOT_RUN'.
|
'PASSED' if not.
|
||||||
:rtype: ``string``
|
:rtype: ``string``
|
||||||
"""
|
"""
|
||||||
failed = 0
|
failure_states = ['failures', 'unreachable']
|
||||||
for h in self.content['stats'].keys():
|
|
||||||
if self.content['stats'][h].get('failures'):
|
for v_stats in self.content['stats'].values():
|
||||||
failed += 1
|
if any([v_stats[failure] != 0 for failure in failure_states]):
|
||||||
if self.content['stats'][h].get('unreachable'):
|
return 'FAILED'
|
||||||
failed += 1
|
return 'PASSED'
|
||||||
return ('FAILED' if failed else 'PASSED')
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_host_group(self):
|
def get_host_group(self):
|
||||||
|
|
Loading…
Reference in New Issue