moob 0.3.12 → 0.3.15
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 +15 -0
- data/lib/moob.rb +10 -8
- data/lib/moob/idrac7.rb +19 -14
- data/lib/moob/supermicro.rb +71 -0
- metadata +20 -15
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTk1OTgxOTAwMDdmODUxNTYwMjIyZjE5MTAzNTI2ZDAwNDNmYjFkNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZmYxMjlkMmVhY2QxZDRkZTYwZWVjODZhZDE5NDBlMmU0NTkwMWQwMA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZWVkZTNkZGNlOGEyNjBjOTM3ZDhkNGYxNGZmOTVkYTZmNzYwY2QwODIzYzNl
|
10
|
+
MTYwYTBiYTNhMDczNWM3MDM1M2RmNGU1YjZiNWY2MDE2Mjc0ZmM3NjM4Yzli
|
11
|
+
Y2FmZjI5NTVlYjlhN2ZkOWQ1MjViOGJhZTY2YTU2YzUyZWFiOTQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZmRmZTViMjk5YzJjNDZmYTY2MjM5MTJkZTViNGM1MGI0Nzk4NWMyMzcwODQw
|
14
|
+
OWRjODYwOTdlM2JjZTFmMzQ0NWUzNGFjNjJjMDcwNmNhNmYyMGMyZTNjMGI5
|
15
|
+
ODVlOWUwOTYwOGQ5Y2Q5MjkyNDJmYjZkODQwOTFkMmY3NzNiZjQ=
|
data/lib/moob.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'tempfile'
|
2
3
|
|
3
4
|
module Moob
|
4
|
-
VERSION = [0,3,
|
5
|
+
VERSION = [0,3,15]
|
5
6
|
|
6
7
|
class ResponseError < Exception
|
7
8
|
def initialize response
|
@@ -18,16 +19,18 @@ module Moob
|
|
18
19
|
autoload :Megatrends, 'moob/megatrends.rb'
|
19
20
|
autoload :SunILom, 'moob/sunilom.rb'
|
20
21
|
autoload :IbmEServer, 'moob/ibmeserver.rb'
|
22
|
+
autoload :Supermicro, 'moob/supermicro.rb'
|
21
23
|
|
22
24
|
TYPES = {
|
23
25
|
:idrac6 => Idrac6,
|
24
26
|
:idrac7 => Idrac7,
|
25
27
|
:megatrends => Megatrends,
|
26
28
|
:sun => SunILom,
|
27
|
-
:ibm => IbmEServer
|
29
|
+
:ibm => IbmEServer,
|
30
|
+
:supermicro => Supermicro
|
28
31
|
}
|
29
32
|
|
30
|
-
AUTODETECT_ORDER = [ :idrac7, :idrac6, :megatrends, :sun, :ibm ]
|
33
|
+
AUTODETECT_ORDER = [ :idrac7, :idrac6, :supermicro, :megatrends, :sun, :ibm ]
|
31
34
|
|
32
35
|
def self.lom type, hostname, options = {}
|
33
36
|
case type
|
@@ -55,12 +58,11 @@ module Moob
|
|
55
58
|
raise "Invalid JNLP file (\"#{jnlp}\")"
|
56
59
|
end
|
57
60
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
61
|
+
tmpfile = Tempfile.new("#{lom.hostname}_#{Time.now.to_i}.jnlp")
|
62
|
+
tmpfile.write jnlp
|
63
|
+
tmpfile.close
|
62
64
|
|
63
|
-
raise 'javaws failed' unless system "javaws -wait #{
|
65
|
+
raise 'javaws failed' unless system "javaws -wait #{tmpfile.path}"
|
64
66
|
end
|
65
67
|
|
66
68
|
def self.show_console_preview lom
|
data/lib/moob/idrac7.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Moob
|
2
|
+
|
2
3
|
class Idrac7 < BaseLom
|
3
4
|
@name = 'Dell iDrac 7'
|
4
5
|
|
@@ -29,6 +30,8 @@ class Idrac7 < BaseLom
|
|
29
30
|
|
30
31
|
def authenticate
|
31
32
|
@session.handle_cookies nil
|
33
|
+
# Needed for new version of iDrac emb web server to even responde
|
34
|
+
@session.headers['Accept-Language'] = 'en-US,en;q=0.8,sv;q=0.6'
|
32
35
|
|
33
36
|
login = @session.get 'login.html'
|
34
37
|
|
@@ -57,16 +60,22 @@ class Idrac7 < BaseLom
|
|
57
60
|
end
|
58
61
|
|
59
62
|
Moob.inform "Requesting indexurl of #{@indexurl}"
|
60
|
-
@authhash = @indexurl.split('?')[1]
|
61
|
-
|
62
|
-
@index = @session.get @indexurl
|
63
63
|
|
64
64
|
# someone decided it was a good idea to include a ST2 token in every XHR
|
65
65
|
# request. We need it for a lot of our features.
|
66
|
-
@
|
67
|
-
|
66
|
+
@authhash = @indexurl.split('?')[1]
|
67
|
+
@authhash =~ /ST2=([0-9a-f]+)/
|
68
68
|
@st2 = $1
|
69
69
|
|
70
|
+
if @st2.nil?
|
71
|
+
Moob.inform 'Trying to parse ST2 token from HTML page'
|
72
|
+
|
73
|
+
@index = @session.get @indexurl
|
74
|
+
@index.body =~ /var TOKEN_VALUE = "([0-9a-f]+)";/
|
75
|
+
raise ResponseError.new @index unless @index.status == 200
|
76
|
+
@st2 = $1
|
77
|
+
end
|
78
|
+
|
70
79
|
@session.headers['ST2'] = @st2
|
71
80
|
|
72
81
|
return self
|
@@ -81,7 +90,7 @@ class Idrac7 < BaseLom
|
|
81
90
|
def detect
|
82
91
|
begin
|
83
92
|
home = @session.get 'login.html'
|
84
|
-
home.body =~ /Integrated Dell Remote Access Controller 7/
|
93
|
+
home.body =~ /(Integrated Dell Remote Access Controller 7)|(iDRAC7)/
|
85
94
|
rescue
|
86
95
|
false
|
87
96
|
end
|
@@ -90,16 +99,11 @@ class Idrac7 < BaseLom
|
|
90
99
|
action :jnlp, 'Remote control'
|
91
100
|
|
92
101
|
def jnlp
|
93
|
-
|
94
|
-
|
95
|
-
dns_name = $1
|
96
|
-
|
97
|
-
@index.body =~ /var sysNameStr += +"([^"]+)"/
|
98
|
-
raise "Couldn't find the system name" unless $&
|
99
|
-
sys_name = $1 # eg PowerEdge R610
|
102
|
+
# Request system name and hostname from data end-point
|
103
|
+
req = get_infos ['sysDesc' ,'hostname']
|
100
104
|
|
101
105
|
# eg escaped "idrac-A1BCD2E, PowerEdge R610, User:root"
|
102
|
-
title = CGI::escape "#{
|
106
|
+
title = CGI::escape "#{req['hostname']}, #{req['sysDesc']}, User:#{@username}"
|
103
107
|
|
104
108
|
viewer = @session.get "viewer.jnlp(#{@hostname}@0@#{title}@#{Time.now.to_i * 1000}@#{@authhash})"
|
105
109
|
raise ResponseError.new viewer unless viewer.status == 200
|
@@ -166,6 +170,7 @@ class Idrac7 < BaseLom
|
|
166
170
|
end
|
167
171
|
|
168
172
|
def get_infos keys
|
173
|
+
Moob.inform "Requesting data?get=#{keys.join(',')}"
|
169
174
|
infos = @session.post "data?get=#{keys.join(',')}", {}
|
170
175
|
|
171
176
|
raise ResponseError.new infos unless infos.status == 200
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Moob
|
2
|
+
class Supermicro < BaseLom
|
3
|
+
@name = 'Supermicro'
|
4
|
+
|
5
|
+
def initialize hostname, options = {}
|
6
|
+
super hostname, options
|
7
|
+
@username ||= 'ADMIN'
|
8
|
+
@password ||= 'ADMIN'
|
9
|
+
begin
|
10
|
+
@ip = Socket.getaddrinfo(hostname, nil)[0][3]
|
11
|
+
rescue
|
12
|
+
raise "Couldn't resolve \"#{hostname}\""
|
13
|
+
end
|
14
|
+
@session.base_url = "#{@transport}://#{@ip}/"
|
15
|
+
end
|
16
|
+
|
17
|
+
def authenticate
|
18
|
+
@session.handle_cookies nil
|
19
|
+
auth = @session.post 'cgi/login.cgi',
|
20
|
+
"name=#{@username}&pwd=#{@password}"
|
21
|
+
|
22
|
+
raise ResponseError.new auth unless auth.status == 200
|
23
|
+
return self
|
24
|
+
end
|
25
|
+
|
26
|
+
def detect
|
27
|
+
begin
|
28
|
+
home = @session.get '/'
|
29
|
+
home.body =~ /META NAME=\"ATEN International Co Ltd\.\"/
|
30
|
+
rescue
|
31
|
+
false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def power_action action
|
36
|
+
time_s = Time.now.strftime("%a %b %d %Y %H:%M:%S")
|
37
|
+
req = @session.get "cgi/ipmi.cgi?POWER_INFO.XML=" + CGI::escape(action) + "&time_stamp=" + CGI::escape(time_s)
|
38
|
+
raise ResponseError.new req unless req.status == 200
|
39
|
+
unless req.body =~ /POWER_INFO/
|
40
|
+
raise 'The answer looks wrong'
|
41
|
+
end
|
42
|
+
return nil
|
43
|
+
end
|
44
|
+
|
45
|
+
action :poff, 'Power Off'
|
46
|
+
action :pon, 'Power On'
|
47
|
+
action :pcycle, 'Power Cycle'
|
48
|
+
action :preset, 'Power Reset'
|
49
|
+
action :shutdown, 'Soft Power Off'
|
50
|
+
def poff; power_action "(1,0)"; end
|
51
|
+
def pon; power_action "(1,1)"; end
|
52
|
+
def pcycle; power_action "(1,2)"; end
|
53
|
+
def preset; power_action "(1,3)"; end
|
54
|
+
def shutdown; power_action "(1,5)"; end
|
55
|
+
|
56
|
+
action :pstatus, 'Power status'
|
57
|
+
def pstatus
|
58
|
+
time_s = Time.now.strftime("%a %b %d %Y %H:%M:%S")
|
59
|
+
status = @session.get "cgi/ipmi.cgi?POWER_INFO.XML=(0%2C0)&time_stamp=" + CGI::escape(time_s)
|
60
|
+
raise ResponseError.new status unless status.status == 200
|
61
|
+
raise 'Couldn\'t read the state' unless status.body =~ /POWER STATUS=\"([A-Z]+)\"/
|
62
|
+
case $1
|
63
|
+
when 'OFF'
|
64
|
+
return :off
|
65
|
+
when 'ON'
|
66
|
+
return :on
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,38 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.15
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Pierre Carrier
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: patron
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.4.14
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.4.14
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: json
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 1.5.3
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.3
|
36
41
|
description: Control systems using Web-based out-of-band managers without a browser
|
37
42
|
email:
|
38
43
|
- pierre@spotify.com
|
@@ -41,38 +46,38 @@ executables:
|
|
41
46
|
extensions: []
|
42
47
|
extra_rdoc_files: []
|
43
48
|
files:
|
49
|
+
- COPYING
|
44
50
|
- bin/moob
|
51
|
+
- lib/moob.rb
|
45
52
|
- lib/moob/baselom.rb
|
46
53
|
- lib/moob/ibmeserver.rb
|
47
54
|
- lib/moob/idrac6.rb
|
48
55
|
- lib/moob/idrac7.rb
|
49
56
|
- lib/moob/megatrends.rb
|
50
57
|
- lib/moob/sunilom.rb
|
51
|
-
- lib/moob.rb
|
52
|
-
- COPYING
|
58
|
+
- lib/moob/supermicro.rb
|
53
59
|
homepage: https://github.com/spotify/moob
|
54
60
|
licenses:
|
55
61
|
- ISC
|
62
|
+
metadata: {}
|
56
63
|
post_install_message:
|
57
64
|
rdoc_options: []
|
58
65
|
require_paths:
|
59
66
|
- lib
|
60
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
68
|
requirements:
|
63
69
|
- - ! '>='
|
64
70
|
- !ruby/object:Gem::Version
|
65
71
|
version: '0'
|
66
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
73
|
requirements:
|
69
74
|
- - ! '>='
|
70
75
|
- !ruby/object:Gem::Version
|
71
76
|
version: 1.2.0
|
72
77
|
requirements: []
|
73
78
|
rubyforge_project: moob
|
74
|
-
rubygems_version:
|
79
|
+
rubygems_version: 2.2.2
|
75
80
|
signing_key:
|
76
|
-
specification_version:
|
81
|
+
specification_version: 4
|
77
82
|
summary: Manage Out-Of-Band!
|
78
83
|
test_files: []
|