idrac 0.7.6 → 0.7.8
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/README.md +9 -0
- data/lib/idrac/client.rb +5 -2
- data/lib/idrac/session.rb +14 -3
- data/lib/idrac/system_config.rb +3 -5
- data/lib/idrac/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4a991e250b073d8337d02439ef78b0456eda253169b32ff6c0fa0f55a0884f0
|
4
|
+
data.tar.gz: c95d65eb76ffac9a349f16d24bbb7f7fb2f137f9b1c6c0071e9f8ce4b78c61d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6493b01742f6f63021152a8d70a6f932396774a83f9e41f916825786ccde2257a09f96cc7144d78470b5d623cb32876c6f49534e941d81894c7c06a933bd9eed
|
7
|
+
data.tar.gz: 9576c7a48cf53755457c9f0f70b17fdc40d7e02985c08294b9845fa068ca8d9c0a68e4379072e4ceb62e88718540cc9ba9a0cf1766cfb245b7cf715516a98948
|
data/README.md
CHANGED
@@ -218,6 +218,15 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
218
218
|
|
219
219
|
## Changelog
|
220
220
|
|
221
|
+
### Version 0.7.8
|
222
|
+
- **Network Redirection Support**: Added optional `host_header` parameter to Client initialization
|
223
|
+
- Enables iDRAC access through network redirection scenarios where the connection IP differs from the Host header requirement
|
224
|
+
- **Configurable VNC Port**: Made VNC port configurable in `set_idrac_ip` function with `vnc_port` parameter (default: 5901)
|
225
|
+
|
226
|
+
### Version 0.7.7
|
227
|
+
- **Bug Fix**: Fixed Session base_url method to use instance variables instead of client delegation
|
228
|
+
- Resolved "undefined local variable or method 'client'" error in session.rb
|
229
|
+
|
221
230
|
### Version 0.7.6
|
222
231
|
- **PR Preparation**: Updated version for PR submission
|
223
232
|
|
data/lib/idrac/client.rb
CHANGED
@@ -9,7 +9,7 @@ require 'colorize'
|
|
9
9
|
|
10
10
|
module IDRAC
|
11
11
|
class Client
|
12
|
-
attr_reader :host, :username, :password, :port, :use_ssl, :verify_ssl, :auto_delete_sessions, :session, :web
|
12
|
+
attr_reader :host, :username, :password, :port, :use_ssl, :verify_ssl, :auto_delete_sessions, :session, :web, :host_header
|
13
13
|
attr_accessor :direct_mode, :verbosity, :retry_count, :retry_delay
|
14
14
|
|
15
15
|
include Power
|
@@ -25,7 +25,7 @@ module IDRAC
|
|
25
25
|
include SystemConfig
|
26
26
|
include Utility
|
27
27
|
|
28
|
-
def initialize(host:, username:, password:, port: 443, use_ssl: true, verify_ssl: false, direct_mode: false, auto_delete_sessions: true, retry_count: 3, retry_delay: 1)
|
28
|
+
def initialize(host:, username:, password:, port: 443, use_ssl: true, verify_ssl: false, direct_mode: false, auto_delete_sessions: true, retry_count: 3, retry_delay: 1, host_header: nil)
|
29
29
|
@host = host
|
30
30
|
@username = username
|
31
31
|
@password = password
|
@@ -34,6 +34,7 @@ module IDRAC
|
|
34
34
|
@verify_ssl = verify_ssl
|
35
35
|
@direct_mode = direct_mode
|
36
36
|
@auto_delete_sessions = auto_delete_sessions
|
37
|
+
@host_header = host_header
|
37
38
|
@verbosity = 0
|
38
39
|
@retry_count = retry_count
|
39
40
|
@retry_delay = retry_delay
|
@@ -121,6 +122,7 @@ module IDRAC
|
|
121
122
|
# Add client headers
|
122
123
|
headers['User-Agent'] ||= 'iDRAC Ruby Client'
|
123
124
|
headers['Accept'] ||= 'application/json'
|
125
|
+
headers['Host'] = @host_header if @host_header
|
124
126
|
|
125
127
|
# If we're in direct mode, use Basic Auth
|
126
128
|
if @direct_mode
|
@@ -259,6 +261,7 @@ module IDRAC
|
|
259
261
|
"User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
|
260
262
|
"Accept-Encoding" => "deflate, gzip"
|
261
263
|
}
|
264
|
+
headers_to_use["Host"] = @host_header if @host_header
|
262
265
|
|
263
266
|
if web.cookies
|
264
267
|
headers_to_use["Cookie"] = web.cookies
|
data/lib/idrac/session.rb
CHANGED
@@ -9,7 +9,7 @@ require 'socket'
|
|
9
9
|
module IDRAC
|
10
10
|
class Session
|
11
11
|
attr_reader :host, :username, :password, :port, :use_ssl, :verify_ssl,
|
12
|
-
:x_auth_token, :session_location, :direct_mode, :auto_delete_sessions
|
12
|
+
:x_auth_token, :session_location, :direct_mode, :auto_delete_sessions, :host_header
|
13
13
|
attr_accessor :verbosity
|
14
14
|
|
15
15
|
include Debuggable
|
@@ -22,6 +22,7 @@ module IDRAC
|
|
22
22
|
@port = client.port
|
23
23
|
@use_ssl = client.use_ssl
|
24
24
|
@verify_ssl = client.verify_ssl
|
25
|
+
@host_header = client.host_header
|
25
26
|
@x_auth_token = nil
|
26
27
|
@session_location = nil
|
27
28
|
@direct_mode = client.direct_mode
|
@@ -282,7 +283,8 @@ module IDRAC
|
|
282
283
|
private
|
283
284
|
|
284
285
|
def base_url
|
285
|
-
|
286
|
+
protocol = use_ssl ? 'https' : 'http'
|
287
|
+
"#{protocol}://#{host}:#{port}"
|
286
288
|
end
|
287
289
|
|
288
290
|
def print_connection_debug_info
|
@@ -347,10 +349,12 @@ module IDRAC
|
|
347
349
|
end
|
348
350
|
|
349
351
|
def basic_auth_headers(content_type = 'application/json')
|
350
|
-
{
|
352
|
+
headers = {
|
351
353
|
'Authorization' => "Basic #{Base64.strict_encode64("#{username}:#{password}")}",
|
352
354
|
'Content-Type' => content_type
|
353
355
|
}
|
356
|
+
headers['Host'] = host_header if host_header
|
357
|
+
headers
|
354
358
|
end
|
355
359
|
|
356
360
|
def request_with_basic_auth(method, url, body = nil, content_type = 'application/json')
|
@@ -391,6 +395,7 @@ module IDRAC
|
|
391
395
|
response = connection.post(url) do |req|
|
392
396
|
req.headers['Content-Type'] = 'application/json'
|
393
397
|
req.headers['Accept'] = 'application/json'
|
398
|
+
req.headers['Host'] = host_header if host_header
|
394
399
|
req.body = payload.to_json
|
395
400
|
debug "Request headers: #{req.headers.reject { |k,v| k =~ /auth/i }.to_json}", 2
|
396
401
|
debug "Request body: #{req.body}", 2
|
@@ -418,6 +423,7 @@ module IDRAC
|
|
418
423
|
alt_response = connection.post(url) do |req|
|
419
424
|
# No Content-Type header
|
420
425
|
req.headers['Accept'] = '*/*'
|
426
|
+
req.headers['Host'] = host_header if host_header
|
421
427
|
req.body = payload.to_json
|
422
428
|
end
|
423
429
|
|
@@ -494,6 +500,7 @@ module IDRAC
|
|
494
500
|
no_content_type_response = connection.post(url) do |req|
|
495
501
|
req.headers['Authorization'] = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
|
496
502
|
req.headers['Accept'] = '*/*'
|
503
|
+
req.headers['Host'] = host_header if host_header
|
497
504
|
req.body = payload.to_json
|
498
505
|
end
|
499
506
|
|
@@ -532,6 +539,7 @@ module IDRAC
|
|
532
539
|
response = connection.post(url) do |req|
|
533
540
|
req.headers['Authorization'] = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
|
534
541
|
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
542
|
+
req.headers['Host'] = host_header if host_header
|
535
543
|
req.body = "UserName=#{URI.encode_www_form_component(username)}&Password=#{URI.encode_www_form_component(password)}"
|
536
544
|
end
|
537
545
|
|
@@ -573,6 +581,7 @@ module IDRAC
|
|
573
581
|
response = connection.post(url) do |req|
|
574
582
|
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
575
583
|
req.headers['Accept'] = '*/*'
|
584
|
+
req.headers['Host'] = host_header if host_header
|
576
585
|
req.body = "UserName=#{URI.encode_www_form_component(username)}&Password=#{URI.encode_www_form_component(password)}"
|
577
586
|
debug "Request headers: #{req.headers.reject { |k,v| k =~ /auth/i }.to_json}", 2
|
578
587
|
end
|
@@ -602,6 +611,7 @@ module IDRAC
|
|
602
611
|
req.headers['Accept'] = 'application/json'
|
603
612
|
req.headers['X-Requested-With'] = 'XMLHttpRequest'
|
604
613
|
req.headers['Authorization'] = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
|
614
|
+
req.headers['Host'] = host_header if host_header
|
605
615
|
req.body = "UserName=#{URI.encode_www_form_component(username)}&Password=#{URI.encode_www_form_component(password)}"
|
606
616
|
end
|
607
617
|
|
@@ -632,6 +642,7 @@ module IDRAC
|
|
632
642
|
|
633
643
|
response = connection.get('/redfish/v1') do |req|
|
634
644
|
req.headers['Accept'] = 'application/json'
|
645
|
+
req.headers['Host'] = host_header if host_header
|
635
646
|
end
|
636
647
|
|
637
648
|
if response.status == 200
|
data/lib/idrac/system_config.rb
CHANGED
@@ -4,16 +4,16 @@ require 'colorize'
|
|
4
4
|
module IDRAC
|
5
5
|
module SystemConfig
|
6
6
|
# This assigns the iDRAC IP to be a STATIC IP.
|
7
|
-
def set_idrac_ip(new_ip:, new_gw:, new_nm:, vnc_password: "calvin")
|
7
|
+
def set_idrac_ip(new_ip:, new_gw:, new_nm:, vnc_password: "calvin", vnc_port: 5901)
|
8
8
|
scp = get_system_configuration_profile(target: "iDRAC")
|
9
9
|
pp scp
|
10
10
|
## We want to access the iDRAC web server even when IPs don't match (and they won't when we port forward local host):
|
11
11
|
set_scp_attribute(scp, "WebServer.1#HostHeaderCheck", "Disabled")
|
12
12
|
## We want VirtualMedia to be enabled so we can mount ISOs: set_scp_attribute(scp, "VirtualMedia.1#Enable", "Enabled")
|
13
13
|
set_scp_attribute(scp, "VirtualMedia.1#EncryptEnable", "Disabled")
|
14
|
-
## We want to access VNC Server on
|
14
|
+
## We want to access VNC Server on specified port for screenshots and without SSL:
|
15
15
|
set_scp_attribute(scp, "VNCServer.1#Enable", "Enabled")
|
16
|
-
set_scp_attribute(scp, "VNCServer.1#Port",
|
16
|
+
set_scp_attribute(scp, "VNCServer.1#Port", vnc_port.to_s)
|
17
17
|
set_scp_attribute(scp, "VNCServer.1#SSLEncryptionBitLength", "Disabled")
|
18
18
|
# And password calvin
|
19
19
|
set_scp_attribute(scp, "VNCServer.1#Password", vnc_password)
|
@@ -72,8 +72,6 @@ module IDRAC
|
|
72
72
|
raise "Failed configuring static IP: #{message} - #{error}"
|
73
73
|
end
|
74
74
|
|
75
|
-
# Finally, let's update our configuration to reflect the new port:
|
76
|
-
self.idrac
|
77
75
|
return true
|
78
76
|
end
|
79
77
|
|
data/lib/idrac/version.rb
CHANGED