[Validator Run] Add return code management
The validator run command will now raise a CommandError exception if one or more validations have failed. This patch is also aligning the result table to left in order to be compliant with other table output. Closes-Bug: #1915154 Change-Id: I265b77de4b8f9b611f6bc908e90d8f69a26439ab Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com> (cherry picked from commitbe3f43ff81
) (cherry picked from commit5317f37ae3
)
This commit is contained in:
parent
5f803a1c44
commit
53e24c0b57
|
@ -403,6 +403,7 @@ class TripleOValidatorRun(command.Command):
|
|||
# Set Field name by getting the result dict keys
|
||||
t.field_names = results[0].keys()
|
||||
t.align = 'l'
|
||||
is_failed_validation = False
|
||||
for r in results:
|
||||
if r.get('Status_by_Host'):
|
||||
h = []
|
||||
|
@ -412,11 +413,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:
|
||||
|
@ -428,6 +431,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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue