From 92f7aa79b0f0d30c4e421b373a0ea10f76d53aa6 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 18 Aug 2014 10:37:07 -0500 Subject: [PATCH] Fix bad commit from #8095 and fix bad splitting on :'s in the image Fixes #8095 Fixes #8658 --- library/cloud/docker | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/library/cloud/docker b/library/cloud/docker index 23c88e51843..0b12f5535be 100644 --- a/library/cloud/docker +++ b/library/cloud/docker @@ -197,6 +197,14 @@ options: default: false aliases: [] version_added: "1.8" + registry: + description: + - The remote registry URL to use for pulling images. + required: false + default: '' + aliases: [] + version_added: "1.8" + author: Cove Schneider, Joshua Conner, Pavel Antonov requirements: [ "docker-py >= 0.3.0", "docker >= 0.10.0" ] ''' @@ -499,13 +507,6 @@ class DockerManager: def get_split_image_tag(self, image): if '/' in image: image = image.split('/')[-1] - tag = None - if image.find(':') > 0: - return image.split(':') - else: - return image, tag - - def get_split_full_image_tag(self, image): tag = "latest" if image.find(':') > 0: return image.split(':') @@ -611,8 +612,13 @@ class DockerManager: try: containers = do_create(count, params) except: - image, tag = self.get_split_full_image_tag(params['image']) - self.client.pull(image, tag = tag) + image, tag = self.get_split_image_tag(params['image']) + if self.module.params.get('username'): + self.client.login(self.module.params.get('username'), + password=self.module.params.get('password'), + email=self.module.params.get('email'), + registry=self.module.params.get('registry')) + self.client.pull(image, tag=tag) self.increment_counter('pull') containers = do_create(count, params) @@ -700,9 +706,10 @@ def main(): memory_swap = dict(default=0), docker_url = dict(default='unix://var/run/docker.sock'), docker_api_version = dict(default=docker.client.DEFAULT_DOCKER_API_VERSION), - user = dict(default=None), + username = dict(default=None), password = dict(), email = dict(), + registry = dict(), hostname = dict(default=None), env = dict(type='dict'), dns = dict(),