moob 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/COPYING CHANGED
@@ -1,4 +1,4 @@
1
1
  Copyright (c) 2011, Pierre Carrier <pierre@gcarrier.fr>
2
2
 
3
- Permission is granted to copy, modify and/or distribute this work and/or
4
- license, without conditions.
3
+ Permission is granted to use, copy, modify and/or distribute this work
4
+ and/or license, without conditions.
data/bin/moob CHANGED
@@ -94,6 +94,7 @@ begin
94
94
  end
95
95
 
96
96
  lom.logout
97
+ Moob.inform "Logged out of #{h}."
97
98
  end
98
99
  puts 'There might be a delay before Java Web Start shows up...' if options[:action] == :jnlp
99
100
 
@@ -1,5 +1,5 @@
1
1
  module Moob
2
- VERSION = [0,3,0]
2
+ VERSION = [0,3,1]
3
3
 
4
4
  class ResponseError < Exception
5
5
  def initialize response
@@ -14,11 +14,13 @@ module Moob
14
14
  autoload :Idrac6, 'moob/idrac6.rb'
15
15
  autoload :Megatrends, 'moob/megatrends.rb'
16
16
  autoload :SunILom, 'moob/sunilom.rb'
17
+ autoload :IbmEServer, 'moob/ibmeserver.rb'
17
18
 
18
19
  TYPES = {
19
20
  :idrac6 => Idrac6,
20
21
  :megatrends => Megatrends,
21
- :sun => SunILom
22
+ :sun => SunILom,
23
+ :ibm => IbmEServer
22
24
  }
23
25
 
24
26
  def self.lom type, hostname, options = {}
@@ -19,6 +19,7 @@ class Moob::BaseLom
19
19
  @session.connect_timeout = 10_000
20
20
  @session.timeout = 10_000
21
21
  @session.insecure = true
22
+ @session.default_response_charset = 'ISO-8859-1'
22
23
  end
23
24
 
24
25
  def logout
@@ -0,0 +1,75 @@
1
+ module Moob
2
+ class IbmEServer < BaseLom
3
+ @name = 'IBM eServer Remote Supervisor Adapter'
4
+
5
+ def initialize hostname, options = {}
6
+ super hostname, options
7
+ @username ||= 'USERID'
8
+ @password ||= 'PASSW0RD'
9
+ end
10
+
11
+ def authenticate
12
+ @session.handle_cookies nil
13
+
14
+ home = @session.get ''
15
+ raise ResponseError.new home unless home.status == 200
16
+
17
+ auth = @session.post 'private/check_userlogin', {
18
+ 'userid' => @username,
19
+ 'passwd' => @password
20
+ }
21
+ raise ResponseError.new auth unless auth.status == 200
22
+
23
+ init = @session.post 'private/start_menus', {
24
+ 'JUNK' => '1',
25
+ 'TIMEOUT' => '05'
26
+ }
27
+ raise ResponseError.new init unless init.status == 200
28
+
29
+ return self
30
+ end
31
+
32
+ action :infos, 'Vital Product Data'
33
+ def infos
34
+ return JSON.pretty_generate get_infos
35
+ end
36
+
37
+ def detect
38
+ begin
39
+ home = @session.get 'private/userlogin.ssi'
40
+ home.body =~ /Remote Supervisor Adapter/
41
+ rescue
42
+ false
43
+ end
44
+ end
45
+
46
+ def logout
47
+ page = @session.get 'private/logoff'
48
+ raise ResponseError.new page unless page.status == 200
49
+ end
50
+
51
+ def get_infos
52
+ page = @session.get 'private/vpd.ssi'
53
+ raise ResponseError.new page unless page.status == 200
54
+
55
+ infos = {}
56
+
57
+ infos[:macs] = Hash[
58
+ page.body.scan /<TR><TD[^>]*>MAC ([^:]*):<\/TD><TD[^>]*>([^<]*)<\/TD><\/TR>/
59
+ ]
60
+
61
+ infos[:type] = grab page.body, 'Machine type'
62
+ infos[:model] = grab page.body, 'Machine model'
63
+ infos[:serial] = grab page.body, 'Serial number'
64
+ infos[:uuid] = grab page.body, 'UUID'
65
+ end
66
+
67
+ private
68
+ def grab contents, name
69
+ if contents =~ /<TR><TD[^>]*>#{name}:<\/TD><TD[^>]*>([^<]*)<\/TD><\/TR>/
70
+ return $1
71
+ end
72
+ end
73
+
74
+ end
75
+ end
@@ -167,21 +167,6 @@ class Idrac6 < BaseLom
167
167
  class_eval %{def #{name}; boot_on #{code}; end}
168
168
  end
169
169
 
170
- def get_infos keys
171
- infos = @session.post "data?get=#{keys.join(',')}", {}
172
-
173
- raise ResponseError.new infos unless infos.status == 200
174
- raise Exception.new "The status isn't OK" unless infos.body =~ /<status>ok<\/status>/
175
-
176
- return Hash[keys.collect do |k|
177
- if infos.body =~ /<#{k}>(.*?)<\/#{k}>/
178
- [k, $1]
179
- else
180
- [k, nil]
181
- end
182
- end]
183
- end
184
-
185
170
  action :pstatus, 'Power status'
186
171
  def pstatus
187
172
  case get_infos(['pwState'])['pwState']
@@ -198,5 +183,20 @@ class Idrac6 < BaseLom
198
183
  def infos
199
184
  return JSON.pretty_generate get_infos INFO_FIELDS
200
185
  end
186
+
187
+ def get_infos keys
188
+ infos = @session.post "data?get=#{keys.join(',')}", {}
189
+
190
+ raise ResponseError.new infos unless infos.status == 200
191
+ raise Exception.new "The status isn't OK" unless infos.body =~ /<status>ok<\/status>/
192
+
193
+ return Hash[keys.collect do |k|
194
+ if infos.body =~ /<#{k}>(.*?)<\/#{k}>/
195
+ [k, $1]
196
+ else
197
+ [k, nil]
198
+ end
199
+ end]
200
+ end
201
201
  end
202
202
  end
@@ -30,7 +30,7 @@ class Megatrends < BaseLom
30
30
  def detect
31
31
  begin
32
32
  home = @session.get 'page/login.html'
33
- home.body =~ /\.\.\/res\/banner_right.png/
33
+ home.body =~ /\.\.\/res\/banner_right\.png/
34
34
  rescue
35
35
  false
36
36
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Pierre Carrier
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-07-30 00:00:00 +02:00
17
+ date: 2012-02-23 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -57,6 +57,7 @@ extra_rdoc_files: []
57
57
  files:
58
58
  - bin/moob
59
59
  - lib/moob/baselom.rb
60
+ - lib/moob/ibmeserver.rb
60
61
  - lib/moob/idrac6.rb
61
62
  - lib/moob/megatrends.rb
62
63
  - lib/moob/sunilom.rb