Class: Oxidized::SSH
Defined Under Namespace
Classes: NoShell
Constant Summary
collapse
- RescueFail =
{
:debug => [
Net::SSH::Disconnect,
],
:warn => [
RuntimeError,
Net::SSH::AuthenticationFailed,
],
}
Instance Method Summary
collapse
Methods included from Input::CLI
#connect_cli, #disconnect_cli, #get, #initialize, #password, #post_login, #pre_logout, #username
#vars
Instance Method Details
#cmd(cmd, expect = @node.prompt) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/oxidized/input/ssh.rb', line 37
def cmd cmd, expect=@node.prompt
Log.debug "SSH: #{cmd} @ #{@node.name}"
if @exec
@ssh.exec! cmd
else
cmd_shell(cmd, expect).gsub(/\r\n/, "\n")
end
end
|
#connect(node) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/oxidized/input/ssh.rb', line 18
def connect node
@node = node
@output = ''
@node.model.cfg['ssh'].each { |cb| instance_exec(&cb) }
secure = CFG.input.ssh.secure
@ssh = Net::SSH.start @node.ip, @node.auth[:username],
:password => @node.auth[:password], :timeout => CFG.timeout,
:paranoid => secure
unless @exec
shell_open @ssh
@username ? shell_login : expect(@node.prompt)
end
connected?
end
|
#connected? ⇒ Boolean
33
34
35
|
# File 'lib/oxidized/input/ssh.rb', line 33
def connected?
@ssh and not @ssh.closed?
end
|
#output ⇒ Object
50
51
52
|
# File 'lib/oxidized/input/ssh.rb', line 50
def output
@output
end
|
#send(data) ⇒ Object
46
47
48
|
# File 'lib/oxidized/input/ssh.rb', line 46
def send data
@ses.send_data data
end
|