From ba784b5a31ba5ef5e581f06eff682085babc66a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Thu, 21 Feb 2019 19:34:16 +0100 Subject: [PATCH] virttest.virt_vm: Attempt to log useful data on login failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a hackish way of attempting to log useful data on login failure. Signed-off-by: Lukáš Doktor --- virttest/virt_vm.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/virttest/virt_vm.py b/virttest/virt_vm.py index 5f18ed9a85..20a3988f55 100644 --- a/virttest/virt_vm.py +++ b/virttest/virt_vm.py @@ -1190,6 +1190,19 @@ def print_guest_network_info(): return self.wait_for_serial_login(timeout, internal_timeout, False, username, password) + # Attempt to log useful data + try: + session = self.wait_for_serial_login(timeout, internal_timeout, + False, username, password) + session.sendline("echo Login failed, dumping useful logs...") + session.sendline("echo /var/log/messages") + session.sendline("cat /var/log/messages") + session.sendline("echo journalctl") + session.cmd_status("journalctl | cat") + session.close() + except Exception: + pass + raise remote.LoginTimeoutError("exceeded %s s timeout, last " "failure: %s" % (timeout, error))