From 07e56863b9e12eefbe3f486076e4b4ba32b3bcc5 Mon Sep 17 00:00:00 2001 From: Mathieu Bultel Date: Mon, 9 Mar 2020 14:44:24 +0100 Subject: [PATCH] remove untested get_result functions from this PR --- validations_libs/utils.py | 81 --------------------------------------- 1 file changed, 81 deletions(-) diff --git a/validations_libs/utils.py b/validations_libs/utils.py index 739f2f2e..9b39dc03 100644 --- a/validations_libs/utils.py +++ b/validations_libs/utils.py @@ -21,7 +21,6 @@ import shutil import tempfile import yaml -#from prettytable import PrettyTable from validations_libs import constants RED = "\033[1;31m" @@ -236,83 +235,3 @@ def get_new_validations_logs_on_disk(): ] return files - - -#def get_results(results): -# """Get validations results and return as PrettytTable format""" -# new_log_files = get_new_validations_logs_on_disk() - -# for i in new_log_files: -# val_id = "{}.yaml".format(i.split('_')[1]) -# for res in results: -# if res['validation'].get('validation_id') == val_id: -# res['validation']['logfile'] = \ -# os.path.join(constants.VALIDATIONS_LOG_BASEDIR, i) - -# t = PrettyTable(border=True, header=True, padding_width=1) -# t.field_names = [ -# "UUID", "Validations", "Status", "Host Group(s)", -# "Status by Host", "Unreachable Host(s)", "Duration"] - -# for validation in results: -# r = [] -# logfile = validation['validation'].get('logfile', None) -# if logfile and os.path.exists(logfile): -# with open(logfile, 'r') as val: -# contents = json.load(val) - -# for i in contents['plays']: -# host = [ -# x.encode('utf-8') -# for x in i['play'].get('host').split(', ') -# ] -# val_id = i['play'].get('validation_id') -# time_elapsed = \ -# i['play']['duration'].get('time_elapsed', None) - -# r.append(contents['plays'][0]['play'].get('id')) -# r.append(val_id) -# if validation['validation'].get('status') == "PASSED": -# r.append(PASSED_VALIDATION) -# else: -# r.append(FAILED_VALIDATION) - -# unreachable_hosts = [] -# hosts_result = [] -# for h in list(contents['stats'].keys()): -# ht = h.encode('utf-8') -# if contents['stats'][ht]['unreachable'] != 0: -# unreachable_hosts.append(ht) -# elif contents['stats'][ht]['failures'] != 0: -# hosts_result.append("{}{}{}".format( -# RED, ht, RESET)) -# else: -# hosts_result.append("{}{}{}".format( -# GREEN, ht, RESET)) - -# r.append(", ".join(host)) -# r.append(", ".join(hosts_result)) -# r.append("{}{}{}".format(RED, -# ", ".join(unreachable_hosts), -# RESET)) -# r.append(time_elapsed) -# t.add_row(r) - -# t.sortby = "UUID" -# for field in t.field_names: -# if field == "Status": -# t.align['Status'] = "l" -# else: -# t.align[field] = "l" - -# print(t) - -# if len(new_log_files) > len(results): -# LOG.warn('Looks like we have more log files than ' -# 'executed validations') - -# for i in new_log_files: -# os.rename( -# "{}/{}".format(constants.VALIDATIONS_LOG_BASEDIR, -# i), "{}/processed_{}".format( -# constants.VALIDATIONS_LOG_BASEDIR, i))