callback_plugins/validation_output.py: improved output

- when the validation is successful, all hosts are listed in the output
- when the validation does not run on any host, output contains a warning
- when the validation fails, both hosts where it passed and where it failed are listed

Change-Id: I69368d2c56d4f014d0dde78b8662146fcf686751
Closes-Bug: #1636849
This commit is contained in:
Katerina Pilatova 2016-11-10 12:44:26 +01:00
parent 6c0001331b
commit d6f10a2ab0
1 changed files with 19 additions and 5 deletions

View File

@ -144,9 +144,23 @@ class CallbackModule(CallbackBase):
hosts = sorted(stats.processed.keys())
failed_hosts = [host for host in hosts if failed(host)]
if failed_hosts:
print("Failure! The validation failed for the following hosts:")
for host in hosts:
print("*", host)
if hosts:
if failed_hosts:
if len(failed_hosts) == len(hosts):
print("Failure! The validation failed for all hosts:")
for failed_host in failed_hosts:
print("*", failed_host)
else:
print("Failure! The validation failed for hosts:")
for failed_host in failed_hosts:
print("*", failed_host)
print("and passed for hosts:")
for host in [h for h in hosts if h not in failed_hosts]:
print("*", host)
else:
print("Success! The validation passed for all hosts:")
for host in hosts:
print("*", host)
else:
print("Success! The validation passed for all hosts.")
print("Warning! The validation did not run on any host.")