From 582d31dacfa11c7cc4ff5fd63809fc3700b0239f Mon Sep 17 00:00:00 2001 From: Mathieu Bultel Date: Thu, 5 Mar 2020 17:29:12 +0100 Subject: [PATCH] add validations logs path cache --- validations_libs/ansible.py | 4 +++- validations_libs/constants.py | 4 ++-- validations_libs/run.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/validations_libs/ansible.py b/validations_libs/ansible.py index 71671ebb..38b81fc8 100644 --- a/validations_libs/ansible.py +++ b/validations_libs/ansible.py @@ -20,6 +20,7 @@ import os import six import sys import tempfile +import uuid import yaml from six.moves import configparser @@ -297,7 +298,8 @@ class Ansible(object): command_path = None - with utils.TempDirs(chdir=False) as ansible_artifact_path: + with utils.TempDirs(dir_path=constants.VALIDATION_RUN_LOG_PATH, + chdir=False,) as ansible_artifact_path: if 'ANSIBLE_CONFIG' not in env and not ansible_cfg: ansible_cfg = os.path.join(ansible_artifact_path, 'ansible.cfg') config = configparser.ConfigParser() diff --git a/validations_libs/constants.py b/validations_libs/constants.py index 67231897..be27233e 100644 --- a/validations_libs/constants.py +++ b/validations_libs/constants.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. # - - DEFAULT_VALIDATIONS_BASEDIR = '/usr/share/validations-common' ANSIBLE_VALIDATION_DIR = '/usr/share/validations-common/playbooks' @@ -23,3 +21,5 @@ VALIDATION_GROUPS_INFO = '%s/groups.yaml' % DEFAULT_VALIDATIONS_BASEDIR VALIDATION_GROUPS = ['no-op', 'prep', 'post'] + +VALIDATION_RUN_LOG_PATH = '/var/lib/validations/logs' diff --git a/validations_libs/run.py b/validations_libs/run.py index 81ec611e..5569cfec 100644 --- a/validations_libs/run.py +++ b/validations_libs/run.py @@ -32,7 +32,7 @@ class Run(object): def run_validations(self, playbook, inventory, group=None, extra_vars=None, validations_dir=None, validation_name=None, extra_env_var=None, - ansible_cfg=None): + ansible_cfg=None, quiet=True): self.log = logging.getLogger(__name__ + ".run_validations") @@ -71,7 +71,7 @@ class Run(object): parallel_run=True, inventory=inventory, output_callback='validation_json', - quiet=True, + quiet=quiet, extra_vars=extra_vars, extra_env_variables=extra_env_var, ansible_cfg=ansible_cfg,