Class: Fog::SCP::Real
- Inherits:
-
Object
- Object
- Fog::SCP::Real
- Defined in:
- lib/fog/core/scp.rb
Instance Method Summary collapse
- #download(remote_path, local_path, download_options = {}) ⇒ Object
-
#initialize(address, username, options) ⇒ Real
constructor
A new instance of Real.
- #upload(local_path, remote_path, upload_options = {}) ⇒ Object
Constructor Details
#initialize(address, username, options) ⇒ Real
Returns a new instance of Real.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/core/scp.rb', line 38 def initialize(address, username, ) require 'net/scp' key_manager = Net::SSH::Authentication::KeyManager.new(nil, ) unless [:key_data] || [:keys] || [:password] || key_manager.agent raise ArgumentError.new(':key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH') end @address = address @username = username @options = { :paranoid => false }.merge() end |
Instance Method Details
#download(remote_path, local_path, download_options = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fog/core/scp.rb', line 64 def download(remote_path, local_path, = {}) begin Net::SCP.start(@address, @username, @options) do |scp| scp.download!(remote_path, local_path, ) do |ch, name, sent, total| # TODO: handle progress display? end end rescue Exception => error raise error end end |
#upload(local_path, remote_path, upload_options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/core/scp.rb', line 52 def upload(local_path, remote_path, = {}) begin Net::SCP.start(@address, @username, @options) do |scp| scp.upload!(local_path, remote_path, ) do |ch, name, sent, total| # TODO: handle progress display? end end rescue Exception => error raise error end end |