Browse Source

Merge "Expansion of logging for the show action."

changes/93/795093/8
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
2dc6b358f5
2 changed files with 33 additions and 4 deletions
  1. +7
    -0
      validations_libs/utils.py
  2. +26
    -4
      validations_libs/validation_logs.py

+ 7
- 0
validations_libs/utils.py View File

@ -274,6 +274,13 @@ def get_validations_data(validation, path=constants.ANSIBLE_VALIDATION_DIR):
data = {}
val_path = "{}/{}.yaml".format(path, validation)
LOG.debug(
"Obtaining information about validation {} from {}".format(
validation,
val_path)
)
if os.path.exists(val_path):
val = Validation(val_path)
data.update(val.get_formated_data)


+ 26
- 4
validations_libs/validation_logs.py View File

@ -328,6 +328,11 @@ class ValidationLogs(object):
"""
log_files = glob.glob("{}/*_{}_*".format(self.logs_path,
validation_id))
LOG.debug(
"Getting log file for validation {} from {}.".format(
validation_id,
log_files)
)
return [self._get_content(log) for log in log_files]
def get_logfile_by_uuid(self, uuid):
@ -417,12 +422,25 @@ class ValidationLogs(object):
"""
if not isinstance(logs, list):
logs = [logs]
LOG.debug(
("`get_validations_stats` received `logs` argument "
"of type {} but it expects a list. "
"Attempting to resolve.").format(
type(logs))
)
# Get validation stats
total_number = len(logs)
failed_number = 0
passed_number = 0
last_execution = None
dates = []
LOG.debug(
"Retreiving {} validation stats.".format(total_number)
)
for log in logs:
if log.get('validation_output'):
failed_number += 1
@ -439,11 +457,15 @@ class ValidationLogs(object):
if dates:
last_execution = time.strftime('%Y-%m-%d %H:%M:%S', max(dates))
execution_stats = "Total: {}, Passed: {}, Failed: {}".format(
total_number,
passed_number,
failed_number)
LOG.debug(execution_stats)
return {"Last execution date": last_execution,
"Number of execution": "Total: {}, Passed: {}, "
"Failed: {}".format(total_number,
passed_number,
failed_number)}
"Number of execution": execution_stats}
def get_results(self, uuid, validation_id=None):
"""Return a list of validation results by uuid


Loading…
Cancel
Save