Coverage for lib/ansible/plugins/connection/persistent.py : 70%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# 2017 Red Hat Inc. # (c) 2017 Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
author: Ansible Core Team connection: persistent short_description: Use a persistent unix socket for connection description: - This is a helper plugin to allow making other connections persistent. version_added: "2.3" """
except ImportError: from ansible.utils.display import Display display = Display()
''' Local based connections '''
self._connected = True return self
display.vvvv('exec_command(), socket_path=%s' % self.socket_path, host=self._play_context.remote_addr) connection = SocketConnection(self.socket_path) out = connection.exec_command(cmd, in_data=in_data, sudoable=sudoable) return 0, out, ''
pass
pass
self._connected = False
"""Returns the path of the persistent connection socket.
Attempts to ensure (within playcontext.timeout seconds) that the socket path exists. If the path exists (or the timeout has expired), returns the socket path. """
''' Starts the persistent connection '''
# Need to force a protocol that is compatible with both py2 and py3. # That would be protocol=2 or less. # Also need to force a protocol that excludes certain control chars as # stdin in this case is a pty and control chars will cause problems. # that means only protocol=0 will work.
else: result = json.loads(to_text(stderr, errors='surrogate_then_replace'))
if self._play_context.verbosity > 2: msg = "The full traceback is:\n" + result['exception'] display.display(msg, color=C.COLOR_ERROR) raise AnsibleError(result['error'])
|