Class: Oxidized::HTTP
Constant Summary
Constants inherited
from Input
Input::RESCUE_FAIL
Instance Attribute Summary
Attributes included from Input::CLI
#node
Instance Method Summary
collapse
Methods included from Input::CLI
#connect_cli, #disconnect_cli, #get, #initialize, #login, #password, #post_login, #pre_logout, #username
#vars
Instance Method Details
#cmd(callback_or_string) ⇒ Object
33
34
35
36
37
|
# File 'lib/oxidized/input/http.rb', line 33
def cmd(callback_or_string)
return cmd_cb callback_or_string if callback_or_string.is_a?(Proc)
cmd_str callback_or_string
end
|
#cmd_cb(callback) ⇒ Object
39
40
41
|
# File 'lib/oxidized/input/http.rb', line 39
def cmd_cb(callback)
instance_exec(&callback)
end
|
#cmd_str(string) ⇒ Object
43
44
45
46
|
# File 'lib/oxidized/input/http.rb', line 43
def cmd_str(string)
path = string % { password: @node.auth[:password] }
get_http path
end
|
#connect(node) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/oxidized/input/http.rb', line 10
def connect(node)
@node = node
@secure = false
@username = nil
@password = nil
@headers = {}
@log = File.open(Oxidized::Config::LOG + "/#{@node.ip}-http", "w") if Oxidized.config.input.debug?
@node.model.cfg["http"].each { |cb| instance_exec(&cb) }
return true unless @main_page && defined?(login)
begin
require "mechanize"
rescue LoadError
raise OxidizedError, "mechanize not found: sudo gem install mechanize"
end
@m = Mechanize.new
url = URI::HTTP.build host: @node.ip, path: @main_page
@m_page = @m.get(url.to_s)
login
end
|