Example #1
0
 def sftp(self):
     if self._sftp is None:
         if self.properties['username'] == 'root':
             self.logger.debug("Opening SFTP session")
             self._sftp = self.client.open_sftp()
         else:
             self.logger.debug("Opening sudo-wrapped SFTP")
             chan = self._root_command(self.properties['sftp_server'])
             self.logger.debug("Connecting SFTP Client.")
             self._sftp = SFTPClient(chan)
     return self._sftp
Example #2
0
def open_sftp_with_timeout(client, timeout=5):
    """
    SFTP Connection to transfer files and environment between Auptimizer source machine and remote machine.
    """
    t = client.get_transport()
    chan = t.open_session(window_size=None,
                          max_packet_size=None,
                          timeout=timeout)
    if chan is None:
        return None
    chan.invoke_subsystem("sftp")
    return SFTPClient(chan)