qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2 12/25] tests/docker: add script for automating container r


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 12/25] tests/docker: add script for automating container refresh
Date: Thu, 14 Jan 2021 14:31:23 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 1/14/21 2:02 PM, Daniel P. Berrangé wrote:
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  tests/docker/dockerfiles/refresh | 53 ++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
>  create mode 100755 tests/docker/dockerfiles/refresh
> 
> diff --git a/tests/docker/dockerfiles/refresh 
> b/tests/docker/dockerfiles/refresh
> new file mode 100755
> index 0000000000..b1d99963e9
> --- /dev/null
> +++ b/tests/docker/dockerfiles/refresh
> @@ -0,0 +1,53 @@
> +#!/usr/bin/python3
> +#
> +# Re-generate container recipes
> +#
> +# This script uses the "lcitool" available from
> +#
> +#   https://gitlab.com/libvirt/libvirt-ci
> +#
> +# Copyright (c) 2020 Red Hat Inc.
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2
> +# or (at your option) any later version. See the COPYING file in
> +# the top-level directory.
> +
> +import sys
> +import os
> +import subprocess
> +
> +if len(sys.argv) != 2:
> +   print("syntax: %s PATH-TO-LCITOOL" % sys.argv[0], file=sys.stderr)
> +   sys.exit(1)
> +
> +lcitool_path=sys.argv[1]
> +
> +def atomic_write(filename, content):
> +   try:
> +      with open(filename + ".tmp", "w") as fp:
> +         print(content, file=fp, end="")
> +         os.replace(filename + ".tmp", filename)
> +   except Exception as ex:
> +      os.unlink(filename + ".tmp")
> +      raise
> +
> +def generate_image(filename, host, cross=None, trailer=None):
> +   print("Generate %s" % filename)
> +   args = [lcitool_path, "dockerfile"]
> +   if cross is not None:
> +      args.extend(["--cross", cross])
> +   args.extend([host, "qemu"])
> +   lcitool=subprocess.run(args, capture_output=True)
> +
> +   if lcitool.returncode != 0:
> +      raise Exception("Failed to generate %s: %s" % (filename, 
> lcitool.stderr))
> +
> +   content = lcitool.stdout.decode("utf8")
> +   if trailer is not None:
> +      content += trailer
> +   atomic_write(filename, content)
> +
> +try:
> +   pass

This code would be easier to understand if you place this
patch before the "tests/docker: auto-generate ..." ones,
and add a comment (or directly add these 3 lines in the
first "auto-generate" patch).

Otherwise:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> +except Exception as ex:
> +   print(str(ex), file=sys.stderr)
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]