Class: Specinfra::Backend::Ssh
- Inherits:
-
Exec
- Object
- Base
- Exec
- Specinfra::Backend::Ssh
show all
- Defined in:
- lib/specinfra/backend/ssh.rb
Instance Method Summary
collapse
Methods inherited from Base
#command, #get_config, #host_inventory, #initialize, instance, #os_info, #set_config, #set_example
Instance Method Details
#build_command(cmd) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/specinfra/backend/ssh.rb', line 35
def build_command(cmd)
cmd = super(cmd)
if sudo?
cmd = "#{sudo} -p '#{prompt}' #{cmd}"
end
cmd
end
|
#run_command(cmd, opt = {}) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/specinfra/backend/ssh.rb', line 9
def run_command(cmd, opt={})
cmd = build_command(cmd)
cmd = add_pre_command(cmd)
ret = with_env do
ssh_exec!(cmd)
end
ret[:stdout].gsub!(/\r\n/, "\n")
ret[:stdout].gsub!(/\A\n/, "") if sudo?
if @example
@example.metadata[:command] = cmd
@example.metadata[:stdout] = ret[:stdout]
end
CommandResult.new ret
end
|
#send_directory(from, to) ⇒ Object
31
32
33
|
# File 'lib/specinfra/backend/ssh.rb', line 31
def send_directory(from, to)
scp_upload!(from, to, :recursive => true)
end
|
#send_file(from, to) ⇒ Object
27
28
29
|
# File 'lib/specinfra/backend/ssh.rb', line 27
def send_file(from, to)
scp_upload!(from, to)
end
|