moob 0.3.15 → 0.3.16
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.
- checksums.yaml +8 -8
- data/lib/moob.rb +1 -1
- data/lib/moob/idrac7.rb +12 -2
- data/lib/moob/pec.rb +164 -0
- data/lib/moob/supermicro.rb +8 -0
- data/lib/moob/version.rb +3 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWY1NjAwYTJkYzk2MjhjM2VlZWMxNzczMjFlNTNiNTZiZGY3ZmM0NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTk0N2I3ZGE2NDUxZDczNmIxYjM0MmM0Y2M4ODVhMWFjOGMyMzU2Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmIzNmRkNWU1MzIzZjViZWY1NWI0MzVhM2E5YjdjZmVhNzRmYjBhZjQ4ZDgy
|
10
|
+
MmY5Nzk0NjA2NTdkNTk0NjA3MjFmMzA4MTFiNzU3YWJjNjZjMmE4ZDVkY2Ji
|
11
|
+
ZmVkZGY2N2I0NDZiZjNiNjZlMzgzODRjMTc0OWVhOWVhODYyYzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmI5Y2ViMWNiZmY4ZWM2MDY3YjU1NWVkODMzYWQ5Yjg5YmNjNjBmZjEyMThk
|
14
|
+
ZmEwMjZhMGQ2NGY5NDJhMGNlNDE2NWIxNDk2ODY5YmYyYTQxNDk5NzAyMjcx
|
15
|
+
ZWUxMjM1ZmE0M2ZhNzE0MDAwOTZkMzgxOGE1ZjA5MDRhYTNmMGI=
|
data/lib/moob.rb
CHANGED
@@ -2,7 +2,6 @@ require 'fileutils'
|
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
4
|
module Moob
|
5
|
-
VERSION = [0,3,15]
|
6
5
|
|
7
6
|
class ResponseError < Exception
|
8
7
|
def initialize response
|
@@ -13,6 +12,7 @@ module Moob
|
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
15
|
+
autoload :VERSION, 'moob/version.rb'
|
16
16
|
autoload :BaseLom, 'moob/baselom.rb'
|
17
17
|
autoload :Idrac6, 'moob/idrac6.rb'
|
18
18
|
autoload :Idrac7, 'moob/idrac7.rb'
|
data/lib/moob/idrac7.rb
CHANGED
@@ -82,8 +82,12 @@ class Idrac7 < BaseLom
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def logout
|
85
|
-
|
86
|
-
|
85
|
+
if @skiplogout
|
86
|
+
Moob.inform 'Skipping logout...'
|
87
|
+
else
|
88
|
+
out = @session.get 'data/logout'
|
89
|
+
raise ResponseError.new out unless out.status == 200
|
90
|
+
end
|
87
91
|
return self
|
88
92
|
end
|
89
93
|
|
@@ -224,5 +228,11 @@ class Idrac7 < BaseLom
|
|
224
228
|
return imgfile, req.headers
|
225
229
|
end
|
226
230
|
|
231
|
+
action :lomreset, 'Reset LOM'
|
232
|
+
def lomreset
|
233
|
+
@skiplogout = true
|
234
|
+
drac_set_params({ 'iDracReset' => 1 })
|
235
|
+
end
|
236
|
+
|
227
237
|
end
|
228
238
|
end
|
data/lib/moob/pec.rb
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
module Moob
|
2
|
+
class Pec < BaseLom
|
3
|
+
@name = 'Dell PowerEdge C series'
|
4
|
+
|
5
|
+
INFO_FIELDS = %w[
|
6
|
+
asic certificate
|
7
|
+
chassisFLEDStatus chassisILEDStatus chassisName
|
8
|
+
biosVer fwUpdated fwVersion hostname hwVersion
|
9
|
+
ipmiKey ipmiLAN ipmiMinPriv
|
10
|
+
productDescription productName pwState
|
11
|
+
serialOverLanBaud serialOverLanEnabled serialOverLanPriv
|
12
|
+
hostname
|
13
|
+
ifName macAddr autoNeg v4Enabled v4DHCPEnabled v4IPAddr
|
14
|
+
v4NetMask v4Gateway
|
15
|
+
]
|
16
|
+
|
17
|
+
def initialize hostname, options = {}
|
18
|
+
super hostname, options
|
19
|
+
@username ||= 'root'
|
20
|
+
@password ||= 'root'
|
21
|
+
@index = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def authenticate
|
25
|
+
@session.handle_cookies nil
|
26
|
+
|
27
|
+
login = @session.get 'login.html'
|
28
|
+
|
29
|
+
raise ResponseError.new login unless login.status == 200
|
30
|
+
|
31
|
+
auth = @session.post 'data/login', "user=#{@username}&password=#{@password}"
|
32
|
+
|
33
|
+
raise ResponseError.new auth unless auth.status == 200
|
34
|
+
|
35
|
+
auth.body =~ /<authResult>([^<]+)<\/authResult>/
|
36
|
+
|
37
|
+
raise 'Cannot find auth result' unless $&
|
38
|
+
raise "Auth failed with: \"#{auth.body}\"" unless $1 == "0"
|
39
|
+
|
40
|
+
auth.body =~ /<forwardUrl>([^<]+)<\/forwardUrl>/
|
41
|
+
|
42
|
+
raise 'Cannot find the authenticated index url after auth' unless $&
|
43
|
+
|
44
|
+
@indexurl = $1
|
45
|
+
|
46
|
+
|
47
|
+
Moob.inform "Requesting indexurl of #{@indexurl}"
|
48
|
+
@authhash = @indexurl.split('?')[1]
|
49
|
+
|
50
|
+
@index = @session.get @indexurl
|
51
|
+
|
52
|
+
# someone decided it was a good idea to include a ST2 token in every XHR
|
53
|
+
# request. We need it for a lot of our features.
|
54
|
+
@index.body =~ /var CSRF_TOKEN_2_VALUE = "([0-9a-f]+)";/
|
55
|
+
raise ResponseError.new @index unless @index.status == 200
|
56
|
+
@st2 = $1
|
57
|
+
|
58
|
+
@session.headers['ST2'] = @st2
|
59
|
+
|
60
|
+
return self
|
61
|
+
end
|
62
|
+
|
63
|
+
def logout
|
64
|
+
out = @session.get 'data/logout'
|
65
|
+
raise ResponseError.new out unless out.status == 200
|
66
|
+
return self
|
67
|
+
end
|
68
|
+
|
69
|
+
def detect
|
70
|
+
begin
|
71
|
+
home = @session.get 'login.html'
|
72
|
+
home.body =~ /Dell Remote Management Controller/
|
73
|
+
rescue
|
74
|
+
false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
action :jnlp, 'Remote control'
|
79
|
+
|
80
|
+
def jnlp
|
81
|
+
# On PEC LOM CSRF_TOKEN_1 carries the auth token
|
82
|
+
@index.body =~ /var CSRF_TOKEN_1\s+= \"ST1\" \+ \"=\" \+ "([0-9a-f]+)";/
|
83
|
+
@st1 = $1
|
84
|
+
|
85
|
+
viewer = @session.get "viewer.jnlp(#{@hostname}@0@#{Time.now.to_i * 1000})?ST1=#{@st1}"
|
86
|
+
raise ResponseError.new viewer unless viewer.status == 200
|
87
|
+
|
88
|
+
return viewer.body
|
89
|
+
end
|
90
|
+
|
91
|
+
def power_control action
|
92
|
+
req = @session.post "data?set=pwState:#{action}", {}
|
93
|
+
raise ResponseError.new req unless req.status == 200
|
94
|
+
return nil
|
95
|
+
end
|
96
|
+
|
97
|
+
[
|
98
|
+
[0, :poff, 'Power Off System'],
|
99
|
+
[1, :pon, 'Power On System'],
|
100
|
+
[2, :pcycle, 'Power Cycle System (cold boot)'],
|
101
|
+
[3, :preset, 'Reset System (warm boot)'],
|
102
|
+
[4, :nmi, 'NMI (Non-Masking Interrupt)'],
|
103
|
+
[5, :shutdown, 'Graceful Shutdown']
|
104
|
+
].each do |code, name, desc|
|
105
|
+
action name, desc
|
106
|
+
class_eval %{def #{name}; power_control #{code}; end}
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
action :pstatus, 'Power status'
|
111
|
+
def pstatus
|
112
|
+
case get_infos(['pwState'])['pwState']
|
113
|
+
when '0'
|
114
|
+
return :off
|
115
|
+
when '1'
|
116
|
+
return :on
|
117
|
+
else
|
118
|
+
return nil
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
action :infos, 'Get system information'
|
123
|
+
def infos
|
124
|
+
return JSON.pretty_generate get_infos INFO_FIELDS
|
125
|
+
end
|
126
|
+
|
127
|
+
def get_infos keys
|
128
|
+
infos = @session.post "data?get=#{keys.join(',')}", {}
|
129
|
+
|
130
|
+
raise ResponseError.new infos unless infos.status == 200
|
131
|
+
raise "The status isn't OK" unless infos.body =~ /<status>ok<\/status>/
|
132
|
+
|
133
|
+
return Hash[keys.collect do |k|
|
134
|
+
if infos.body =~ /<#{k}>(.*?)<\/#{k}>/
|
135
|
+
[k, $1]
|
136
|
+
else
|
137
|
+
[k, nil]
|
138
|
+
end
|
139
|
+
end]
|
140
|
+
end
|
141
|
+
|
142
|
+
action :set_params, 'Set LOM parameters'
|
143
|
+
def set_params
|
144
|
+
unless @params
|
145
|
+
raise "Params are not set!"
|
146
|
+
end
|
147
|
+
drac_set_params @params
|
148
|
+
end
|
149
|
+
|
150
|
+
action :enable_ipmi, 'Enable IPMI over LAN (on LOM port)'
|
151
|
+
def enable_ipmi
|
152
|
+
drac_set_params({ 'ipmiLAN' => 1 })
|
153
|
+
end
|
154
|
+
|
155
|
+
def drac_set_params params
|
156
|
+
params.each do |p,v|
|
157
|
+
req = @session.post "data?set=#{p}:#{v}", {}
|
158
|
+
raise ResponseError.new req unless req.status == 200
|
159
|
+
end
|
160
|
+
return nil
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
end
|
data/lib/moob/supermicro.rb
CHANGED
@@ -67,5 +67,13 @@ class Supermicro < BaseLom
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
action :jnlp, 'Remote control'
|
71
|
+
def jnlp
|
72
|
+
viewer = @session.get 'cgi/url_redirect.cgi?url_name=&url_type=jwsk'
|
73
|
+
raise ResponseError.new viewer unless viewer.status == 200
|
74
|
+
|
75
|
+
return viewer.body
|
76
|
+
end
|
77
|
+
|
70
78
|
end
|
71
79
|
end
|
data/lib/moob/version.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Nathan Ferch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: patron
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version: 1.5.3
|
41
41
|
description: Control systems using Web-based out-of-band managers without a browser
|
42
42
|
email:
|
43
|
-
-
|
43
|
+
- nf@spotify.com
|
44
44
|
executables:
|
45
45
|
- moob
|
46
46
|
extensions: []
|
@@ -54,8 +54,10 @@ files:
|
|
54
54
|
- lib/moob/idrac6.rb
|
55
55
|
- lib/moob/idrac7.rb
|
56
56
|
- lib/moob/megatrends.rb
|
57
|
+
- lib/moob/pec.rb
|
57
58
|
- lib/moob/sunilom.rb
|
58
59
|
- lib/moob/supermicro.rb
|
60
|
+
- lib/moob/version.rb
|
59
61
|
homepage: https://github.com/spotify/moob
|
60
62
|
licenses:
|
61
63
|
- ISC
|