From b0357bf9e8f27cad04bd3882acab215e0463a0a5 Mon Sep 17 00:00:00 2001 From: Michael Schuett Date: Tue, 7 Jul 2015 15:36:10 -0400 Subject: [PATCH] Handle connection error Try and help when mac hits a connection error. --- cloud/docker/docker_image.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cloud/docker/docker_image.py b/cloud/docker/docker_image.py index 6f41755c929..3807c963de1 100644 --- a/cloud/docker/docker_image.py +++ b/cloud/docker/docker_image.py @@ -431,6 +431,20 @@ def main(): else: module.exit_json(failed=True, chaged=manager.has_changed(), msg="SSLError: " + str(e)) + except ConnectionError as e: + if get_platform() == "Darwin" and "DOCKER_HOST" not in os.environ: + # Ensure that the environment variables has been set + environment_error = ''' + It looks like you have not set your docker environment + variables. Please ensure that you have set the requested + variables as instructed when running boot2docker up. If + they are set in .bash_profile you will need to symlink + it to .bashrc. + ''' + module.exit_json(failed=True, chaged=manager.has_changed(), msg="ConnectionError: " + str(e) + environment_error) + + module.exit_json(failed=True, chaged=manager.has_changed(), msg="ConnectionError: " + str(e)) + except DockerAPIError as e: module.exit_json(failed=True, changed=manager.has_changed(), msg="Docker API error: " + e.explanation)