mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
fix ident, raise TaskError
This commit is contained in:
parent
99786539c7
commit
141e6399f3
1 changed files with 26 additions and 25 deletions
|
@ -76,30 +76,31 @@ class PullDockerImages(Task):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
images = info.manifest.plugins['docker_daemon'].get('pull_images', [])
|
from bootstrapvz.common.exceptions import TaskError
|
||||||
retries = info.manifest.plugins['docker_daemon'].get('pull_images_retries', 10)
|
images = info.manifest.plugins['docker_daemon'].get('pull_images', [])
|
||||||
|
retries = info.manifest.plugins['docker_daemon'].get('pull_images_retries', 10)
|
||||||
|
|
||||||
bin_docker = os.path.join(info.root, 'usr/bin/docker')
|
bin_docker = os.path.join(info.root, 'usr/bin/docker')
|
||||||
graph_dir = os.path.join(info.root, 'var/lib/docker')
|
graph_dir = os.path.join(info.root, 'var/lib/docker')
|
||||||
socket = 'unix://' + os.path.join(info.workspace, 'docker.sock')
|
socket = 'unix://' + os.path.join(info.workspace, 'docker.sock')
|
||||||
pidfile = os.path.join(info.workspace, 'docker.pid')
|
pidfile = os.path.join(info.workspace, 'docker.pid')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
daemon = subprocess.Popen([bin_docker, '-d', '--graph', graph_dir, '-H', socket, '-p', pidfile])
|
daemon = subprocess.Popen([bin_docker, '-d', '--graph', graph_dir, '-H', socket, '-p', pidfile])
|
||||||
for _ in range(retries):
|
for _ in range(retries):
|
||||||
if log_check_call([bin_docker, '-H', socket, 'version']) == 0:
|
if log_check_call([bin_docker, '-H', socket, 'version']) == 0:
|
||||||
break
|
break
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
for img in images:
|
for img in images:
|
||||||
if img.endswith('.tar.gz') or img.endswith('.tgz'):
|
if img.endswith('.tar.gz') or img.endswith('.tgz'):
|
||||||
cmd = [bin_docker, '-H', socket, 'load', '-i', img]
|
cmd = [bin_docker, '-H', socket, 'load', '-i', img]
|
||||||
if log_check_call(cmd) != 0:
|
if log_check_call(cmd) != 0:
|
||||||
msg = 'error loading docker image {img}.'.format(img=img)
|
msg = 'error loading docker image {img}.'.format(img=img)
|
||||||
raise Exception(msg)
|
raise TaskError(msg)
|
||||||
else: # regular docker image
|
else: # regular docker image
|
||||||
cmd = [bin_docker, '-H', socket, 'pull', img]
|
cmd = [bin_docker, '-H', socket, 'pull', img]
|
||||||
if log_check_call(cmd) != 0:
|
if log_check_call(cmd) != 0:
|
||||||
msg = 'error pulling docker image {img}.'.format(img=img)
|
msg = 'error pulling docker image {img}.'.format(img=img)
|
||||||
raise Exception(msg)
|
raise TaskError(msg)
|
||||||
finally:
|
finally:
|
||||||
daemon.terminate()
|
daemon.terminate()
|
||||||
|
|
Loading…
Add table
Reference in a new issue