moob 0.3.8 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/moob +18 -0
- data/lib/moob.rb +30 -3
- data/lib/moob/baselom.rb +1 -0
- data/lib/moob/idrac6.rb +38 -3
- data/lib/moob/idrac7.rb +35 -3
- metadata +6 -6
data/bin/moob
CHANGED
@@ -45,6 +45,12 @@ OptionParser.new do |opts|
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
opts.on '-r', '--params foo=bar,dead=beef', Array,
|
49
|
+
'Comma-separated list of parameter/value pairs to use with set_params action' do |a|
|
50
|
+
options[:params]=a.inject({}) { |r, i| s=i.split('='); r[s[0]]=s[1]; r}
|
51
|
+
end
|
52
|
+
|
53
|
+
|
48
54
|
opts.on '-u', '--username u',
|
49
55
|
'LOM username',
|
50
56
|
'Defaults to the model\'s default if known' do |u|
|
@@ -70,6 +76,12 @@ OptionParser.new do |opts|
|
|
70
76
|
opts.on '-v', '--verbose' do
|
71
77
|
$VERBOSE = true
|
72
78
|
end
|
79
|
+
|
80
|
+
opts.on '-V', '--version',
|
81
|
+
'Prints version string and exits' do
|
82
|
+
puts "moob #{Moob::VERSION.join('.')}"
|
83
|
+
exit 0
|
84
|
+
end
|
73
85
|
end.parse!
|
74
86
|
|
75
87
|
if options[:machines].empty?
|
@@ -96,7 +108,13 @@ begin
|
|
96
108
|
case action
|
97
109
|
when :jnlp
|
98
110
|
Moob.start_jnlp lom
|
111
|
+
when :show_console_preview
|
112
|
+
Moob.show_console_preview lom
|
113
|
+
when :save_console_preview
|
114
|
+
savefile=Moob.save_console_preview lom
|
115
|
+
$stderr.puts "Console preview saved as #{savefile}"
|
99
116
|
else
|
117
|
+
|
100
118
|
res = lom.send action
|
101
119
|
puts res if res
|
102
120
|
end
|
data/lib/moob.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Moob
|
2
|
-
VERSION = [0,3,
|
4
|
+
VERSION = [0,3,11]
|
3
5
|
|
4
6
|
class ResponseError < Exception
|
5
7
|
def initialize response
|
@@ -25,12 +27,14 @@ module Moob
|
|
25
27
|
:ibm => IbmEServer
|
26
28
|
}
|
27
29
|
|
30
|
+
AUTODETECT_ORDER = [ :idrac7, :idrac6, :megatrends, :sun, :ibm ]
|
31
|
+
|
28
32
|
def self.lom type, hostname, options = {}
|
29
33
|
case type
|
30
34
|
when :auto
|
31
|
-
|
35
|
+
AUTODETECT_ORDER.each do |sym|
|
32
36
|
Moob.inform "Trying type #{sym}..."
|
33
|
-
lom =
|
37
|
+
lom = TYPES[sym].new hostname, options
|
34
38
|
if lom.detect
|
35
39
|
Moob.inform "Type #{sym} detected."
|
36
40
|
return lom
|
@@ -59,6 +63,29 @@ module Moob
|
|
59
63
|
raise 'javaws failed' unless system "javaws -wait #{filepath}"
|
60
64
|
end
|
61
65
|
|
66
|
+
def self.show_console_preview lom
|
67
|
+
imgfile, headers = lom.fetch_console_preview
|
68
|
+
|
69
|
+
if RUBY_PLATFORM =~ /darwin/
|
70
|
+
raise 'open failed' unless system "open #{imgfile.path}"
|
71
|
+
else
|
72
|
+
raise 'see failed' unless system "see #{imgfile.path}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.save_console_preview lom
|
77
|
+
imgfile, headers = lom.fetch_console_preview
|
78
|
+
|
79
|
+
timestamp=Time.parse(headers['Last-modified'])
|
80
|
+
fileext=headers['Content-type'].split('/')[1]
|
81
|
+
|
82
|
+
filename="#{lom.hostname}-#{timestamp.utc.iso8601(0)}.#{fileext}"
|
83
|
+
|
84
|
+
FileUtils.cp(imgfile, filename)
|
85
|
+
|
86
|
+
return filename
|
87
|
+
end
|
88
|
+
|
62
89
|
def self.inform msg
|
63
90
|
$stderr.puts "\033[36m#{msg}\033[0m" if $VERBOSE
|
64
91
|
end
|
data/lib/moob/baselom.rb
CHANGED
@@ -12,6 +12,7 @@ class Moob::BaseLom
|
|
12
12
|
@transport = options[:transport] or 'https'
|
13
13
|
@username = options[:username]
|
14
14
|
@password = options[:password]
|
15
|
+
@params = options[:params]
|
15
16
|
|
16
17
|
@session = Patron::Session.new
|
17
18
|
@session.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; '\
|
data/lib/moob/idrac6.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'time'
|
3
|
+
|
1
4
|
module Moob
|
2
5
|
class Idrac6 < BaseLom
|
3
6
|
@name = 'Dell iDrac 6'
|
@@ -17,7 +20,7 @@ class Idrac6 < BaseLom
|
|
17
20
|
v6DHCPEnabled v6DHCPServers v6DNS1 v6DNS2
|
18
21
|
v6SiteLocal v6SiteLocal3 v6SiteLocal4 v6SiteLocal5 v6SiteLocal6 v6SiteLocal7 v6SiteLocal8
|
19
22
|
v6SiteLocal9 v6SiteLocal10 v6SiteLocal11 v6SiteLocal12 v6SiteLocal13 v6SiteLocal14 v6SiteLocal15
|
20
|
-
ipmiLAN ipmiMinPriv
|
23
|
+
ipmiLAN ipmiMinPriv hostname
|
21
24
|
]
|
22
25
|
|
23
26
|
def initialize hostname, options = {}
|
@@ -151,12 +154,44 @@ class Idrac6 < BaseLom
|
|
151
154
|
end]
|
152
155
|
end
|
153
156
|
|
157
|
+
action :set_params, 'Set iDRAC parameters'
|
158
|
+
def set_params
|
159
|
+
unless @params
|
160
|
+
raise "Params are not set!"
|
161
|
+
end
|
162
|
+
drac_set_params @params
|
163
|
+
end
|
164
|
+
|
154
165
|
action :enable_ipmi, 'Enable IPMI over LAN (on LOM port)'
|
155
166
|
def enable_ipmi
|
156
|
-
|
157
|
-
|
167
|
+
drac_set_params({ 'ipmiLAN' => 1 })
|
168
|
+
end
|
169
|
+
|
170
|
+
def drac_set_params params
|
171
|
+
params.each do |p,v|
|
172
|
+
req = @session.post "data?set=#{p}:#{v}", {}
|
173
|
+
raise ResponseError.new req unless req.status == 200
|
174
|
+
end
|
158
175
|
return nil
|
159
176
|
end
|
160
177
|
|
178
|
+
action :show_console_preview, 'Display iDRAC console screenshot'
|
179
|
+
action :save_console_preview, 'Save iDRAC console screenshot'
|
180
|
+
|
181
|
+
def fetch_console_preview
|
182
|
+
imgfile = Tempfile.new('console_preview')
|
183
|
+
|
184
|
+
refreshreq = @session.get "data?get=consolepreview[auto%20#{Time.now.utc.to_i}]", {}
|
185
|
+
|
186
|
+
raise ResponseError.new req unless refreshreq.status == 200
|
187
|
+
|
188
|
+
req = @session.get_file "capconsole/scapture0.png?#{Time.now.utc.to_i}", imgfile.path
|
189
|
+
|
190
|
+
raise ResponseError.new req unless req.status == 200
|
191
|
+
raise UnexpectedContentError.new req unless req.headers['Content-type'] =~ /image\//
|
192
|
+
|
193
|
+
return imgfile, req.headers
|
194
|
+
end
|
195
|
+
|
161
196
|
end
|
162
197
|
end
|
data/lib/moob/idrac7.rb
CHANGED
@@ -17,7 +17,7 @@ class Idrac7 < BaseLom
|
|
17
17
|
v6DHCPEnabled v6DHCPServers v6DNS1 v6DNS2
|
18
18
|
v6SiteLocal v6SiteLocal3 v6SiteLocal4 v6SiteLocal5 v6SiteLocal6 v6SiteLocal7 v6SiteLocal8
|
19
19
|
v6SiteLocal9 v6SiteLocal10 v6SiteLocal11 v6SiteLocal12 v6SiteLocal13 v6SiteLocal14 v6SiteLocal15
|
20
|
-
ipmiLAN ipmiMinPriv ipmiKey
|
20
|
+
ipmiLAN ipmiMinPriv ipmiKey hostname
|
21
21
|
]
|
22
22
|
|
23
23
|
def initialize hostname, options = {}
|
@@ -180,12 +180,44 @@ class Idrac7 < BaseLom
|
|
180
180
|
end]
|
181
181
|
end
|
182
182
|
|
183
|
+
action :set_params, 'Set iDRAC parameters'
|
184
|
+
def set_params
|
185
|
+
unless @params
|
186
|
+
raise "Params are not set!"
|
187
|
+
end
|
188
|
+
drac_set_params @params
|
189
|
+
end
|
190
|
+
|
183
191
|
action :enable_ipmi, 'Enable IPMI over LAN (on LOM port)'
|
184
192
|
def enable_ipmi
|
185
|
-
|
186
|
-
|
193
|
+
drac_set_params({ 'ipmiLAN' => 1 })
|
194
|
+
end
|
195
|
+
|
196
|
+
def drac_set_params params
|
197
|
+
params.each do |p,v|
|
198
|
+
req = @session.post "data?set=#{p}:#{v}", {}
|
199
|
+
raise ResponseError.new req unless req.status == 200
|
200
|
+
end
|
187
201
|
return nil
|
188
202
|
end
|
189
203
|
|
204
|
+
action :show_console_preview, 'Display iDRAC console screenshot'
|
205
|
+
action :save_console_preview, 'Save iDRAC console screenshot'
|
206
|
+
|
207
|
+
def fetch_console_preview
|
208
|
+
imgfile = Tempfile.new('console_preview')
|
209
|
+
|
210
|
+
refreshreq = @session.get "data?get=consolepreview[auto%20#{Time.now.utc.to_i}]", {}
|
211
|
+
|
212
|
+
raise ResponseError.new req unless refreshreq.status == 200
|
213
|
+
|
214
|
+
req = @session.get_file "capconsole/scapture0.png?#{Time.now.utc.to_i}", imgfile.path
|
215
|
+
|
216
|
+
raise ResponseError.new req unless req.status == 200
|
217
|
+
raise UnexpectedContentError.new req unless req.headers['Content-type'] =~ /image\//
|
218
|
+
|
219
|
+
return imgfile, req.headers
|
220
|
+
end
|
221
|
+
|
190
222
|
end
|
191
223
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: patron
|
16
|
-
requirement: &
|
16
|
+
requirement: &70155657258840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.14
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70155657258840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70155657258380 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.5.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70155657258380
|
36
36
|
description: Control systems using Web-based out-of-band managers without a browser
|
37
37
|
email:
|
38
38
|
- pierre@spotify.com
|