From d58ea5bbb0294de85c4e50e62322ade0d8b962d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Wed, 24 Jun 2020 08:19:38 +0200 Subject: [PATCH] [TRAIN ONLY] Do not encode hostnames in validation result Encoding the names to utf-8 leads to unwanted failures such as: KeyError: b'undercloud' as well as TypeError: sequence item 0: expected str instance, bytes found Removing the two calls to .encode() solves those issues. It also correct a tiny deprecation warning, moving from LOG.warn to LOG.warning. This is a train-only patch since later the whole thing was moved out of tripleoclient in favor of validations-libs and/or validations-common. Change-Id: Ie1530321b488bef11692553ea25131d9360763dd --- tripleoclient/v1/tripleo_validator.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tripleoclient/v1/tripleo_validator.py b/tripleoclient/v1/tripleo_validator.py index 19855311e..564d9c65b 100644 --- a/tripleoclient/v1/tripleo_validator.py +++ b/tripleoclient/v1/tripleo_validator.py @@ -547,8 +547,7 @@ class TripleOValidatorRun(command.Command): for i in contents['plays']: host = [ - x.encode('utf-8') - for x in i['play'].get('host').split(', ') + x for x in i['play'].get('host').split(', ') ] val_id = i['play'].get('validation_id') time_elapsed = \ @@ -563,8 +562,7 @@ class TripleOValidatorRun(command.Command): unreachable_hosts = [] hosts_result = [] - for h in list(contents['stats'].keys()): - ht = h.encode('utf-8') + for ht in list(contents['stats'].keys()): if contents['stats'][ht]['unreachable'] != 0: unreachable_hosts.append(ht) elif contents['stats'][ht]['failures'] != 0: @@ -592,8 +590,8 @@ class TripleOValidatorRun(command.Command): print(t) if len(new_log_files) > len(results): - LOG.warn(_('Looks like we have more log files than ' - 'executed validations')) + LOG.warning(_('Looks like we have more log files than ' + 'executed validations')) for i in new_log_files: os.rename(