All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: "Fam Zheng" <fam@euphon.net>,
	berrange@redhat.com, "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel@nongnu.org, "Gerd Hoffmann" <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/5] docker.py: add podman support
Date: Thu, 11 Jul 2019 16:52:56 +0100	[thread overview]
Message-ID: <877e8oeffr.fsf@zen.linaroharston> (raw)
In-Reply-To: <20190709194330.837-2-marcandre.lureau@redhat.com>


Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> Add a --engine option to select either docker, podman or auto.
>
> Among other advantages, podman allows to run rootless & daemonless
> containers, fortunately sharing compatible CLI with docker.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Acked-by: Alex Bennée <alex.bennee@linaro.org>

podman doesn't seem to be widely packaged as of yet so I can't test it
on any of my systems.

> ---
>  tests/docker/docker.py | 43 +++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 38 insertions(+), 5 deletions(-)
>
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 53a8c9c801..1f59a78b10 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -20,6 +20,7 @@ import hashlib
>  import atexit
>  import uuid
>  import argparse
> +import enum
>  import tempfile
>  import re
>  import signal
> @@ -38,6 +39,26 @@ FILTERED_ENV_NAMES = ['ftp_proxy', 'http_proxy', 'https_proxy']
>
>  DEVNULL = open(os.devnull, 'wb')
>
> +class EngineEnum(enum.IntEnum):
> +    AUTO = 1
> +    DOCKER = 2
> +    PODMAN = 3
> +
> +    def __str__(self):
> +        return self.name.lower()
> +
> +    def __repr__(self):
> +        return str(self)
> +
> +    @staticmethod
> +    def argparse(s):
> +        try:
> +            return EngineEnum[s.upper()]
> +        except KeyError:
> +            return s
> +
> +
> +USE_ENGINE = EngineEnum.AUTO
>
>  def _text_checksum(text):
>      """Calculate a digest string unique to the text content"""
> @@ -48,9 +69,14 @@ def _file_checksum(filename):
>      return _text_checksum(open(filename, 'rb').read())
>
>
> -def _guess_docker_command():
> -    """ Guess a working docker command or raise exception if not found"""
> -    commands = [["docker"], ["sudo", "-n", "docker"]]
> +def _guess_engine_command():
> +    """ Guess a working engine command or raise exception if not found"""
> +    commands = []
> +
> +    if USE_ENGINE in [EngineEnum.AUTO, EngineEnum.PODMAN]:
> +        commands += [["podman"]]
> +    if USE_ENGINE in [EngineEnum.AUTO, EngineEnum.DOCKER]:
> +        commands += [["docker"], ["sudo", "-n", "docker"]]
>      for cmd in commands:
>          try:
>              # docker version will return the client details in stdout
> @@ -61,7 +87,7 @@ def _guess_docker_command():
>          except OSError:
>              pass
>      commands_txt = "\n".join(["  " + " ".join(x) for x in commands])
> -    raise Exception("Cannot find working docker command. Tried:\n%s" %
> +    raise Exception("Cannot find working engine command. Tried:\n%s" %
>                      commands_txt)
>
>
> @@ -190,7 +216,7 @@ def _dockerfile_preprocess(df):
>  class Docker(object):
>      """ Running Docker commands """
>      def __init__(self):
> -        self._command = _guess_docker_command()
> +        self._command = _guess_engine_command()
>          self._instances = []
>          atexit.register(self._kill_instances)
>          signal.signal(signal.SIGTERM, self._kill_instances)
> @@ -502,6 +528,8 @@ class ProbeCommand(SubCommand):
>                  print("yes")
>              elif docker._command[0] == "sudo":
>                  print("sudo")
> +            elif docker._command[0] == "podman":
> +                print("podman")
>          except Exception:
>              print("no")
>
> @@ -597,9 +625,13 @@ class CheckCommand(SubCommand):
>
>
>  def main():
> +    global USE_ENGINE
> +
>      parser = argparse.ArgumentParser(description="A Docker helper",
>                                       usage="%s <subcommand> ..." %
>                                       os.path.basename(sys.argv[0]))
> +    parser.add_argument("--engine", type=EngineEnum.argparse, choices=list(EngineEnum),
> +                        help="specify which container engine to use")
>      subparsers = parser.add_subparsers(title="subcommands", help=None)
>      for cls in SubCommand.__subclasses__():
>          cmd = cls()
> @@ -608,6 +640,7 @@ def main():
>          cmd.args(subp)
>          subp.set_defaults(cmdobj=cmd)
>      args, argv = parser.parse_known_args()
> +    USE_ENGINE = args.engine
>      return args.cmdobj.run(args, argv)


--
Alex Bennée


  reply	other threads:[~2019-07-11 15:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09 19:43 [Qemu-devel] [PATCH v2 0/5] tests/docker: add podman support Marc-André Lureau
2019-07-09 19:43 ` [Qemu-devel] [PATCH v2 1/5] docker.py: " Marc-André Lureau
2019-07-11 15:52   ` Alex Bennée [this message]
2019-07-09 19:43 ` [Qemu-devel] [PATCH v2 2/5] tests/docker: " Marc-André Lureau
2019-07-10  8:27   ` Paolo Bonzini
2019-07-10  8:39     ` Marc-André Lureau
2019-07-10  9:44       ` Paolo Bonzini
2019-07-11 15:55         ` Alex Bennée
2019-07-17 15:44       ` Debarshi Ray
2019-07-17 15:17   ` Debarshi Ray
2019-07-09 19:43 ` [Qemu-devel] [PATCH v2 3/5] tests: specify the address family when checking bind Marc-André Lureau
2019-07-10 10:12   ` Philippe Mathieu-Daudé
2019-07-09 19:43 ` [Qemu-devel] [PATCH v2 4/5] test-char: skip tcp tests if ipv4 check failed Marc-André Lureau
2019-07-09 19:43 ` [Qemu-devel] [PATCH v2 5/5] test: skip tests if socket_check_protocol_support() failed Marc-André Lureau
2019-07-09 23:39 ` [Qemu-devel] [PATCH v2 0/5] tests/docker: add podman support no-reply

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=877e8oeffr.fsf@zen.linaroharston \
    --to=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=fam@euphon.net \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.