[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) <gchamoul@redhat.com>
(cherry picked from commit da8a3e5964)
(cherry picked from commit cd789148ef)
This commit is contained in:
Gael Chamoulaud (Strider) 2020-10-15 13:46:54 +02:00 committed by Mathieu Bultel
parent 7f001ff7b6
commit 3eef4f4539
1 changed files with 10 additions and 0 deletions

View File

@ -26,6 +26,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
@ -333,6 +334,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: