ipatests: Fix on logs collection

If the function `install_kra` or `install_ca` fails
on call `host.run_command(command, raiseonerr=raiseonerr)`
then the logs are not collected.

This situation is not optimal because we need to see what happend
during the debbuging the tests.

So, this patch solves this situation and it adds try--finally
construction.

https://pagure.io/freeipa/issue/7214

Reviewed-By: Tibor Dudlak <tdudlak@redhat.com>
This commit is contained in:
Petr Čech 2017-10-16 13:13:32 +02:00 committed by Tibor Dudlák
parent 49cf5ec64b
commit 3a0410267f

View File

@ -1163,8 +1163,10 @@ def install_kra(host, domain_level=None, first_instance=False, raiseonerr=True):
if domain_level == DOMAIN_LEVEL_0 and not first_instance:
replica_file = get_replica_filename(host)
command.append(replica_file)
result = host.run_command(command, raiseonerr=raiseonerr)
setup_server_logs_collecting(host)
try:
result = host.run_command(command, raiseonerr=raiseonerr)
finally:
setup_server_logs_collecting(host)
return result
@ -1184,8 +1186,10 @@ def install_ca(host, domain_level=None, first_instance=False,
if cert_files:
for fname in cert_files:
command.extend(['--external-cert-file', fname])
result = host.run_command(command, raiseonerr=raiseonerr)
setup_server_logs_collecting(host)
try:
result = host.run_command(command, raiseonerr=raiseonerr)
finally:
setup_server_logs_collecting(host)
return result