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 95898bff35)
This commit is contained in:
Mathieu Bultel 2020-06-16 23:59:33 +02:00 committed by Gael Chamoulaud (Strider)
parent 81bc1fc95f
commit 27b4c19928
No known key found for this signature in database
GPG Key ID: 4119D0305C651D66
1 changed files with 48 additions and 0 deletions

View File

@ -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)