idrac 0.1.9 → 0.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad668d80e3824d65d43da614767040617ee8e606c613105aa56f6949d8fb5e00
4
- data.tar.gz: 62d065f745bc38db6e508bccb79ebecefceb92dfadad409c89b6086b23ba2ca0
3
+ metadata.gz: dc168577884bf076d1472ba870c60262e0cc59fcab318bffa9bd57eaa3dc040b
4
+ data.tar.gz: 887c5990aed81c2addf6ecf6e7e8b229a8c57fced5090a57ca193fc07a7a5a96
5
5
  SHA512:
6
- metadata.gz: e4e6b60bb9a25dad0e85de333297df4cd7708591dc86b79afae0beacad4f016ee6d70395279d57635eeada4eaf604dbfdcf091fe195becf6242275067017cfa3
7
- data.tar.gz: ce9a0577803fced25c6f89c77d451ac9776f9ce15bd840f48184a3ea4f0b810151ff6e8863468b5cac5f0e4401534033314839fa0cd35075202fd08488de2168
6
+ metadata.gz: 9f8714784e0bd9324b03086aaa4dbad64cda93a4f941b6bf6d8b1d36d8e66d892a7ad10fc3cac887c9868ddd1369fe17abce12e192e3e5f60bea1bb6bcb26e0b
7
+ data.tar.gz: f9f444b78243d5668eec03c717dd46b479d14deddc293c09cd30c79dd2e099777e698eadbd053d4cf13ee2d227b764df473c340ada870a3e1a470167002de05c
data/bin/idrac CHANGED
@@ -14,16 +14,17 @@ require "idrac"
14
14
  module IDRAC
15
15
  class CLI < Thor
16
16
  class_option :host, type: :string, required: true, desc: "iDRAC host address"
17
- class_option :username, type: :string, required: true, desc: "iDRAC username"
18
- class_option :password, type: :string, required: true, desc: "iDRAC password"
17
+ class_option :username, type: :string, required: false, default: "root", desc: "iDRAC username (default: root)"
18
+ class_option :password, type: :string, required: false, default: "calvin", desc: "iDRAC password (default: calvin)"
19
19
  class_option :port, type: :numeric, default: 443, desc: "iDRAC port"
20
20
  class_option :no_ssl, type: :boolean, default: false, desc: "Disable SSL"
21
- class_option :no_verify_ssl, type: :boolean, default: false, desc: "Disable SSL verification (use this for self-signed certificates)"
21
+ class_option :verify_ssl, type: :boolean, default: false, desc: "Enable SSL verification (not recommended for iDRAC's self-signed certificates)"
22
22
 
23
23
  desc "firmware:update PATH", "Update firmware using the specified file"
24
24
  method_option :wait, type: :boolean, default: true, desc: "Wait for the update to complete"
25
25
  method_option :timeout, type: :numeric, default: 3600, desc: "Timeout in seconds when waiting"
26
26
  def firmware_update(path)
27
+ check_ssl_verification
27
28
  client = create_client
28
29
  firmware = IDRAC::Firmware.new(client)
29
30
 
@@ -40,6 +41,7 @@ module IDRAC
40
41
 
41
42
  desc "firmware:catalog [DIRECTORY]", "Download Dell firmware catalog"
42
43
  def firmware_catalog(directory = nil)
44
+ check_ssl_verification
43
45
  client = create_client
44
46
  firmware = IDRAC::Firmware.new(client)
45
47
 
@@ -57,11 +59,13 @@ module IDRAC
57
59
  desc "firmware:status", "Show current firmware status and available updates"
58
60
  method_option :catalog, type: :string, desc: "Path to existing catalog file"
59
61
  def firmware_status
62
+ check_ssl_verification
60
63
  client = create_client
61
64
  firmware = IDRAC::Firmware.new(client)
62
65
 
63
66
  begin
64
67
  # Get system inventory
68
+ puts "Retrieving system inventory..."
65
69
  inventory = firmware.get_system_inventory
66
70
 
67
71
  puts "System Information:"
@@ -107,6 +111,7 @@ module IDRAC
107
111
  desc "firmware:interactive", "Interactive firmware update"
108
112
  method_option :catalog, type: :string, desc: "Path to existing catalog file"
109
113
  def firmware_interactive
114
+ check_ssl_verification
110
115
  client = create_client
111
116
  firmware = IDRAC::Firmware.new(client)
112
117
 
@@ -139,6 +144,7 @@ module IDRAC
139
144
  desc "screenshot", "Take a screenshot of the current iDRAC console"
140
145
  method_option :output, type: :string, desc: "Output filename (default: idrac_screenshot_timestamp.png)"
141
146
  def screenshot
147
+ check_ssl_verification
142
148
  client = create_client
143
149
 
144
150
  begin
@@ -169,6 +175,15 @@ module IDRAC
169
175
 
170
176
  private
171
177
 
178
+ def check_ssl_verification
179
+ # If verify_ssl is not explicitly set in the command line, show a warning
180
+ unless ARGV.include?('--verify-ssl') || ARGV.include?('--no-verify-ssl')
181
+ puts "WARNING: SSL verification is disabled by default. iDRAC typically uses self-signed certificates."
182
+ puts " Use --verify-ssl if you want to enable SSL verification."
183
+ puts ""
184
+ end
185
+ end
186
+
172
187
  def create_client
173
188
  IDRAC::Client.new(
174
189
  host: options[:host],
@@ -176,7 +191,7 @@ module IDRAC
176
191
  password: options[:password],
177
192
  port: options[:port],
178
193
  use_ssl: !options[:no_ssl],
179
- verify_ssl: !options[:no_verify_ssl]
194
+ verify_ssl: options[:verify_ssl]
180
195
  )
181
196
  end
182
197
  end
data/lib/idrac/client.rb CHANGED
@@ -80,6 +80,18 @@ module IDRAC
80
80
  req.body = options[:body] if options[:body]
81
81
  end
82
82
 
83
+ # If we get a 401 Unauthorized, try to re-login and retry the request once
84
+ if response.status == 401
85
+ puts "Session expired, re-authenticating..."
86
+ login
87
+ options[:headers]['Cookie'] = "sessionid=#{@session_id}"
88
+
89
+ response = connection.send(method, path, options[:params]) do |req|
90
+ req.headers.merge!(options[:headers])
91
+ req.body = options[:body] if options[:body]
92
+ end
93
+ end
94
+
83
95
  response
84
96
  end
85
97
 
data/lib/idrac/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IDRAC
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.12"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idrac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel