runner: implement container_exist

On podman, we can run "podman container exists" command to check if
whether or not a container does exist.

This will be used later when we'll reduce our usage of "podman inspect".

Change-Id: I6dfbfe9da3d216cadaca77a53a0d5223c9cbd57d
This commit is contained in:
Emilien Macchi
2019-06-17 14:13:49 -04:00
parent 43468616c8
commit 277eb726b9
2 changed files with 20 additions and 0 deletions

View File

@@ -273,6 +273,11 @@ class DockerRunner(BaseRunner):
"by %s" % self.cont_cmd)
return True
def container_exist(self, name, quiet=False):
self.log.warning("container_exist isn't supported "
"by %s" % self.cont_cmd)
return True
class PodmanRunner(BaseRunner):
@@ -342,3 +347,8 @@ class PodmanRunner(BaseRunner):
cmd = ['podman', 'image', 'exists', name]
(_, _, returncode) = self.execute(cmd, self.log, quiet)
return returncode == 0
def container_exist(self, name, quiet=False):
cmd = ['podman', 'container', 'exists', name]
(_, _, returncode) = self.execute(cmd, self.log, quiet)
return returncode == 0