bootstrapvz/plugins/docker_daemon: flake8

This commit is contained in:
Johan Euphrosine 2014-11-19 11:49:17 -08:00
parent f3a9a1b1ec
commit 962532065c
2 changed files with 26 additions and 36 deletions

View file

@ -1,7 +1,6 @@
import os import os
import subprocess import subprocess
import time import time
import logging
def pull(info, images, retries=10): def pull(info, images, retries=10):
@ -21,23 +20,13 @@ def pull(info, images, retries=10):
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]
logging.debug(' '.join(cmd))
if subprocess.call(cmd) != 0: if subprocess.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 Exception(msg)
continue continue
cmd = [bin_docker, '-H', socket, 'pull', img] cmd = [bin_docker, '-H', socket, 'pull', img]
logging.debug('running: %s', ' '.join(cmd))
if subprocess.call(cmd) != 0: if subprocess.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 Exception(msg)
finally: finally:
daemon.terminate() daemon.terminate()
if __name__ == '__main__':
class Info(object):
root = '/tmp/bootstrap-vz/root'
workspace = '/tmp/bootstrap-vz/workspace'
pull_images = ['/usr/local/google/home/proppy/bootstrap-vz/busybox.tar.gz', 'golang:1.3']
pull(Info(), pull_images)

View file

@ -67,6 +67,7 @@ class EnableMemoryCgroup(Task):
grub_config = os.path.join(info.root, 'etc/default/grub') grub_config = os.path.join(info.root, 'etc/default/grub')
sed_i(grub_config, r'^(GRUB_CMDLINE_LINUX*=".*)"\s*$', r'\1 cgroup_enable=memory"') sed_i(grub_config, r'^(GRUB_CMDLINE_LINUX*=".*)"\s*$', r'\1 cgroup_enable=memory"')
class PullDockerImages(Task): class PullDockerImages(Task):
description = 'Pull docker images' description = 'Pull docker images'
phase = phases.system_modification phase = phases.system_modification