From 3d7298092628b125762bf7cdcc976878857c8730 Mon Sep 17 00:00:00 2001 From: Mathieu Bultel Date: Tue, 16 Jun 2020 23:59:33 +0200 Subject: [PATCH] Add TripleO validation CLI script In order to run TripleO validations before any TripleO deployments, we need a simple cli as entry point for validations execution. This review just override the Validation cli in validations-common by provided TripleO specific path for validations Depends-On: https://review.opendev.org/#/c/735973/ Change-Id: Ic6d5ca2445b3285182ba6a1b12939fef4c2b3e61 (cherry picked from commit 95898bff35bf453cd81337bedd4462bce1afc301) (cherry picked from commit 27b4c199281f19148a1f6221535f33629b45e888) --- scripts/tripleo-validation.py | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 scripts/tripleo-validation.py diff --git a/scripts/tripleo-validation.py b/scripts/tripleo-validation.py new file mode 100644 index 000000000..b52d68fd4 --- /dev/null +++ b/scripts/tripleo-validation.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +# Copyright 2020 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import logging +from validations_common.validation import Validation + +TRIPLEO_VALIDATION_DIR = "/usr/share/openstack-tripleo-validations" + + +class TripleOValidation(Validation): + """TripleO Validation client implementation class""" + + log = logging.getLogger(__name__ + ".TripleOValidation") + + def parser(self, tripleo_parser): + """Argument parser for TripleO Validation""" + parser = super(TripleOValidation, self).parser(tripleo_parser) + # Check if user pass custom path for validation playbooks and + # Ansible directory. If not, we override the value with the default + # TripleO path. + for action in tripleo_parser._actions: + if action.dest == 'validation_dir': + if action.default == parser.validation_dir: + parser.validation_dir = "{}/playbooks".format( + TRIPLEO_VALIDATION_DIR) + if action.dest == 'ansible_base_dir': + if action.default == parser.ansible_base_dir: + parser.ansible_base_dir = TRIPLEO_VALIDATION_DIR + return parser + + +if __name__ == "__main__": + validation = TripleOValidation() + args = validation.parser(validation) + validation.take_action(args)