moob 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +2 -2
- data/bin/moob +1 -0
- data/lib/moob.rb +4 -2
- data/lib/moob/baselom.rb +1 -0
- data/lib/moob/ibmeserver.rb +75 -0
- data/lib/moob/idrac6.rb +15 -15
- data/lib/moob/megatrends.rb +1 -1
- metadata +4 -3
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
|
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
data/lib/moob.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Moob
|
2
|
-
VERSION = [0,3,
|
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 = {}
|
data/lib/moob/baselom.rb
CHANGED
@@ -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
|
data/lib/moob/idrac6.rb
CHANGED
@@ -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
|
data/lib/moob/megatrends.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
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:
|
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
|