From 1233ce37972bae978473e07acefcfe6a72be80d7 Mon Sep 17 00:00:00 2001 From: "Gael Chamoulaud (Strider)" Date: Mon, 19 Oct 2020 12:43:48 +0200 Subject: [PATCH] [Validator Show] Properly throwing an exception for unknown validation When running validator show subcommand with a non-existing validation, the subcommand was outputting multiple tracebacks instead of giving a simple message to the user. The patch adds a proper management result when displaying informations of a non-existing validation. Change-Id: If7ef6eb53fe1de66a3a21424ed4e64318e680dd0 Signed-off-by: Gael Chamoulaud (Strider) (cherry picked from commit eb6839a7022b90873d5adc770413548b2b9b6c86) --- tripleoclient/v1/tripleo_validator.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tripleoclient/v1/tripleo_validator.py b/tripleoclient/v1/tripleo_validator.py index c6dca3a55..60ecdef39 100644 --- a/tripleoclient/v1/tripleo_validator.py +++ b/tripleoclient/v1/tripleo_validator.py @@ -93,13 +93,15 @@ class TripleOValidatorShow(command.ShowOne): def take_action(self, parsed_args): LOG.debug(_('Show validation result')) + actions = ValidationActions(constants.ANSIBLE_VALIDATION_DIR) + try: - actions = ValidationActions(constants.ANSIBLE_VALIDATION_DIR) data = actions.show_validations(parsed_args.validation_id) - return data.keys(), data.values() except Exception as e: - raise RuntimeError(_("Validations listing finished with errors\n" - "Output: {}").format(e)) + raise exceptions.CommandError(e) + + if data: + return data.keys(), data.values() class TripleOValidatorShowParameter(command.Command):