Merge "[Validator Run] Add return code management" into stable/train

This commit is contained in:
Zuul 2021-02-12 16:23:02 +00:00 committed by Gerrit Code Review
commit 52024d4501
1 changed files with 10 additions and 3 deletions

View File

@ -410,6 +410,7 @@ class TripleOValidatorRun(command.Command):
t = PrettyTable(border=True, header=True, padding_width=1)
# Set Field name by getting the result dict keys
t.field_names = results[0].keys()
is_failed_validation = False
for r in results:
if r.get('Status_by_Host'):
h = []
@ -419,11 +420,13 @@ class TripleOValidatorRun(command.Command):
_name = '{}{}{}'.format(color, _name, RESET)
h.append(_name)
r['Status_by_Host'] = ', '.join(h)
if r.get('status'):
status = r.get('status')
if r.get('Status'):
status = r.get('Status')
if status == 'FAILED':
is_failed_validation = True
color = (CYAN if status in ['starting', 'running']
else GREEN if status == 'PASSED' else RED)
r['status'] = '{}{}{}'.format(color, status, RESET)
r['Status'] = '{}{}{}'.format(color, status, RESET)
t.add_row(r.values())
print(t)
else:
@ -435,6 +438,10 @@ class TripleOValidatorRun(command.Command):
oooutils.cleanup_tripleo_ansible_inventory_file(
static_inventory)
if is_failed_validation:
raise exceptions.CommandError(
_("One or more validations have failed."))
def take_action(self, parsed_args):
self._run_validator_run(parsed_args)