ilorb 0.0.3 → 0.0.4
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 +4 -4
- data/.rubocop.yml +25 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +15 -0
- data/README.md +0 -1
- data/Rakefile +3 -1
- data/ilorb.gemspec +4 -3
- data/lib/ilorb.rb +43 -50
- data/lib/ilorb/definitions/rib.rb +12 -7
- data/lib/ilorb/definitions/server.rb +4 -2
- data/lib/ilorb/definitions/user.rb +2 -1
- data/lib/ilorb/ribcl.rb +6 -9
- data/lib/ilorb/version.rb +2 -1
- data/spec/assets/certificate.crt +31 -0
- data/spec/assets/certificate_signing_request_request.xml +15 -0
- data/spec/assets/get_network_settings_request.xml +8 -0
- data/spec/assets/import_certificate_request.xml +39 -0
- data/spec/assets/server_auto_pwr_request.xml +8 -0
- data/spec/assets/set_one_time_boot_request.xml +8 -0
- data/spec/assets/set_persistent_boot_request.xml +11 -0
- data/spec/assets/set_pwreg_request.xml +11 -0
- data/spec/definitions/test.rb +33 -0
- data/spec/ilo_spec.rb +66 -32
- data/spec/spec_helper.rb +5 -5
- metadata +36 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef13e4245bd8ab4b335dec77e001da8c498c5353
|
4
|
+
data.tar.gz: 285a8b272eba2ae35d1f76aca2a8e2b4082189df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04e755c6e729b2216288cab7250f028684ef2ab63a183a0110123cb2b0b9c54303338daeb67b4d8b49086b1d68769ed070d3aa40df59c591bd168b89f36307a2
|
7
|
+
data.tar.gz: 4d46b5905eca7e3ba167ccf776ae83152e828ddfa8b2a0a031c27db0f58b9a786c5e387966791d24836288cb1dd4483083f0fc82ef7754a3eb7789f2c1dc27d8
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
|
4
|
+
Lint/UnusedBlockArgument:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Max: 120
|
9
|
+
|
10
|
+
Metrics/MethodLength:
|
11
|
+
Max: 15
|
12
|
+
CountComments: false
|
13
|
+
|
14
|
+
Metrics/ClassLength:
|
15
|
+
Max: 150
|
16
|
+
CountComments: false
|
17
|
+
|
18
|
+
Style/StringLiterals:
|
19
|
+
EnforcedStyle: double_quotes
|
20
|
+
|
21
|
+
Style/StringLiteralsInInterpolation:
|
22
|
+
EnforcedStyle: double_quotes
|
23
|
+
|
24
|
+
Style/TrailingComma:
|
25
|
+
EnforcedStyleForMultiline: consistent_comma
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -9,6 +9,9 @@ GEM
|
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
addressable (2.3.5)
|
12
|
+
ast (2.0.0)
|
13
|
+
astrolabe (1.3.0)
|
14
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
12
15
|
coderay (1.0.9)
|
13
16
|
crack (0.4.1)
|
14
17
|
safe_yaml (~> 0.9.0)
|
@@ -18,10 +21,14 @@ GEM
|
|
18
21
|
nokogiri (1.6.6.2)
|
19
22
|
mini_portile (~> 0.6.0)
|
20
23
|
nori (2.5.0)
|
24
|
+
parser (2.2.2.2)
|
25
|
+
ast (>= 1.1, < 3.0)
|
26
|
+
powerpack (0.1.0)
|
21
27
|
pry (0.9.12.2)
|
22
28
|
coderay (~> 1.0.5)
|
23
29
|
method_source (~> 0.8)
|
24
30
|
slop (~> 3.4)
|
31
|
+
rainbow (2.0.0)
|
25
32
|
rspec (2.14.1)
|
26
33
|
rspec-core (~> 2.14.0)
|
27
34
|
rspec-expectations (~> 2.14.0)
|
@@ -30,6 +37,13 @@ GEM
|
|
30
37
|
rspec-expectations (2.14.0)
|
31
38
|
diff-lcs (>= 1.1.3, < 2.0)
|
32
39
|
rspec-mocks (2.14.1)
|
40
|
+
rubocop (0.30.1)
|
41
|
+
astrolabe (~> 1.3)
|
42
|
+
parser (>= 2.2.2.1, < 3.0)
|
43
|
+
powerpack (~> 0.1)
|
44
|
+
rainbow (>= 1.99.1, < 3.0)
|
45
|
+
ruby-progressbar (~> 1.4)
|
46
|
+
ruby-progressbar (1.7.5)
|
33
47
|
safe_yaml (0.9.4)
|
34
48
|
slop (3.4.5)
|
35
49
|
webmock (1.13.0)
|
@@ -44,4 +58,5 @@ DEPENDENCIES
|
|
44
58
|
ilorb!
|
45
59
|
pry
|
46
60
|
rspec (~> 2.14)
|
61
|
+
rubocop
|
47
62
|
webmock (~> 1.13)
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/ilorb.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
|
-
require
|
5
|
+
require "ilorb/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "ilorb"
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/josqu4red/ilorb"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files = `git ls-files`.split(
|
17
|
+
spec.files = `git ls-files`.split($RS)
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rspec", "~> 2.14"
|
24
24
|
spec.add_development_dependency "webmock", "~> 1.13"
|
25
25
|
spec.add_development_dependency "pry"
|
26
|
+
spec.add_development_dependency "rubocop"
|
26
27
|
spec.add_dependency "nokogiri"
|
27
28
|
spec.add_dependency "nori", "~> 2"
|
28
29
|
end
|
data/lib/ilorb.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
|
1
|
+
require "logger"
|
2
|
+
require "socket"
|
3
|
+
require "openssl"
|
4
|
+
require "net/https"
|
5
|
+
require "nokogiri"
|
6
|
+
require "nori"
|
7
|
+
require "ilorb/ribcl"
|
8
|
+
|
9
|
+
# Main library class
|
9
10
|
class ILORb
|
10
|
-
|
11
11
|
def initialize(config = {})
|
12
12
|
@hostname = config[:hostname]
|
13
|
-
@login = config[:login] || "Administrator"
|
14
13
|
@password = config[:password]
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
14
|
+
@login = config.fetch(:login, "Administrator")
|
15
|
+
@port = config.fetch(:port, 443)
|
16
|
+
@protocol = config.fetch(:protocol, :http)
|
17
|
+
@verify_ssl = config.fetch(:verify_ssl, false)
|
18
|
+
@definitions_path = config.fetch(:definitions_path, File.join(File.dirname(__FILE__), "ilorb/definitions"))
|
19
|
+
@ribcl_path = config.fetch(:ribcl_path, "/ribcl")
|
19
20
|
|
20
21
|
@log = Logger.new(STDOUT)
|
21
22
|
@log.level = config[:debug] ? Logger::DEBUG : Logger::WARN
|
22
23
|
|
23
|
-
@nori = Nori.new(:
|
24
|
+
@nori = Nori.new(convert_tags_to: ->(tag) { tag.downcase.to_sym })
|
24
25
|
|
25
26
|
setup_commands
|
26
27
|
end
|
27
28
|
|
28
29
|
# args should be empty or contain a hash anytime
|
29
30
|
def method_missing(name, *args, &block)
|
30
|
-
if @ribcl.
|
31
|
+
if @ribcl.command?(name)
|
31
32
|
command = @ribcl.command(name)
|
32
33
|
|
33
|
-
|
34
|
+
fail RIBCL::NotImplementedError, "#{name} is not supported" unless command.supported?
|
34
35
|
@log.info("Calling method #{name}")
|
35
36
|
|
36
37
|
params = args.first || {}
|
37
38
|
attributes = {}
|
38
|
-
element_map = nil
|
39
39
|
|
40
40
|
command.get_attributes.each do |attr|
|
41
41
|
# Attributes are mandatory
|
42
|
-
|
42
|
+
fail "Attribute #{attr} missing in #{name} call" unless params.key?(attr)
|
43
43
|
attributes.store(attr, @ribcl.encode(params.delete(attr)))
|
44
44
|
end
|
45
45
|
|
@@ -47,26 +47,26 @@ class ILORb
|
|
47
47
|
element_map = command.map_elements
|
48
48
|
|
49
49
|
elements_array = [params].flatten.map do |params_hash|
|
50
|
-
Hash[params_hash.map{ |k,
|
50
|
+
Hash[params_hash.map { |k, _| [k, @ribcl.encode(params_hash.delete(k))] if element_map.key?(k) }.compact]
|
51
51
|
end
|
52
52
|
|
53
|
-
#TODO check for CDATA
|
53
|
+
# TODO: check for CDATA
|
54
54
|
|
55
55
|
request = ribcl_request(command, attributes) do |xml|
|
56
56
|
elements_array.each do |elements_hash|
|
57
57
|
elements_hash.each do |key, value|
|
58
58
|
elt = command.get_elements[element_map[key].first]
|
59
59
|
if elt.is_a?(Array)
|
60
|
-
attrs = Hash[elt.map{|x| [x, elements_hash.delete(element_map.invert[[element_map[key].first, x]])]}]
|
60
|
+
attrs = Hash[elt.map { |x| [x, elements_hash.delete(element_map.invert[[element_map[key].first, x]])] }]
|
61
61
|
else
|
62
|
-
attrs = {element_map[key].last => value}
|
62
|
+
attrs = { element_map[key].last => value }
|
63
63
|
end
|
64
64
|
xml.send(element_map[key].first, attrs)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
68
|
elsif !command.get_text.nil?
|
69
|
-
if text = params[command.get_text]
|
69
|
+
if (text = params[command.get_text])
|
70
70
|
request = ribcl_request(command, text, attributes)
|
71
71
|
end
|
72
72
|
else
|
@@ -74,33 +74,33 @@ class ILORb
|
|
74
74
|
end
|
75
75
|
|
76
76
|
response = send_request(request)
|
77
|
-
parse_response(response
|
77
|
+
parse_response(response)
|
78
78
|
else
|
79
79
|
super
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
def respond_to(name)
|
84
|
-
@ribcl.
|
84
|
+
@ribcl.command?(name) ? true : super
|
85
85
|
end
|
86
86
|
|
87
87
|
def supported_commands
|
88
|
-
@ribcl.select{|
|
88
|
+
@ribcl.select { |_, command| command.supported? }.keys
|
89
89
|
end
|
90
90
|
|
91
91
|
private
|
92
92
|
|
93
|
-
def ribcl_request(command, *args
|
93
|
+
def ribcl_request(command, *args)
|
94
94
|
builder = Nokogiri::XML::Builder.new do |xml|
|
95
|
-
xml.ribcl(:
|
96
|
-
xml.login(:
|
97
|
-
xml.send(command.context, :
|
98
|
-
xml.send(command.name, *args)
|
95
|
+
xml.ribcl(version: "2.0") do
|
96
|
+
xml.login(password: @password, user_login: @login) do
|
97
|
+
xml.send(command.context, mode: command.mode) do
|
98
|
+
xml.send(command.name, *args) do
|
99
99
|
yield xml if block_given?
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
104
|
end
|
105
105
|
|
106
106
|
builder.to_xml
|
@@ -145,11 +145,11 @@ class ILORb
|
|
145
145
|
ssl_sock.sync_close = true
|
146
146
|
|
147
147
|
@log.info("Connecting to #{@hostname}:#{@port}")
|
148
|
-
ssl_sock.connect
|
149
148
|
@log.debug("Request:\n#{xml}")
|
149
|
+
ssl_sock.connect
|
150
150
|
ssl_sock.puts("#{xml}\r\n")
|
151
151
|
response = ""
|
152
|
-
while line = ssl_sock.gets
|
152
|
+
while (line = ssl_sock.gets)
|
153
153
|
response += line
|
154
154
|
end
|
155
155
|
ssl_sock.close
|
@@ -157,7 +157,7 @@ class ILORb
|
|
157
157
|
response
|
158
158
|
end
|
159
159
|
|
160
|
-
def parse_response(xml
|
160
|
+
def parse_response(xml)
|
161
161
|
@log.debug("Response:\n#{xml}")
|
162
162
|
|
163
163
|
# ILO sends back multiple XML documents, split by XML header and remove first (empty)
|
@@ -166,17 +166,15 @@ class ILORb
|
|
166
166
|
output = {}
|
167
167
|
|
168
168
|
messages.each do |doc|
|
169
|
-
xml_doc = Nokogiri::XML(doc){|cfg| cfg.nonet.noblanks}
|
169
|
+
xml_doc = Nokogiri::XML(doc) { |cfg| cfg.nonet.noblanks }
|
170
170
|
|
171
171
|
xml_doc.root.children.each do |node|
|
172
172
|
case node.name
|
173
173
|
when "RESPONSE"
|
174
174
|
code = node.attr("STATUS").to_i(16)
|
175
175
|
message = node.attr("MESSAGE")
|
176
|
-
|
177
|
-
|
178
|
-
else
|
179
|
-
output[:status] = { :code => code, :message => message }
|
176
|
+
output[:status] = { code: code, message: message }
|
177
|
+
if code != 0
|
180
178
|
@log.error("#{message} (#{code})")
|
181
179
|
break
|
182
180
|
end
|
@@ -192,12 +190,7 @@ class ILORb
|
|
192
190
|
end
|
193
191
|
|
194
192
|
def setup_commands
|
195
|
-
@ribcl = ILORb::RIBCL.load(File.join(
|
193
|
+
@ribcl = ILORb::RIBCL.load(File.join(@definitions_path, "*.rb"))
|
196
194
|
nil
|
197
195
|
end
|
198
|
-
|
199
|
-
def error(message)
|
200
|
-
@log.error(message)
|
201
|
-
raise message
|
202
|
-
end
|
203
196
|
end
|
@@ -50,22 +50,27 @@ context :rib_info do
|
|
50
50
|
attributes :device, :image_url
|
51
51
|
end
|
52
52
|
write_cmd :license do
|
53
|
-
elements :
|
53
|
+
elements activate: :key
|
54
54
|
end
|
55
55
|
write_cmd :mod_global_settings do
|
56
|
-
elements :session_timeout, :f8_prompt_enabled, :http_port, :https_port, :remote_console_port, :min_password,
|
56
|
+
elements :session_timeout, :f8_prompt_enabled, :http_port, :https_port, :remote_console_port, :min_password,
|
57
|
+
:ilo_funct_enabled, :virtual_media_port, :f8_login_required, :enforce_aes, :authentication_failure_logging,
|
58
|
+
:ssh_status, :ssh_port, :serial_cli_status, :serial_cli_speed, :rbsu_post_ip, :snmp_access_enabled,
|
59
|
+
:snmp_port, :snmp_trap_port, :remote_syslog_enable, :remote_syslog_port, :remote_syslog_server_address,
|
60
|
+
:alertmail_enable, :alertmail_email_address, :alertmail_sender_domain, :alertmail_smtp_server,
|
61
|
+
:ipmi_dcmi_over_lan_enabled, :vsp_log_enable
|
57
62
|
end
|
58
63
|
write_cmd :mod_network_settings do
|
59
64
|
elements :enable_nic, :nic_speed, :full_duplex, :speed_autoselect, :ping_gateway,
|
60
65
|
:shared_network_port, :vlan_enabled, :vlan_id,
|
61
|
-
:dhcp_enable, :dhcp_domain_name, :dhcp_gateway, :dhcp_dns_server, :dhcp_wins_server, :dhcp_static_route,
|
62
|
-
:ip_address, :subnet_mask, :gateway_ip_address, :dns_name, :domain_name,
|
66
|
+
:dhcp_enable, :dhcp_domain_name, :dhcp_gateway, :dhcp_dns_server, :dhcp_wins_server, :dhcp_static_route,
|
67
|
+
:dhcp_sntp_settings, :ip_address, :subnet_mask, :gateway_ip_address, :dns_name, :domain_name,
|
63
68
|
:prim_dns_server, :sec_dns_server, :ter_dns_server, :reg_ddns_server,
|
64
69
|
:prim_wins_server, :sec_wins_server, :reg_wins_server,
|
65
70
|
:sntp_server1, :sntp_server2, :timezone,
|
66
71
|
:enclosure_ip_enable, :web_agent_ip_address
|
67
72
|
end
|
68
|
-
write_cmd :mod_snmp_im_settings do #TODO
|
73
|
+
write_cmd :mod_snmp_im_settings do # TODO
|
69
74
|
not_implemented
|
70
75
|
end
|
71
76
|
write_cmd :profile_apply do
|
@@ -92,7 +97,7 @@ context :rib_info do
|
|
92
97
|
end
|
93
98
|
write_cmd :set_security_msg do
|
94
99
|
not_implemented
|
95
|
-
elements :security_msg, :
|
100
|
+
elements :security_msg, security_msg_text: :cdata
|
96
101
|
end
|
97
102
|
write_cmd :set_vm_status do
|
98
103
|
attributes :device
|
@@ -104,7 +109,7 @@ context :rib_info do
|
|
104
109
|
write_cmd :trigger_test_event do
|
105
110
|
not_implemented
|
106
111
|
end
|
107
|
-
write_cmd :update_firmware do #TODO
|
112
|
+
write_cmd :update_firmware do # TODO
|
108
113
|
not_implemented
|
109
114
|
end
|
110
115
|
end
|
@@ -10,7 +10,7 @@ context :server_info do
|
|
10
10
|
|
11
11
|
read_cmd :get_persistent_boot
|
12
12
|
write_cmd :set_persistent_boot do
|
13
|
-
elements :
|
13
|
+
elements device: [:value]
|
14
14
|
end
|
15
15
|
|
16
16
|
read_cmd :get_one_time_boot
|
@@ -43,7 +43,7 @@ context :server_info do
|
|
43
43
|
|
44
44
|
read_cmd :get_pwreg
|
45
45
|
write_cmd :set_pwreg do
|
46
|
-
elements :
|
46
|
+
elements pwralert: :type, pwralert_settings: [:threshold, :duration]
|
47
47
|
end
|
48
48
|
|
49
49
|
read_cmd :get_power_cap
|
@@ -92,4 +92,6 @@ context :server_info do
|
|
92
92
|
|
93
93
|
read_cmd :get_server_power_on_time
|
94
94
|
write_cmd :clear_server_power_on_time
|
95
|
+
|
96
|
+
write_cmd :clear_iml
|
95
97
|
end
|
@@ -14,7 +14,8 @@ context :user_info do
|
|
14
14
|
|
15
15
|
write_cmd :mod_user do
|
16
16
|
attributes :user_login
|
17
|
-
elements :user_name, :user_login, :password, :admin_priv, :remote_cons_priv, :reset_server_priv,
|
17
|
+
elements :user_name, :user_login, :password, :admin_priv, :remote_cons_priv, :reset_server_priv,
|
18
|
+
:virtual_media_priv, :config_ilo_priv, :del_users_ssh_key
|
18
19
|
end
|
19
20
|
|
20
21
|
read_cmd :get_all_users
|
data/lib/ilorb/ribcl.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class ILORb
|
2
|
+
# ILO API methods DSL implementation
|
2
3
|
class RIBCL < Hash
|
3
|
-
|
4
4
|
class NotImplementedError < StandardError; end
|
5
5
|
class InvalidDefinitionError < StandardError; end
|
6
6
|
|
@@ -9,7 +9,7 @@ class ILORb
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# meaningful aliases
|
12
|
-
alias_method :
|
12
|
+
alias_method :command?, :key?
|
13
13
|
alias_method :command, :fetch
|
14
14
|
|
15
15
|
# mapping between Ruby objects and api format
|
@@ -31,7 +31,6 @@ class ILORb
|
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
|
-
# private methods are used by DSL
|
35
34
|
|
36
35
|
def context(name, &block)
|
37
36
|
context = Context.new(name)
|
@@ -39,6 +38,7 @@ class ILORb
|
|
39
38
|
merge!(context.commands)
|
40
39
|
end
|
41
40
|
|
41
|
+
# Implements contexts matching categories in ILO API (Server, RIB, User, etc.)
|
42
42
|
class Context
|
43
43
|
attr_reader :commands
|
44
44
|
|
@@ -47,9 +47,6 @@ class ILORb
|
|
47
47
|
@commands = {}
|
48
48
|
end
|
49
49
|
|
50
|
-
private
|
51
|
-
# private methods are used by DSL
|
52
|
-
|
53
50
|
[:read, :write].each do |mode|
|
54
51
|
define_method "#{mode}_cmd" do |name, &block|
|
55
52
|
command = Command.new(name, @name, mode)
|
@@ -59,6 +56,7 @@ class ILORb
|
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
59
|
+
# Implements ILO API commands with their parameters
|
62
60
|
class Command
|
63
61
|
attr_reader :name, :context, :mode
|
64
62
|
|
@@ -97,7 +95,6 @@ class ILORb
|
|
97
95
|
end
|
98
96
|
|
99
97
|
private
|
100
|
-
# private methods are used by DSL
|
101
98
|
|
102
99
|
def attributes(*params)
|
103
100
|
@attributes += params
|
@@ -115,7 +112,7 @@ class ILORb
|
|
115
112
|
end
|
116
113
|
@elements.merge!(hash)
|
117
114
|
else
|
118
|
-
|
115
|
+
fail InvalidDefinitionError, "no elements and text"
|
119
116
|
end
|
120
117
|
end
|
121
118
|
|
@@ -123,7 +120,7 @@ class ILORb
|
|
123
120
|
if @elements.empty?
|
124
121
|
@text = param
|
125
122
|
else
|
126
|
-
|
123
|
+
fail InvalidDefinitionError, "no text and elements"
|
127
124
|
end
|
128
125
|
end
|
129
126
|
|
data/lib/ilorb/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
3
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
4
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
5
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
6
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
7
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
8
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
9
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
10
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
11
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
12
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
13
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
14
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
15
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
16
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
17
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
18
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
19
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
20
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
21
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
22
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
23
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
24
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
25
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
26
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
27
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
28
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
29
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
30
|
+
000000000000000000000000000000000000
|
31
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<ribcl version="2.0">
|
3
|
+
<login password="SECRET" user_login="Admin">
|
4
|
+
<rib_info mode="write">
|
5
|
+
<certificate_signing_request>
|
6
|
+
<csr_state value="state"/>
|
7
|
+
<csr_country value="country"/>
|
8
|
+
<csr_locality value="locality"/>
|
9
|
+
<csr_organization value="organization"/>
|
10
|
+
<csr_organizational_unit value="organizational_unit"/>
|
11
|
+
<csr_common_name value="common_name"/>
|
12
|
+
</certificate_signing_request>
|
13
|
+
</rib_info>
|
14
|
+
</login>
|
15
|
+
</ribcl>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<ribcl version="2.0">
|
3
|
+
<login password="SECRET" user_login="Admin">
|
4
|
+
<rib_info mode="write">
|
5
|
+
<import_certificate>-----BEGIN CERTIFICATE-----
|
6
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
7
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
8
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
9
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
10
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
11
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
12
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
13
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
14
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
15
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
16
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
17
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
18
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
19
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
20
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
21
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
22
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
23
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
24
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
25
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
26
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
27
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
28
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
29
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
30
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
31
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
32
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
33
|
+
0000000000000000000000000000000000000000000000000000000000000000
|
34
|
+
000000000000000000000000000000000000
|
35
|
+
-----END CERTIFICATE-----
|
36
|
+
</import_certificate>
|
37
|
+
</rib_info>
|
38
|
+
</login>
|
39
|
+
</ribcl>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<ribcl version="2.0">
|
3
|
+
<login password="SECRET" user_login="Admin">
|
4
|
+
<server_info mode="write">
|
5
|
+
<set_persistent_boot>
|
6
|
+
<device value="FLOPPY"/>
|
7
|
+
<device value="CDROM"/>
|
8
|
+
</set_persistent_boot>
|
9
|
+
</server_info>
|
10
|
+
</login>
|
11
|
+
</ribcl>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<ribcl version="2.0">
|
3
|
+
<login password="SECRET" user_login="Admin">
|
4
|
+
<server_info mode="write">
|
5
|
+
<set_pwreg>
|
6
|
+
<pwralert type="PEAK"/>
|
7
|
+
<pwralert_settings threshold="200" duration="35"/>
|
8
|
+
</set_pwreg>
|
9
|
+
</server_info>
|
10
|
+
</login>
|
11
|
+
</ribcl>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
context :rib_info do
|
2
|
+
read_cmd :get_network_settings
|
3
|
+
|
4
|
+
write_cmd :certificate_signing_request do
|
5
|
+
elements :csr_state, :csr_country, :csr_locality, :csr_organization, :csr_organizational_unit, :csr_common_name
|
6
|
+
end
|
7
|
+
|
8
|
+
write_cmd :import_certificate do
|
9
|
+
text :certificate
|
10
|
+
end
|
11
|
+
|
12
|
+
write_cmd :license do
|
13
|
+
elements activate: :key
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context :server_info do
|
18
|
+
write_cmd :set_persistent_boot do
|
19
|
+
elements device: [:value]
|
20
|
+
end
|
21
|
+
|
22
|
+
write_cmd :set_one_time_boot do
|
23
|
+
attributes :value
|
24
|
+
end
|
25
|
+
|
26
|
+
write_cmd :set_pwreg do
|
27
|
+
elements pwralert: :type, pwralert_settings: [:threshold, :duration]
|
28
|
+
end
|
29
|
+
|
30
|
+
write_cmd :server_auto_pwr do
|
31
|
+
attributes :value
|
32
|
+
end
|
33
|
+
end
|
data/spec/ilo_spec.rb
CHANGED
@@ -1,79 +1,113 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe ILORb do
|
4
4
|
let(:hostname) { "10.200.0.1" }
|
5
5
|
let(:login) { "Admin" }
|
6
6
|
let(:password) { "SECRET" }
|
7
|
-
let(:
|
7
|
+
let(:definitions_path) { File.join(File.dirname(__FILE__), "definitions") }
|
8
|
+
let(:ilo) { ILORb.new(hostname: hostname, login: login, password: password, definitions_path: definitions_path) }
|
8
9
|
|
9
10
|
describe "#get_network_settings" do
|
10
11
|
before do
|
11
|
-
stub_request(:post, "https://10.200.0.1/ribcl")
|
12
|
-
with(:
|
13
|
-
to_return(:
|
12
|
+
stub_request(:post, "https://10.200.0.1/ribcl")
|
13
|
+
.with(body: asset_file("get_network_settings_request.xml"))
|
14
|
+
.to_return(status: 200, body: asset_file("get_network_settings_response.xml"))
|
14
15
|
end
|
15
16
|
|
16
17
|
subject { ilo.get_network_settings }
|
17
18
|
|
18
|
-
its([:status]) { should include(code: 0, message:
|
19
|
+
its([:status]) { should include(code: 0, message: "No error") }
|
19
20
|
its([:get_network_settings]) { should_not be_empty }
|
20
21
|
end
|
21
22
|
|
22
23
|
describe "#set_one_time_boot" do
|
23
24
|
before do
|
24
|
-
stub_request(:post, "https://10.200.0.1/ribcl")
|
25
|
-
with(:
|
26
|
-
to_return(:
|
25
|
+
stub_request(:post, "https://10.200.0.1/ribcl")
|
26
|
+
.with(body: asset_file("set_one_time_boot_request.xml"))
|
27
|
+
.to_return(status: 200, body: asset_file("basic_response.xml"))
|
27
28
|
end
|
28
29
|
|
29
30
|
subject { ilo.set_one_time_boot(value: "FLOPPY") }
|
30
31
|
|
31
|
-
its([:status]) { should include(code: 0, message:
|
32
|
+
its([:status]) { should include(code: 0, message: "No error") }
|
32
33
|
end
|
33
34
|
|
34
35
|
describe "#set_pwreg" do
|
35
36
|
before do
|
36
|
-
stub_request(:post, "https://10.200.0.1/ribcl")
|
37
|
-
with(:
|
38
|
-
to_return(:
|
37
|
+
stub_request(:post, "https://10.200.0.1/ribcl")
|
38
|
+
.with(body: asset_file("set_pwreg_request.xml"))
|
39
|
+
.to_return(status: 200, body: asset_file("basic_response.xml"))
|
39
40
|
end
|
40
41
|
|
41
|
-
subject { ilo.set_pwreg
|
42
|
-
pwralert_settings_threshold: 200,
|
43
|
-
pwralert_settings_duration: 35 }
|
42
|
+
subject { ilo.set_pwreg(pwralert_type: "PEAK", pwralert_settings_threshold: 200, pwralert_settings_duration: 35) }
|
44
43
|
|
45
|
-
its([:status]) { should include(code: 0, message:
|
44
|
+
its([:status]) { should include(code: 0, message: "No error") }
|
46
45
|
end
|
47
46
|
|
48
|
-
describe "#
|
47
|
+
describe "#set_persistent_boot" do
|
49
48
|
before do
|
50
|
-
stub_request(:post, "https://10.200.0.1/ribcl")
|
51
|
-
with(:
|
52
|
-
to_return(:
|
49
|
+
stub_request(:post, "https://10.200.0.1/ribcl")
|
50
|
+
.with(body: asset_file("set_persistent_boot_request.xml"))
|
51
|
+
.to_return(status: 200, body: asset_file("basic_response.xml"))
|
53
52
|
end
|
54
53
|
|
55
|
-
subject { ilo.
|
54
|
+
subject { ilo.set_persistent_boot([{ device_value: "FLOPPY" }, { device_value: "CDROM" }]) }
|
56
55
|
|
57
|
-
its([:status]) { should include(code: 0, message:
|
56
|
+
its([:status]) { should include(code: 0, message: "No error") }
|
58
57
|
end
|
59
58
|
|
60
|
-
describe "#
|
59
|
+
describe "#certificate_signing_request" do
|
61
60
|
before do
|
62
|
-
stub_request(:post, "https://10.200.0.1/ribcl")
|
63
|
-
with(:
|
64
|
-
to_return(:
|
61
|
+
stub_request(:post, "https://10.200.0.1/ribcl")
|
62
|
+
.with(body: asset_file("certificate_signing_request_request.xml"))
|
63
|
+
.to_return(status: 200, body: asset_file("basic_response.xml"))
|
64
|
+
end
|
65
|
+
|
66
|
+
subject do
|
67
|
+
ilo.certificate_signing_request(
|
68
|
+
csr_state: "state",
|
69
|
+
csr_country: "country",
|
70
|
+
csr_locality: "locality",
|
71
|
+
csr_organization: "organization",
|
72
|
+
csr_organizational_unit: "organizational_unit",
|
73
|
+
csr_common_name: "common_name"
|
74
|
+
)
|
65
75
|
end
|
66
76
|
|
67
|
-
|
68
|
-
|
77
|
+
its([:status]) { should include(code: 0, message: "No error") }
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#import_certificate" do
|
81
|
+
before do
|
82
|
+
stub_request(:post, "https://10.200.0.1/ribcl")
|
83
|
+
.with(body: asset_file("import_certificate_request.xml"))
|
84
|
+
.to_return(status: 200, body: asset_file("basic_response.xml"))
|
85
|
+
end
|
86
|
+
|
87
|
+
subject do
|
88
|
+
ilo.import_certificate(certificate: asset_file("certificate.crt"))
|
89
|
+
end
|
90
|
+
|
91
|
+
its([:status]) { should include(code: 0, message: "No error") }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "#server_auto_pwr" do
|
95
|
+
before do
|
96
|
+
stub_request(:post, "https://10.200.0.1/ribcl")
|
97
|
+
.with(body: asset_file("server_auto_pwr_request.xml"))
|
98
|
+
.to_return(status: 200, body: asset_file("basic_response.xml"))
|
99
|
+
end
|
100
|
+
|
101
|
+
subject do
|
102
|
+
ilo.server_auto_pwr(value: "On")
|
103
|
+
end
|
69
104
|
|
70
|
-
its([:status]) { should include(code: 0, message:
|
105
|
+
its([:status]) { should include(code: 0, message: "No error") }
|
71
106
|
end
|
72
107
|
|
73
108
|
private
|
74
109
|
|
75
110
|
def asset_file(asset)
|
76
|
-
|
77
|
-
File.new(path)
|
111
|
+
File.open(File.join(File.dirname(__FILE__), "assets", asset)).read
|
78
112
|
end
|
79
113
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
require "ilorb"
|
4
|
+
require "webmock/rspec"
|
5
|
+
require "pry"
|
6
6
|
|
7
7
|
RSpec.configure do |config|
|
8
8
|
config.order = "random"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ilorb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Amiez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: nokogiri
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,6 +116,7 @@ extensions: []
|
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
104
118
|
- ".gitignore"
|
119
|
+
- ".rubocop.yml"
|
105
120
|
- ".ruby-gemset"
|
106
121
|
- Gemfile
|
107
122
|
- Gemfile.lock
|
@@ -115,7 +130,16 @@ files:
|
|
115
130
|
- lib/ilorb/ribcl.rb
|
116
131
|
- lib/ilorb/version.rb
|
117
132
|
- spec/assets/basic_response.xml
|
133
|
+
- spec/assets/certificate.crt
|
134
|
+
- spec/assets/certificate_signing_request_request.xml
|
135
|
+
- spec/assets/get_network_settings_request.xml
|
118
136
|
- spec/assets/get_network_settings_response.xml
|
137
|
+
- spec/assets/import_certificate_request.xml
|
138
|
+
- spec/assets/server_auto_pwr_request.xml
|
139
|
+
- spec/assets/set_one_time_boot_request.xml
|
140
|
+
- spec/assets/set_persistent_boot_request.xml
|
141
|
+
- spec/assets/set_pwreg_request.xml
|
142
|
+
- spec/definitions/test.rb
|
119
143
|
- spec/ilo_spec.rb
|
120
144
|
- spec/spec_helper.rb
|
121
145
|
homepage: https://github.com/josqu4red/ilorb
|
@@ -138,12 +162,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
162
|
version: '0'
|
139
163
|
requirements: []
|
140
164
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.5.1
|
142
166
|
signing_key:
|
143
167
|
specification_version: 4
|
144
168
|
summary: Configure and retrieve data from server's ILO management card
|
145
169
|
test_files:
|
146
170
|
- spec/assets/basic_response.xml
|
171
|
+
- spec/assets/certificate.crt
|
172
|
+
- spec/assets/certificate_signing_request_request.xml
|
173
|
+
- spec/assets/get_network_settings_request.xml
|
147
174
|
- spec/assets/get_network_settings_response.xml
|
175
|
+
- spec/assets/import_certificate_request.xml
|
176
|
+
- spec/assets/server_auto_pwr_request.xml
|
177
|
+
- spec/assets/set_one_time_boot_request.xml
|
178
|
+
- spec/assets/set_persistent_boot_request.xml
|
179
|
+
- spec/assets/set_pwreg_request.xml
|
180
|
+
- spec/definitions/test.rb
|
148
181
|
- spec/ilo_spec.rb
|
149
182
|
- spec/spec_helper.rb
|