|
|
|
@ -118,6 +118,13 @@ class Connection(object):
|
|
|
|
|
vvv("PUT %s TO %s" % (in_path, out_path), host=self.host)
|
|
|
|
|
if not os.path.exists(in_path):
|
|
|
|
|
raise errors.AnsibleFileNotFound("file or module does not exist: %s" % in_path)
|
|
|
|
|
if C.DEFAULT_SCP_IF_SSH:
|
|
|
|
|
ft_cmd = ["scp"] + self.common_args
|
|
|
|
|
ft_cmd += [in_path,self.host + ":" + out_path]
|
|
|
|
|
p = subprocess.Popen(ft_cmd, stdin=subprocess.PIPE,
|
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
stdout, stderr = p.communicate()
|
|
|
|
|
else:
|
|
|
|
|
sftp_cmd = ["sftp"] + self.common_args + [self.host]
|
|
|
|
|
p = subprocess.Popen(sftp_cmd, stdin=subprocess.PIPE,
|
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
@ -128,6 +135,13 @@ class Connection(object):
|
|
|
|
|
def fetch_file(self, in_path, out_path):
|
|
|
|
|
''' fetch a file from remote to local '''
|
|
|
|
|
vvv("FETCH %s TO %s" % (in_path, out_path), host=self.host)
|
|
|
|
|
if C.DEFAULT_SCP_IF_SSH:
|
|
|
|
|
ft_cmd = ["scp"] + self.common_args
|
|
|
|
|
ft_cmd += [self.host + ":" + in_path, out_path]
|
|
|
|
|
p = subprocess.Popen(ft_cmd, stdin=subprocess.PIPE,
|
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|
stdout, stderr = p.communicate()
|
|
|
|
|
else:
|
|
|
|
|
sftp_cmd = ["sftp"] + self.common_args + [self.host]
|
|
|
|
|
p = subprocess.Popen(sftp_cmd, stdin=subprocess.PIPE,
|
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
|