diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 88927b376..e3ec68a4d 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -1857,6 +1857,11 @@ def get_validations_yaml(validations_data): 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(): info = run_command(['timedatectl'], name='timedatectl') timezoneline = [tz for tz in info.split('\n') if 'Time zone:' in tz] diff --git a/tripleoclient/v1/tripleo_validator.py b/tripleoclient/v1/tripleo_validator.py index adea84545..265000122 100644 --- a/tripleoclient/v1/tripleo_validator.py +++ b/tripleoclient/v1/tripleo_validator.py @@ -30,11 +30,11 @@ class _CommaListGroupAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): opts = constants.VALIDATION_GROUPS for value in values.split(','): - if value not in opts: - message = ("Invalid choice: {value} (choose from {choice})" - .format(value=value, - choice=opts)) - raise argparse.ArgumentError(self, message) + if value not in opts: + message = ("Invalid choice: {value} (choose from {choice})" + .format(value=value, + choice=opts)) + raise argparse.ArgumentError(self, message) setattr(namespace, self.dest, values.split(',')) @@ -168,12 +168,12 @@ class TripleOValidatorRun(command.Command): } LOG.debug(_('Runnning the validations')) - try: - output = validations.run_validations(clients, workflow_input) - print(oooutils.get_validations_json(output)) - except Exception as e: - print(_("Running the validations finished with errors")) - print('Output: {}'.format(e)) + output = validations.run_validations(clients, workflow_input) + for out in output: + print('[{}] - {}\n{}'.format( + out.get('status'), + out.get('validation_name'), + oooutils.indent(out.get('stdout')))) def take_action(self, parsed_args): self._run_validator_run(parsed_args) diff --git a/tripleoclient/workflows/validations.py b/tripleoclient/workflows/validations.py index fc5755fb5..c2637c327 100644 --- a/tripleoclient/workflows/validations.py +++ b/tripleoclient/workflows/validations.py @@ -16,8 +16,6 @@ import pprint from tripleoclient.workflows import base -from tripleoclient import exceptions - def list_validations(clients, workflow_input): @@ -41,6 +39,7 @@ def run_validations(clients, workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient + results = [] 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): - if 'message' in payload: - if payload['status'] == 'SUCCESS': - return payload['message'] + if payload.get('message') is None: + if payload.get('status') in ['SUCCESS', 'FAILED']: + results.append(payload) - if payload['status'] == 'FAILED': - raise exceptions.RegisterOrUpdateError( - 'Exception running validations: {}'.format( - payload['message']) - ) + return results