diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-11-13 15:00:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 15:00:01 +0100 |
commit | 0b1a60ec27928a40ac827148c1517098612616bd (patch) | |
tree | b3902b4614cb521c9873d3200d7f073a135d6308 /test/python/docker/common.py | |
parent | 0b3f789a08787c3b2d832a405f6d2d6ff90f5720 (diff) | |
parent | a1187ee6f3a85f8d4e68717731b7b9e2163e8f25 (diff) | |
download | podman-0b1a60ec27928a40ac827148c1517098612616bd.tar.gz podman-0b1a60ec27928a40ac827148c1517098612616bd.tar.bz2 podman-0b1a60ec27928a40ac827148c1517098612616bd.zip |
Merge pull request #8308 from jwhonce/jira/run-976
Refactor to use DockerClient vs APIClient
Diffstat (limited to 'test/python/docker/common.py')
-rw-r--r-- | test/python/docker/common.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/test/python/docker/common.py b/test/python/docker/common.py index 2828d2d20..e79d64a9b 100644 --- a/test/python/docker/common.py +++ b/test/python/docker/common.py @@ -1,21 +1,23 @@ -from docker import APIClient +from docker import DockerClient from test.python.docker import constant -def run_top_container(client: APIClient): - c = client.create_container( +def run_top_container(client: DockerClient): + c = client.containers.create( constant.ALPINE, command="top", detach=True, tty=True, name="top" ) - client.start(c.get("Id")) - return c.get("Id") + c.start() + return c.id -def remove_all_containers(client: APIClient): - for ctnr in client.containers(quiet=True): - client.remove_container(ctnr, force=True) +def remove_all_containers(client: DockerClient): + for ctnr in client.containers.list(all=True): + ctnr.remove(force=True) -def remove_all_images(client: APIClient): - for image in client.images(quiet=True): - client.remove_image(image, force=True) +def remove_all_images(client: DockerClient): + for img in client.images.list(): + # FIXME should DELETE /images accept the sha256: prefix? + id_ = img.id.removeprefix("sha256:") + client.images.remove(id_, force=True) |