Class: SSHKit::Backend::Netssh
Defined Under Namespace
Classes: Configuration
Instance Attribute Summary
Attributes inherited from Abstract
#host
Class Method Summary
collapse
Instance Method Summary
collapse
#make, #rake
Methods inherited from Abstract
#as, #debug, #error, #fatal, #info, #initialize, #log, #make, #rake, #trace, #warn, #with, #within
Class Method Details
.config ⇒ Object
98
99
100
|
# File 'lib/sshkit/backends/netssh.rb', line 98
def config
@config ||= Configuration.new
end
|
94
95
96
|
# File 'lib/sshkit/backends/netssh.rb', line 94
def configure
yield config
end
|
Instance Method Details
#background(*args) ⇒ Object
57
58
59
60
|
# File 'lib/sshkit/backends/netssh.rb', line 57
def background(*args)
options = args..merge(run_in_background: true)
_execute(*[*args, options]).success?
end
|
#capture(*args) ⇒ Object
62
63
64
65
|
# File 'lib/sshkit/backends/netssh.rb', line 62
def capture(*args)
options = args..merge(verbosity: Logger::DEBUG)
_execute(*[*args, options]).full_stdout.strip
end
|
#download!(remote, local = nil, options = {}) ⇒ Object
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/sshkit/backends/netssh.rb', line 82
def download!(remote, local=nil, options = {})
ssh.scp.download!(remote, local, options) do |ch, name, received, total|
percentage = (received.to_f * 100 / total.to_f).to_i
if percentage > 0 && percentage % 10 == 0
info "Downloading #{name} #{percentage}%"
else
debug "Downloading #{name} #{percentage}%"
end
end
end
|
#execute(*args) ⇒ Object
53
54
55
|
# File 'lib/sshkit/backends/netssh.rb', line 53
def execute(*args)
_execute(*args).success?
end
|
#run ⇒ Object
41
42
43
|
# File 'lib/sshkit/backends/netssh.rb', line 41
def run
instance_exec(host, &@block)
end
|
#test(*args) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/sshkit/backends/netssh.rb', line 45
def test(*args)
options = args..merge(
raise_on_non_zero_exit: false,
verbosity: Logger::DEBUG
)
_execute(*[*args, options]).success?
end
|
#upload!(local, remote, options = {}) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/sshkit/backends/netssh.rb', line 67
def upload!(local, remote, options = {})
ssh.scp.upload!(local, remote, options) do |ch, name, sent, total|
percentage = (sent.to_f * 100 / total.to_f)
unless percentage.nan?
if percentage > 0 && percentage % 10 == 0
info "Uploading #{name} #{percentage.round(2)}%"
else
debug "Uploading #{name} #{percentage.round(2)}%"
end
else
warn "Error calculating percentage #{percentage} is NaN"
end
end
end
|