Class: Moob::IbmEServer
Instance Attribute Summary
Attributes inherited from BaseLom
Instance Method Summary collapse
- #authenticate ⇒ Object
- #detect ⇒ Object
- #get_infos ⇒ Object
- #infos ⇒ Object
-
#initialize(hostname, options = {}) ⇒ IbmEServer
constructor
A new instance of IbmEServer.
- #logout ⇒ Object
Methods inherited from BaseLom
Constructor Details
#initialize(hostname, options = {}) ⇒ IbmEServer
Returns a new instance of IbmEServer.
5 6 7 8 9 |
# File 'lib/moob/ibmeserver.rb', line 5 def initialize hostname, = {} super hostname, @username ||= 'USERID' @password ||= 'PASSW0RD' 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 |
# File 'lib/moob/ibmeserver.rb', line 11 def authenticate @session. nil home = @session.get '' raise ResponseError.new home unless home.status == 200 auth = @session.post 'private/check_userlogin', { 'userid' => @username, 'passwd' => @password } raise ResponseError.new auth unless auth.status == 200 init = @session.post 'private/start_menus', { 'JUNK' => '1', 'TIMEOUT' => '05' } raise ResponseError.new init unless init.status == 200 return self end |
#detect ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/moob/ibmeserver.rb', line 37 def detect begin home = @session.get 'private/userlogin.ssi' home.body =~ /Remote Supervisor Adapter/ rescue false end end |
#get_infos ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/moob/ibmeserver.rb', line 51 def get_infos page = @session.get 'private/vpd.ssi' raise ResponseError.new page unless page.status == 200 infos = {} infos[:macs] = Hash[ page.body.scan /<TR><TD[^>]*>MAC ([^:]*):<\/TD><TD[^>]*>([^<]*)<\/TD><\/TR>/ ] infos[:type] = grab page.body, 'Machine type' infos[:model] = grab page.body, 'Machine model' infos[:serial] = grab page.body, 'Serial number' infos[:uuid] = grab page.body, 'UUID' end |
#infos ⇒ Object
33 34 35 |
# File 'lib/moob/ibmeserver.rb', line 33 def infos return JSON.pretty_generate get_infos end |
#logout ⇒ Object
46 47 48 49 |
# File 'lib/moob/ibmeserver.rb', line 46 def logout page = @session.get 'private/logoff' raise ResponseError.new page unless page.status == 200 end |