Class: Moob::IbmEServer

Inherits:
BaseLom show all
Defined in:
lib/moob/ibmeserver.rb

Instance Attribute Summary

Attributes inherited from BaseLom

#hostname, #username

Instance Method Summary collapse

Methods inherited from BaseLom

action, actions, name

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, options = {}
    super hostname, options
    @username ||= 'USERID'
    @password ||= 'PASSW0RD'
end

Instance Method Details

#authenticateObject



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.handle_cookies 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

#detectObject



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_infosObject



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

#infosObject



33
34
35
# File 'lib/moob/ibmeserver.rb', line 33

def infos
  return JSON.pretty_generate get_infos
end

#logoutObject



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