[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)
This commit is contained in:
Gael Chamoulaud (Strider) 2020-10-15 13:46:54 +02:00
parent 4137c0ea49
commit 21d8e7c2c9
No known key found for this signature in database
GPG Key ID: 4119D0305C651D66
1 changed files with 10 additions and 0 deletions

View File

@ -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
@ -317,6 +318,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: