Expansion of logging for the show action.

New logging calls on the debug level.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I3b2f0bfaa9d92e9cc664dea8ba5f7966c6931837
This commit is contained in:
Jiri Podivin 2021-05-12 14:29:35 +02:00 committed by Gael Chamoulaud
parent 0f00fd79f9
commit eb439a35db
2 changed files with 33 additions and 4 deletions

View File

@ -247,6 +247,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)

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