From cd789148efdd96132fe9f68239eb6702695c2918 Mon Sep 17 00:00:00 2001 From: "Gael Chamoulaud (Strider)" Date: Thu, 15 Oct 2020 13:46:54 +0200 Subject: [PATCH] [Validator Run] Ensure the plan really exists This patch will now fetch all the existing plans and will ensure the plan given by the command line is part of it. If not, a exception will be raised to inform the user. Change-Id: If45db93e4e958fe0ae65bd2cd96d3594b97a4320 Signed-off-by: Gael Chamoulaud (Strider) (cherry picked from commit da8a3e59645b2b17a1b05dc1853d1d9fd7e7c424) --- tripleoclient/v1/tripleo_validator.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tripleoclient/v1/tripleo_validator.py b/tripleoclient/v1/tripleo_validator.py index 3c5c110c0..4d16f5cb7 100644 --- a/tripleoclient/v1/tripleo_validator.py +++ b/tripleoclient/v1/tripleo_validator.py @@ -25,6 +25,7 @@ from prettytable import PrettyTable from tripleoclient import command from tripleoclient import constants from tripleoclient import utils as oooutils +from tripleoclient.workflows import plan_management from validations_libs import constants as v_consts from validations_libs import utils as v_utils @@ -316,6 +317,15 @@ class TripleOValidatorRun(command.Command): def _run_validator_run(self, parsed_args): LOG = logging.getLogger(__name__ + ".ValidationsRunAnsible") + + clients = self.app.client_manager + plans = plan_management.list_deployment_plans(clients) + + if parsed_args.plan and parsed_args.plan not in plans: + raise exceptions.CommandError( + _("The plan '{}' doesn't exist. " + "Please use one of those {}".format(parsed_args, plans))) + limit = parsed_args.limit extra_vars = parsed_args.extra_vars if parsed_args.extra_vars_file: