From a28892df4fdf511500d919c6a882dc83ef24f837 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 8 Mar 2018 12:18:06 -0500 Subject: [PATCH] docker-puppet.py: don't pull if image exists This updates the pull function here so that it matches how paunch also handle's images, only pulling them if the existing image doesn't already exist on the host. Change-Id: I90ea41ccdfdb0b9206a63901554d002a5ec0fd3a --- docker/docker-puppet.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docker/docker-puppet.py b/docker/docker-puppet.py index 599ed14b4b..2605b8581d 100755 --- a/docker/docker-puppet.py +++ b/docker/docker-puppet.py @@ -59,9 +59,19 @@ def short_hostname(): def pull_image(name): - log.info('Pulling image: %s' % name) + + subproc = subprocess.Popen(['/usr/bin/docker', 'inspect', name], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + cmd_stdout, cmd_stderr = subproc.communicate() + retval = subproc.returncode + if retval == 0: + log.info('Image already exists: %s' % name) + return + retval = -1 count = 0 + log.info('Pulling image: %s' % name) while retval != 0: count += 1 subproc = subprocess.Popen(['/usr/bin/docker', 'pull', name],