/
scp.rb
29 lines (27 loc) · 1.1 KB
/
scp.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'veewee/provider/core/helper/ssh'
module Veewee
module Provider
module Core
module BoxCommand
def scp(localfile,remotefile,options={})
raise Veewee::Error,"Box is not running" unless self.running?
begin
new_options=ssh_options.merge(options)
self.when_ssh_login_works(self.ip_address,new_options) do
begin
env.logger.info "About to transfer #{localfile} to #{remotefile} to the box #{name} - #{self.ip_address} - #{new_options.inspect}"
self.ssh_transfer_file(self.ip_address,localfile,remotefile,new_options)
rescue RuntimeError => ex
ui.error("Error transfering file #{localfile} failed, possible not enough permissions to write? #{ex}",:prefix => false)
raise Veewee::SshError,ex
end
end
rescue Net::SSH::AuthenticationFailed => ex
ui.error("Authentication failure",:prefix => false)
raise Veewee::SshError,ex
end
end
end # Module
end # Module
end # Module
end # Module