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: Wainer dos Santos Moschetta
Subject: Re: [PATCH v2 12/25] tests/docker: add script for automating container refresh
Date: Fri, 15 Jan 2021 17:35:11 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0

Hi,

On 1/14/21 10:02 AM, 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

My suggestion is to rename the file to gen_dockerfiles.py and move to the parent directory.

To the best of my knowledge this community isn't picky about the style of Python code but if you run pylint you gonna see some warns worth a fix (mostly about bad indentation).

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

Shouldn't we document somewhere else the use of this tool in QEMU? For those who don't know its purpose, how it can be installed/extended, etc... maybe having a README under tests/docker or just appending some words on "Docker based tests" section from docs/devel/testing.rst?

- Wainer

+#
+# 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
+except Exception as ex:
+   print(str(ex), file=sys.stderr)




reply via email to

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