Decorate the ConnectionBase methods, switch to calling super from individual connection classes

This commit is contained in:
Matt Martz 2015-06-04 13:27:18 -05:00
parent 9754c67138
commit bce281014c
5 changed files with 32 additions and 12 deletions

View file

@ -41,7 +41,7 @@ from binascii import hexlify
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
from ansible.plugins.connections import ConnectionBase, ensure_connect
from ansible.plugins.connections import ConnectionBase
from ansible.utils.path import makedirs_safe
AUTHENTICITY_MSG="""
@ -189,10 +189,11 @@ class Connection(ConnectionBase):
return ssh
@ensure_connect
def exec_command(self, cmd, tmp_path, executable='/bin/sh', in_data=None):
''' run a command on the remote host '''
super(Connection, self).exec_command(cmd, tmp_path, executable=executable, in_data=in_data)
if in_data:
raise AnsibleError("Internal Error: this module does not support optimized module pipelining")
@ -250,10 +251,11 @@ class Connection(ConnectionBase):
return (chan.recv_exit_status(), '', no_prompt_out + stdout, no_prompt_out + stderr)
@ensure_connect
def put_file(self, in_path, out_path):
''' transfer a file from local to remote '''
super(Connection, self).put_file(in_path, out_path)
self._display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._connection_info.remote_addr)
if not os.path.exists(in_path):
@ -278,10 +280,11 @@ class Connection(ConnectionBase):
result = SFTP_CONNECTION_CACHE[cache_key] = self._connect().ssh.open_sftp()
return result
@ensure_connect
def fetch_file(self, in_path, out_path):
''' save a remote file to the specified path '''
super(Connection, self).fetch_file(in_path, out_path)
self._display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._connection_info.remote_addr)
try: