Class: Oxidized::HTTP
- Inherits:
-
Input
- Object
- Input
- Oxidized::HTTP
show all
- Defined in:
- lib/oxidized/input/http.rb
Constant Summary
Constants inherited
from Input
Input::RESCUE_FAIL
Instance Attribute Summary
Attributes included from Input::CLI
#node
Instance Method Summary
collapse
Methods inherited from Input
config_name, #config_name, rescue_fail, to_sym, #to_sym
Methods included from Input::CLI
#connect_cli, #disconnect_cli, #get, #initialize, #login, #newline, #password, #post_login, #pre_logout, #username
#vars
Instance Method Details
#cmd(callback_or_string) ⇒ Object
29
30
31
32
33
|
# File 'lib/oxidized/input/http.rb', line 29
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
35
36
37
|
# File 'lib/oxidized/input/http.rb', line 35
def cmd_cb(callback)
instance_exec(&callback)
end
|
#cmd_str(string) ⇒ Object
39
40
41
42
|
# File 'lib/oxidized/input/http.rb', line 39
def cmd_str(string)
path = string % { password: @node.auth[:password] }
get_http path
end
|
#connect(node) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/oxidized/input/http.rb', line 7
def connect(node)
@node = node
@secure = false
@username = nil
@password = nil
@headers = {}
@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
|