All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: Qingtang Zhou <qzhou@redhat.com>
Cc: autotest@test.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH 2/3] KVM-Test: unattended_install.py: Get anaconda log and save it to log file
Date: Tue, 05 Jul 2011 12:56:00 -0300	[thread overview]
Message-ID: <1309881362.6594.35.camel@freedom> (raw)
In-Reply-To: <1309254319-30182-1-git-send-email-qzhou@redhat.com>

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 <qzhou@redhat.com>
> ---
>  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

  reply	other threads:[~2011-07-05 15:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-28  9:44 [PATCH 1/3] KVM-Test: kickstart script: Add pre-installation script for dumping anaconda log Qingtang Zhou
2011-06-28  9:45 ` [PATCH 2/3] KVM-Test: unattended_install.py: Get anaconda log and save it to log file Qingtang Zhou
2011-07-05 15:56   ` Lucas Meneghel Rodrigues [this message]
2011-06-28  9:45 ` [PATCH 3/3] KVM Test: Add get anaconda log config in config file Qingtang Zhou
2011-07-05 15:54 ` [Autotest] [PATCH 1/3] KVM-Test: kickstart script: Add pre-installation script for dumping anaconda log Lucas Meneghel Rodrigues
2011-07-07  5:50   ` Qingtang Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1309881362.6594.35.camel@freedom \
    --to=lmr@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=qzhou@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.