From 43d0505bdebc793104178419e0fa763642724494 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Thu, 26 Jan 2017 14:00:08 -0500 Subject: [PATCH] fixes issue in network_cli where _connected wasn't set (#20708) Adds the code to set and unset the _connected propery in network_cli on calls to open() and close() --- lib/ansible/plugins/connection/network_cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/connection/network_cli.py b/lib/ansible/plugins/connection/network_cli.py index 817ef9a21d..0371676ab0 100644 --- a/lib/ansible/plugins/connection/network_cli.py +++ b/lib/ansible/plugins/connection/network_cli.py @@ -69,6 +69,8 @@ class Connection(_Connection): """Connections to the device and sets the terminal type""" super(Connection, self)._connect() + display.debug('starting network_cli._connect()') + network_os = self._play_context.network_os if not network_os: for cls in terminal_loader.all(class_only=True): @@ -94,7 +96,7 @@ class Connection(_Connection): if not self._terminal: raise AnsibleConnectionFailure('network os %s is not supported' % network_os) - return (0, 'connected', '') + self._connected = True @ensure_connect def open_shell(self): @@ -115,6 +117,7 @@ class Connection(_Connection): display.vvv('closing connection', host=self._play_context.remote_addr) self.close_shell() super(Connection, self).close() + self._connected = False def close_shell(self): """Closes the vty shell if the device supports multiplexing"""