Class: Moob::SunILom
Instance Attribute Summary
Attributes inherited from BaseLom
#hostname, #username
Instance Method Summary
collapse
Methods inherited from BaseLom
action, actions, #logout, name
Constructor Details
#initialize(hostname, options = {}) ⇒ SunILom
Returns a new instance of SunILom.
5
6
7
8
9
|
# File 'lib/moob/sunilom.rb', line 5
def initialize hostname, options = {}
super hostname, options
@username ||= 'root'
@password ||= 'changeme'
end
|
Instance Method Details
#authenticate ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/moob/sunilom.rb', line 11
def authenticate
auth = @session.post 'iPages/loginProcessor.asp', {
'username' => @username,
'password' => @password
}
raise ResponseError.new auth unless auth.status == 200
if auth.body =~ /\/iPages\/i_login.asp\?msg=([^"])+"/
error = "code #{$1}"
error_page = @session.get "iPages/i_login.asp?msg=#{$1}"
if error_page.body =~ /<div class="AlrtErrTxt">(.*?)<\/div>/
error = "\"#{$1.gsub /<[^>]+>/, ''}\""
end
raise "Auth failed (#{error})"
end
auth.body =~ /SetWebSessionString\("([^"]+)","([^"]+)"\);/
raise "Couldn't find session cookie in \"#{auth.body}\"" unless $&
@cookie = "#{$1}=#{$2}; langsetting=EN"
return self
end
|
#detect ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/moob/sunilom.rb', line 44
def detect
begin
home = @session.get 'iPages/i_login.asp'
home.body =~ /Sun\(TM\) Sun Integrated Lights Out Manager/
rescue
false
end
end
|
#jnlp ⇒ Object
37
38
39
40
41
42
|
# File 'lib/moob/sunilom.rb', line 37
def jnlp
viewer = @session.get 'cgi-bin/jnlpgenerator-8', { 'Cookie' => @cookie }
raise ResponseError.new viewer unless viewer.status == 200
return viewer.body
end
|