1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

minor bugfix that will catch connection errors in junos

This commit fixes a situation where connection errors would be caught
but no useful information display.  The connection error is now caught
and emitted in a call to fail_json
This commit is contained in:
Peter Sprygada 2016-02-17 14:14:54 +00:00
parent 9e31e33850
commit 1a072578c3

View file

@ -47,7 +47,12 @@ class Cli(object):
password = self.module.params['password']
self.shell = Shell()
self.shell.open(host, port=port, username=username, password=password)
try:
self.shell.open(host, port=port, username=username, password=password)
except Exception, exc:
msg = 'failed to connecto to %s:%s - %s' % (host, port, str(exc))
self.module.fail_json(msg=msg)
def send(self, commands):
return self.shell.send(commands)