idrac 0.7.7 → 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 +5 -0
- data/lib/idrac/client.rb +5 -2
- data/lib/idrac/session.rb +12 -2
- 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,11 @@ 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
|
+
|
221
226
|
### Version 0.7.7
|
222
227
|
- **Bug Fix**: Fixed Session base_url method to use instance variables instead of client delegation
|
223
228
|
- Resolved "undefined local variable or method 'client'" error in session.rb
|
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
|
@@ -348,10 +349,12 @@ module IDRAC
|
|
348
349
|
end
|
349
350
|
|
350
351
|
def basic_auth_headers(content_type = 'application/json')
|
351
|
-
{
|
352
|
+
headers = {
|
352
353
|
'Authorization' => "Basic #{Base64.strict_encode64("#{username}:#{password}")}",
|
353
354
|
'Content-Type' => content_type
|
354
355
|
}
|
356
|
+
headers['Host'] = host_header if host_header
|
357
|
+
headers
|
355
358
|
end
|
356
359
|
|
357
360
|
def request_with_basic_auth(method, url, body = nil, content_type = 'application/json')
|
@@ -392,6 +395,7 @@ module IDRAC
|
|
392
395
|
response = connection.post(url) do |req|
|
393
396
|
req.headers['Content-Type'] = 'application/json'
|
394
397
|
req.headers['Accept'] = 'application/json'
|
398
|
+
req.headers['Host'] = host_header if host_header
|
395
399
|
req.body = payload.to_json
|
396
400
|
debug "Request headers: #{req.headers.reject { |k,v| k =~ /auth/i }.to_json}", 2
|
397
401
|
debug "Request body: #{req.body}", 2
|
@@ -419,6 +423,7 @@ module IDRAC
|
|
419
423
|
alt_response = connection.post(url) do |req|
|
420
424
|
# No Content-Type header
|
421
425
|
req.headers['Accept'] = '*/*'
|
426
|
+
req.headers['Host'] = host_header if host_header
|
422
427
|
req.body = payload.to_json
|
423
428
|
end
|
424
429
|
|
@@ -495,6 +500,7 @@ module IDRAC
|
|
495
500
|
no_content_type_response = connection.post(url) do |req|
|
496
501
|
req.headers['Authorization'] = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
|
497
502
|
req.headers['Accept'] = '*/*'
|
503
|
+
req.headers['Host'] = host_header if host_header
|
498
504
|
req.body = payload.to_json
|
499
505
|
end
|
500
506
|
|
@@ -533,6 +539,7 @@ module IDRAC
|
|
533
539
|
response = connection.post(url) do |req|
|
534
540
|
req.headers['Authorization'] = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
|
535
541
|
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
542
|
+
req.headers['Host'] = host_header if host_header
|
536
543
|
req.body = "UserName=#{URI.encode_www_form_component(username)}&Password=#{URI.encode_www_form_component(password)}"
|
537
544
|
end
|
538
545
|
|
@@ -574,6 +581,7 @@ module IDRAC
|
|
574
581
|
response = connection.post(url) do |req|
|
575
582
|
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
576
583
|
req.headers['Accept'] = '*/*'
|
584
|
+
req.headers['Host'] = host_header if host_header
|
577
585
|
req.body = "UserName=#{URI.encode_www_form_component(username)}&Password=#{URI.encode_www_form_component(password)}"
|
578
586
|
debug "Request headers: #{req.headers.reject { |k,v| k =~ /auth/i }.to_json}", 2
|
579
587
|
end
|
@@ -603,6 +611,7 @@ module IDRAC
|
|
603
611
|
req.headers['Accept'] = 'application/json'
|
604
612
|
req.headers['X-Requested-With'] = 'XMLHttpRequest'
|
605
613
|
req.headers['Authorization'] = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
|
614
|
+
req.headers['Host'] = host_header if host_header
|
606
615
|
req.body = "UserName=#{URI.encode_www_form_component(username)}&Password=#{URI.encode_www_form_component(password)}"
|
607
616
|
end
|
608
617
|
|
@@ -633,6 +642,7 @@ module IDRAC
|
|
633
642
|
|
634
643
|
response = connection.get('/redfish/v1') do |req|
|
635
644
|
req.headers['Accept'] = 'application/json'
|
645
|
+
req.headers['Host'] = host_header if host_header
|
636
646
|
end
|
637
647
|
|
638
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