Skip to content

Commit

Permalink
add upload_file method to connection module
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Horak <[email protected]>
  • Loading branch information
dahorak committed Feb 27, 2024
1 parent 1a5d20f commit ebdf0a2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ocs_ci/utility/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,17 @@ def exec_cmd(self, cmd):
)
logger.debug(f"stderr: {stderr}")
return (retcode, stdout, stderr)

def upload_file(self, localpath, remotepath):
"""
Upload a file to remote server
Args:
localpath (str): Local file to upload
remotepath (str): Target path on the remote server. Filename should be included
"""
sftp = self.client.open_sftp()
logger.info(f"uploading {localpath} to {self.user}@{self.host}:{remotepath}")
sftp.put(localpath, remotepath)
sftp.close()

0 comments on commit ebdf0a2

Please sign in to comment.