Merge "Expansion of logging for the show action."
This commit is contained in:
commit
2dc6b358f5
|
@ -274,6 +274,13 @@ def get_validations_data(validation, path=constants.ANSIBLE_VALIDATION_DIR):
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
val_path = "{}/{}.yaml".format(path, validation)
|
val_path = "{}/{}.yaml".format(path, validation)
|
||||||
|
|
||||||
|
LOG.debug(
|
||||||
|
"Obtaining information about validation {} from {}".format(
|
||||||
|
validation,
|
||||||
|
val_path)
|
||||||
|
)
|
||||||
|
|
||||||
if os.path.exists(val_path):
|
if os.path.exists(val_path):
|
||||||
val = Validation(val_path)
|
val = Validation(val_path)
|
||||||
data.update(val.get_formated_data)
|
data.update(val.get_formated_data)
|
||||||
|
|
|
@ -328,6 +328,11 @@ class ValidationLogs(object):
|
||||||
"""
|
"""
|
||||||
log_files = glob.glob("{}/*_{}_*".format(self.logs_path,
|
log_files = glob.glob("{}/*_{}_*".format(self.logs_path,
|
||||||
validation_id))
|
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]
|
return [self._get_content(log) for log in log_files]
|
||||||
|
|
||||||
def get_logfile_by_uuid(self, uuid):
|
def get_logfile_by_uuid(self, uuid):
|
||||||
|
@ -417,12 +422,25 @@ class ValidationLogs(object):
|
||||||
"""
|
"""
|
||||||
if not isinstance(logs, list):
|
if not isinstance(logs, list):
|
||||||
logs = [logs]
|
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
|
# Get validation stats
|
||||||
total_number = len(logs)
|
total_number = len(logs)
|
||||||
failed_number = 0
|
failed_number = 0
|
||||||
passed_number = 0
|
passed_number = 0
|
||||||
last_execution = None
|
last_execution = None
|
||||||
dates = []
|
dates = []
|
||||||
|
|
||||||
|
LOG.debug(
|
||||||
|
"Retreiving {} validation stats.".format(total_number)
|
||||||
|
)
|
||||||
|
|
||||||
for log in logs:
|
for log in logs:
|
||||||
if log.get('validation_output'):
|
if log.get('validation_output'):
|
||||||
failed_number += 1
|
failed_number += 1
|
||||||
|
@ -439,11 +457,15 @@ class ValidationLogs(object):
|
||||||
if dates:
|
if dates:
|
||||||
last_execution = time.strftime('%Y-%m-%d %H:%M:%S', max(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,
|
return {"Last execution date": last_execution,
|
||||||
"Number of execution": "Total: {}, Passed: {}, "
|
"Number of execution": execution_stats}
|
||||||
"Failed: {}".format(total_number,
|
|
||||||
passed_number,
|
|
||||||
failed_number)}
|
|
||||||
|
|
||||||
def get_results(self, uuid, validation_id=None):
|
def get_results(self, uuid, validation_id=None):
|
||||||
"""Return a list of validation results by uuid
|
"""Return a list of validation results by uuid
|
||||||
|
|
Loading…
Reference in New Issue