mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
implement #scp_download method to allow downloads in addition to uploads via scp. alias #scp method as #scp_upload.
This commit is contained in:
parent
cf84d2d4be
commit
8ad8264d7a
2 changed files with 29 additions and 2 deletions
|
@ -13,6 +13,17 @@ module Fog
|
|||
Fog::SCP.new(public_ip_address, username, scp_options).upload(local_path, remote_path, upload_options)
|
||||
end
|
||||
|
||||
alias_method :scp_upload, :scp
|
||||
|
||||
def scp_download(remote_path, local_path, download_options = {})
|
||||
require 'net/scp'
|
||||
requires :public_ip_address, :username
|
||||
|
||||
scp_options = {}
|
||||
scp_options[:key_data] = [private_key] if private_key
|
||||
Fog::SCP.new(public_ip_address, username, scp_options).download(remote_path, local_path, download_options)
|
||||
end
|
||||
|
||||
def ssh(commands, options={})
|
||||
require 'net/ssh'
|
||||
requires :public_ip_address, :username
|
||||
|
|
|
@ -27,6 +27,10 @@ module Fog
|
|||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
def download(remote_path, local_path, download_options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Real
|
||||
|
@ -45,10 +49,22 @@ module Fog
|
|||
@options = { :paranoid => false }.merge(options)
|
||||
end
|
||||
|
||||
def upload(local_path, remote_path, upload_options = {} )
|
||||
def upload(local_path, remote_path, upload_options = {})
|
||||
begin
|
||||
Net::SCP.start(@address, @username, @options) do |scp|
|
||||
scp.upload!(local_path, remote_path, upload_options ) do |ch, name, sent, total|
|
||||
scp.upload!(local_path, remote_path, upload_options) do |ch, name, sent, total|
|
||||
# TODO: handle progress display?
|
||||
end
|
||||
end
|
||||
rescue Exception => error
|
||||
raise error
|
||||
end
|
||||
end
|
||||
|
||||
def download(remote_path, local_path, download_options = {})
|
||||
begin
|
||||
Net::SCP.start(@address, @username, @options) do |scp|
|
||||
scp.download!(remote_path, local_path, download_options) do |ch, name, sent, total|
|
||||
# TODO: handle progress display?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue