Conditionally decode hosts

TripleO was using python2 up to stable/train. This means we can
.decode() strings, which we did with hosts for hostnames. With python3,
we no longer need to do this and tripleo master is using python3.
Instead, we need to detect this case and handle it appropriately.

Change-Id: Icc211f5b685ec9df06cd25d6af3b28a5db4df590
This commit is contained in:
Lance Bragstad 2020-04-21 18:59:36 +00:00
parent 668d971ceb
commit d2e3b35c02
1 changed files with 4 additions and 1 deletions

View File

@ -346,7 +346,10 @@ def cleanup_ipa_services(keytab, hosts):
hosts_to_delete = set()
for host in hosts:
hostname = host.decode('UTF-8')
if six.PY3:
hostname = host
else:
hostname = host.decode('UTF-8')
if ipa.find_host(hostname):
hosts_to_delete.add(hostname)