From ff985a03aeda709cb33f1cdd4228c4efe872962b Mon Sep 17 00:00:00 2001 From: Hiroaki Nakamura Date: Thu, 12 May 2016 23:27:53 +0900 Subject: [PATCH] Present clearer messages for connection error --- lib/ansible/modules/extras/cloud/lxd/lxd_container.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/modules/extras/cloud/lxd/lxd_container.py b/lib/ansible/modules/extras/cloud/lxd/lxd_container.py index 226e3bf253..64671cf9ee 100644 --- a/lib/ansible/modules/extras/cloud/lxd/lxd_container.py +++ b/lib/ansible/modules/extras/cloud/lxd/lxd_container.py @@ -117,6 +117,7 @@ except ImportError: else: HAS_PYLXD = True +from requests.exceptions import ConnectionError # LXD_ANSIBLE_STATES is a map of states that contain values of methods used # when a particular state is evoked. @@ -200,6 +201,8 @@ class LxdContainerManagement(object): return self.client.containers.get(self.container_name) except NameError: return None + except ConnectionError: + self.module.fail_json(msg="Cannot connect to lxd server") @staticmethod def _container_to_module_state(container):