コード例 #1
0
 def get_remote_file(self, remotepath, localpath):
     """Fetch remote File."""
     sftp_client = self.transport.open_sftp_client()
     LOG.debug('Get the remote file. '
               'Source=%(src)s. Target=%(target)s.' % {
                   'src': remotepath,
                   'target': localpath
               })
     try:
         sftp_client.get(remotepath, localpath)
     except Exception as ex:
         LOG.error('Failed to secure copy. Reason: %s.' % six.text_type(ex))
         raise SFtpExecutionError(err=ex)
コード例 #2
0
 def copy_file_to_remote(self, localpath, remotepath):
     """scp the local file to remote folder."""
     sftp_client = self.transport.open_sftp_client()
     LOG.debug('Copy the local file to remote. '
               'Source=%(src)s. Target=%(target)s.' % {
                   'src': localpath,
                   'target': remotepath
               })
     try:
         sftp_client.put(localpath, remotepath)
     except Exception as ex:
         LOG.error('Failed to copy the local file to remote. '
                   'Reason: %s.' % six.text_type(ex))
         raise SFtpExecutionError(err=ex)