[PATCH 2/3] KVM-Test: unattended_install.py: Get anaconda log and save it to log file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch will save guest's anaconda log to 'anaconda.log' in debug directory.

Signed-off-by: Qingtang Zhou <qzhou@xxxxxxxxxx>
---
 client/tests/kvm/tests/unattended_install.py |   31 ++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/tests/unattended_install.py b/client/tests/kvm/tests/unattended_install.py
index 50a8c7a..d631404 100644
--- a/client/tests/kvm/tests/unattended_install.py
+++ b/client/tests/kvm/tests/unattended_install.py
@@ -494,6 +494,28 @@ class UnattendedInstallConfig(object):
             raise ValueError("Unexpected installation method %s" %
                              self.medium)
 
+def _get_anaconda_log(vm, log_file):
+    port = int(vm.params.get("guest_port_unattended_install")) - 1
+    port = vm.get_port(port)
+
+    anaconda_logfile = open(log_file, 'w')
+
+    while True:
+        client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        try:
+            client.connect((vm.get_address(), port))
+            install_log = client.recv(10240)
+            if install_log != "":
+                anaconda_logfile.write(install_log)
+                anaconda_logfile.flush()
+                client.send("ok %s\n" % str(time.time()))
+        except (socket.error, virt_vm.VMAddressError):
+            pass
+        finally:
+            client.close()
+        time.sleep(1)
+
+    anaconda_logfile.close()
 
 @error.context_aware
 def run_unattended_install(test, params, env):
@@ -524,6 +546,13 @@ def run_unattended_install(test, params, env):
                  "(%d min)", install_timeout, install_timeout/60)
     error.context("waiting for installation to finish")
 
+    get_anaconda_log = params.get("get_anaconda_log") == "yes"
+    if get_anaconda_log:
+        log_file = os.path.join(test.debugdir, "anaconda.log")
+        bg = virt_utils.Thread(_get_anaconda_log,
+                            kwargs={"vm": vm, "log_file": log_file})
+        bg.start()
+
     start_time = time.time()
     while (time.time() - start_time) < install_timeout:
         try:
@@ -539,6 +568,8 @@ def run_unattended_install(test, params, env):
             try:
                 client.connect((vm.get_address(), port))
                 if client.recv(1024) == "done":
+                    if get_anaconda_log:
+                        bg.join()
                     break
             except (socket.error, virt_vm.VMAddressError):
                 pass
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux