From c13638dcb183fdf54ed6a4150df6c13dac361bb3 Mon Sep 17 00:00:00 2001 From: "Gael Chamoulaud (Strider)" Date: Thu, 14 Oct 2021 13:00:24 +0200 Subject: [PATCH] [stable/train] Add support for the validations skip list feature This patch adds a new --skiplist argument to the run sub command. This feature allows the operator to provide a file with a list of Validations to skip via the run sub command. More details could be found in the official validations-libs documentation [1]. PS: To avoid requirements and upper constraints headache, this patch will not use validations_libs.cli.common.read_cli_data_file() coming from recent validations-libs release but the skip list file will be open and read directly in the tripleo_validator.py. Depends-On: https://review.opendev.org/c/openstack/validations-libs/+/809289 [1] - https://docs.openstack.org/validations-libs/latest/readme.html#skip-list Signed-off-by: Gael Chamoulaud (Strider) Change-Id: Ibe6d56fc4eea93ab333fab237aa22e554fc245f3 (cherry picked from commit b7e50a9a157e300142ad6409b0806937eda33819) (cherry picked from commit 70883be45ea5b160f0d19c09fe8a887414997481) --- tripleoclient/v1/tripleo_validator.py | 29 ++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tripleoclient/v1/tripleo_validator.py b/tripleoclient/v1/tripleo_validator.py index ce25cfb51..e85c6e4d6 100644 --- a/tripleoclient/v1/tripleo_validator.py +++ b/tripleoclient/v1/tripleo_validator.py @@ -275,6 +275,18 @@ class TripleOValidatorRun(command.Command): ) ) + parser.add_argument( + '--skiplist', + dest='skip_list', + default=None, + help=_( + "Path where the skip list is stored. " + "An example of the skiplist format could " + "be found at the root of the " + "validations-libs repository." + ) + ) + extra_vars_group = parser.add_mutually_exclusive_group(required=False) extra_vars_group.add_argument( @@ -414,6 +426,20 @@ class TripleOValidatorRun(command.Command): undercloud_connection='local', return_inventory_file_path=True) + skip_list = None + if parsed_args.skip_list: + try: + with open(parsed_args.skip_list, 'r') as _file: + skip_list = yaml.safe_load(_file.read()) + except (yaml.YAMLError, IOError) as error: + error_msg = ( + "The file {} must be properly formatted YAML/JSON." + "Details: {}.").format(parsed_args.skip_list, error) + raise RuntimeError(error_msg) + + if not isinstance(skip_list, dict): + raise RuntimeError("Wrong format for the skiplist.") + v_consts.DEFAULT_VALIDATIONS_BASEDIR = constants.\ DEFAULT_VALIDATIONS_BASEDIR actions = ValidationActions() @@ -427,7 +453,8 @@ class TripleOValidatorRun(command.Command): validation_name=parsed_args.validation_name, extra_env_vars=extra_env_vars, python_interpreter=parsed_args.python_interpreter, - quiet=quiet_mode) + quiet=quiet_mode, + skip_list=skip_list) except RuntimeError as e: raise exceptions.CommandError(e)