Improve validations run outputs through the CLI
When the tripleo.messaging.v1.send workflow fails with the error 'Workflow failed due to message status', the return message is None and we don't have more information about what's failing. The same happens if the validation runs well. This patch improves the output in case of a messaging workflow failure. Change-Id: I3fbf1a05b706b55fe1ab6d35653aecdaa8d4cc6e Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
parent
e1a051d6ac
commit
1acbef8a06
@ -1857,6 +1857,11 @@ def get_validations_yaml(validations_data):
|
|||||||
indent=2)
|
indent=2)
|
||||||
|
|
||||||
|
|
||||||
|
def indent(text):
|
||||||
|
'''Indent the given text by four spaces.'''
|
||||||
|
return ''.join(' {}\n'.format(line) for line in text.splitlines())
|
||||||
|
|
||||||
|
|
||||||
def get_local_timezone():
|
def get_local_timezone():
|
||||||
info = run_command(['timedatectl'], name='timedatectl')
|
info = run_command(['timedatectl'], name='timedatectl')
|
||||||
timezoneline = [tz for tz in info.split('\n') if 'Time zone:' in tz]
|
timezoneline = [tz for tz in info.split('\n') if 'Time zone:' in tz]
|
||||||
|
@ -168,12 +168,12 @@ class TripleOValidatorRun(command.Command):
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug(_('Runnning the validations'))
|
LOG.debug(_('Runnning the validations'))
|
||||||
try:
|
|
||||||
output = validations.run_validations(clients, workflow_input)
|
output = validations.run_validations(clients, workflow_input)
|
||||||
print(oooutils.get_validations_json(output))
|
for out in output:
|
||||||
except Exception as e:
|
print('[{}] - {}\n{}'.format(
|
||||||
print(_("Running the validations finished with errors"))
|
out.get('status'),
|
||||||
print('Output: {}'.format(e))
|
out.get('validation_name'),
|
||||||
|
oooutils.indent(out.get('stdout'))))
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self._run_validator_run(parsed_args)
|
self._run_validator_run(parsed_args)
|
||||||
|
@ -16,8 +16,6 @@ import pprint
|
|||||||
|
|
||||||
from tripleoclient.workflows import base
|
from tripleoclient.workflows import base
|
||||||
|
|
||||||
from tripleoclient import exceptions
|
|
||||||
|
|
||||||
|
|
||||||
def list_validations(clients, workflow_input):
|
def list_validations(clients, workflow_input):
|
||||||
|
|
||||||
@ -41,6 +39,7 @@ def run_validations(clients, workflow_input):
|
|||||||
|
|
||||||
workflow_client = clients.workflow_engine
|
workflow_client = clients.workflow_engine
|
||||||
tripleoclients = clients.tripleoclient
|
tripleoclients = clients.tripleoclient
|
||||||
|
results = []
|
||||||
|
|
||||||
with tripleoclients.messaging_websocket() as ws:
|
with tripleoclients.messaging_websocket() as ws:
|
||||||
|
|
||||||
@ -60,12 +59,8 @@ def run_validations(clients, workflow_input):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
||||||
if 'message' in payload:
|
if payload.get('message') is None:
|
||||||
if payload['status'] == 'SUCCESS':
|
if payload.get('status') in ['SUCCESS', 'FAILED']:
|
||||||
return payload['message']
|
results.append(payload)
|
||||||
|
|
||||||
if payload['status'] == 'FAILED':
|
return results
|
||||||
raise exceptions.RegisterOrUpdateError(
|
|
||||||
'Exception running validations: {}'.format(
|
|
||||||
payload['message'])
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user