diff options
author | Michael Hwang <mhwang@research.att.com> | 2017-09-28 17:05:52 -0400 |
---|---|---|
committer | Michael Hwang <mhwang@research.att.com> | 2017-09-28 17:07:00 -0400 |
commit | 809230f9e3dea1adebbff4aa6927422bffc83ecc (patch) | |
tree | 03fcf7998a9ea638505b3a7c1dd3ca1bd5aa17db /dcae-cli/dcae_cli/util/docker_util.py | |
parent | af7747ca4a7d849dbef9f86b31216e388334f876 (diff) |
Fetch docker logins from Consul
Change-Id: I521fd549b12042fa1d12481fbb0beb535f52e06f
Issue-Id: DCAEGEN2-91
Signed-off-by: Michael Hwang <mhwang@research.att.com>
Diffstat (limited to 'dcae-cli/dcae_cli/util/docker_util.py')
-rw-r--r-- | dcae-cli/dcae_cli/util/docker_util.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/dcae-cli/dcae_cli/util/docker_util.py b/dcae-cli/dcae_cli/util/docker_util.py index b59688b..a0499d6 100644 --- a/dcae-cli/dcae_cli/util/docker_util.py +++ b/dcae-cli/dcae_cli/util/docker_util.py @@ -74,10 +74,10 @@ def build_envs(profile, docker_config, instance_name): # TODO: Consolidate these two docker client methods. Need ability to invoke local # vs remote Docker engine -def get_docker_client(profile): - base_url = "tcp://{0}".format(profile.docker_host) +def get_docker_client(profile, logins=[]): + hostname, port = profile.docker_host.split(":") try: - client = docker.Client(base_url=base_url) + client = doc.create_client(hostname, port, logins=logins) client.ping() return client except: @@ -162,7 +162,8 @@ def _run_registrator(client, external_ip=None): # High level calls # -def deploy_component(profile, image, instance_name, docker_config, should_wait=False): +def deploy_component(profile, image, instance_name, docker_config, should_wait=False, + logins=[]): """Deploy Docker component This calls runs a Docker container detached. The assumption is that the Docker @@ -170,6 +171,13 @@ def deploy_component(profile, image, instance_name, docker_config, should_wait=F TODO: Split out the wait functionality + Args + ---- + logins (list): List of objects where the objects are each a docker login of + the form: + + {"registry": .., "username":.., "password":.. } + Returns ------- Dict that is the result from a Docker inspect call @@ -188,7 +196,7 @@ def deploy_component(profile, image, instance_name, docker_config, should_wait=F raise DockerConstructionError("Could not resolve the docker hostname:{0}".format(dh)) envs = build_envs(profile, docker_config, instance_name) - client = get_docker_client(profile) + client = get_docker_client(profile, logins=logins) config = doc.create_container_config(client, image, envs, hcp) return _run_container(client, config, name=instance_name, wait=should_wait) |