mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-04 05:04:22 -07:00
Present clearer messages for connection error
This commit is contained in:
parent
c538f4d7ca
commit
ff985a03ae
1 changed files with 3 additions and 0 deletions
|
@ -117,6 +117,7 @@ except ImportError:
|
||||||
else:
|
else:
|
||||||
HAS_PYLXD = True
|
HAS_PYLXD = True
|
||||||
|
|
||||||
|
from requests.exceptions import ConnectionError
|
||||||
|
|
||||||
# LXD_ANSIBLE_STATES is a map of states that contain values of methods used
|
# LXD_ANSIBLE_STATES is a map of states that contain values of methods used
|
||||||
# when a particular state is evoked.
|
# when a particular state is evoked.
|
||||||
|
@ -200,6 +201,8 @@ class LxdContainerManagement(object):
|
||||||
return self.client.containers.get(self.container_name)
|
return self.client.containers.get(self.container_name)
|
||||||
except NameError:
|
except NameError:
|
||||||
return None
|
return None
|
||||||
|
except ConnectionError:
|
||||||
|
self.module.fail_json(msg="Cannot connect to lxd server")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _container_to_module_state(container):
|
def _container_to_module_state(container):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue