On Tue, 2011-06-28 at 17:45 +0800, Qingtang Zhou wrote:
> This patch will save guest's anaconda log to 'anaconda.log' in debug
> directory.
>
> Signed-off-by: Qingtang Zhou <[email protected]>
> ---
> 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)
^ Here we have a try/except/finally block, which is illegal in py 2.4.
This needs to be fixed.
> + 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"
^ In case get_anaconda_log is not defined for that specific variant,
better to make it default to 'no', so it'd be something like:
get_anaconda_log = params.get("get_anaconda_log", "no") == "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
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest