idrac 0.1.90 → 0.1.92

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: 9bd0f48612489eb3ed6141bc8735780f0cdb764986514a13537ccc137697f1dd
4
- data.tar.gz: 658202ba06d939316ff833f79fb1dbe79e6b5c9016eab0544b66fc8af161a064
3
+ metadata.gz: aeade8ac07bcfebc5686e67d9ae98ce853db0167b237119226e0335e0a9808b4
4
+ data.tar.gz: c53b5df8739b622864c07cec553fc9cc97651f3acf58d20edef3fa5892d2e43f
5
5
  SHA512:
6
- metadata.gz: 3e31ced6bd56d12dab229975452e20fb1a727759f10626e786ce9e23807c4428e182f86044fb73f8f1090f963cab706e80b776a7ea18696b84b5137ca038a558
7
- data.tar.gz: 6e8ccae12157b54065e4013ddfbffa550c26a6b0fd6b229153ec5e0e491d0027da1c2c98e03530f5242361854daab60e27ca04af111889a3f20ca968b0dfb765
6
+ metadata.gz: d73c18d555af727735ce70d35d0d347d8a3665fd2c8ba73d854065af24d77b1886d6aade4ffec7e6bdb45f37a771d58ed683f567897274a86e49deb453527112
7
+ data.tar.gz: 90e2ec395028e29244ce17f72906883b0d3f327d372faa29826ea8791ee33489ab3484e3fa568e1548fb0ffacd7563d4b36c8796354a090066aab9f906a24ba8
data/bin/idrac CHANGED
@@ -119,7 +119,7 @@ module IDRAC
119
119
  map "lifecycle:status" => :lifecycle_status
120
120
  def lifecycle_status
121
121
  with_idrac_client do |client|
122
- client.get_idrac_lifecycle_status
122
+ client.get_lifecycle_status
123
123
  end
124
124
  end
125
125
 
@@ -127,7 +127,7 @@ module IDRAC
127
127
  map "lifecycle:enable" => :lifecycle_enable
128
128
  def lifecycle_enable
129
129
  with_idrac_client do |client|
130
- client.set_idrac_lifecycle_status(true)
130
+ client.set_lifecycle_status(true)
131
131
  end
132
132
  end
133
133
 
@@ -135,7 +135,7 @@ module IDRAC
135
135
  map "lifecycle:disable" => :lifecycle_disable
136
136
  def lifecycle_disable
137
137
  with_idrac_client do |client|
138
- client.set_idrac_lifecycle_status(false)
138
+ client.set_lifecycle_status(false)
139
139
  end
140
140
  end
141
141
 
data/lib/idrac/client.rb CHANGED
@@ -53,16 +53,16 @@ module IDRAC
53
53
  def login
54
54
  # If we're in direct mode, skip login attempts
55
55
  if @direct_mode
56
- puts "Using direct mode (Basic Auth) for all requests".light_yellow
56
+ debug "Using direct mode (Basic Auth) for all requests", 1, :light_yellow
57
57
  return true
58
58
  end
59
59
 
60
60
  # Try to create a Redfish session
61
61
  if session.create
62
- puts "Successfully logged in to iDRAC using Redfish session".green
62
+ debug "Successfully logged in to iDRAC using Redfish session", 1, :green
63
63
  return true
64
64
  else
65
- puts "Failed to create Redfish session, falling back to direct mode".light_yellow
65
+ debug "Failed to create Redfish session, falling back to direct mode", 1, :light_yellow
66
66
  @direct_mode = true
67
67
  return true
68
68
  end
@@ -72,7 +72,7 @@ module IDRAC
72
72
  def logout
73
73
  session.delete if session.x_auth_token
74
74
  web.logout if web.session_id
75
- puts "Logged out from iDRAC".green
75
+ debug "Logged out from iDRAC", 1, :green
76
76
  return true
77
77
  end
78
78
 
@@ -80,7 +80,7 @@ module IDRAC
80
80
  def authenticated_request(method, path, options = {}, retry_count = 0)
81
81
  # Limit retries to prevent infinite loops
82
82
  if retry_count >= 3
83
- puts "Maximum retry count reached for authenticated request".red.bold
83
+ debug "Maximum retry count reached for authenticated request", 1, :red
84
84
  raise Error, "Maximum retry count reached for authenticated request"
85
85
  end
86
86
 
@@ -110,7 +110,7 @@ module IDRAC
110
110
 
111
111
  return response
112
112
  rescue => e
113
- puts "Error during authenticated request (direct mode): #{e.message}".red.bold
113
+ debug "Error during authenticated request (direct mode): #{e.message}", 1, :red
114
114
  raise Error, "Error during authenticated request: #{e.message}"
115
115
  end
116
116
  else
@@ -135,14 +135,14 @@ module IDRAC
135
135
 
136
136
  # Check if the session is still valid
137
137
  if response.status == 401 || response.status == 403
138
- puts "Session expired or invalid, attempting to create a new session...".light_yellow
138
+ debug "Session expired or invalid, attempting to create a new session...", 1, :light_yellow
139
139
 
140
140
  # Try to create a new session
141
141
  if session.create
142
- puts "Successfully created a new session, retrying request...".green
142
+ debug "Successfully created a new session, retrying request...", 1, :green
143
143
  return authenticated_request(method, path, options, retry_count + 1)
144
144
  else
145
- puts "Failed to create a new session, falling back to direct mode...".light_yellow
145
+ debug "Failed to create a new session, falling back to direct mode...", 1, :light_yellow
146
146
  @direct_mode = true
147
147
  return authenticated_request(method, path, options, retry_count + 1)
148
148
  end
@@ -150,14 +150,14 @@ module IDRAC
150
150
 
151
151
  return response
152
152
  rescue => e
153
- puts "Error during authenticated request (token mode): #{e.message}".red.bold
153
+ debug "Error during authenticated request (token mode): #{e.message}", 1, :red
154
154
 
155
155
  # Try to create a new session
156
156
  if session.create
157
- puts "Successfully created a new session after error, retrying request...".green
157
+ debug "Successfully created a new session after error, retrying request...", 1, :green
158
158
  return authenticated_request(method, path, options, retry_count + 1)
159
159
  else
160
- puts "Failed to create a new session after error, falling back to direct mode...".light_yellow
160
+ debug "Failed to create a new session after error, falling back to direct mode...", 1, :light_yellow
161
161
  @direct_mode = true
162
162
  return authenticated_request(method, path, options, retry_count + 1)
163
163
  end
@@ -165,10 +165,10 @@ module IDRAC
165
165
  else
166
166
  # If we don't have a token, try to create a session
167
167
  if session.create
168
- puts "Successfully created a new session, making request...".green
168
+ debug "Successfully created a new session, making request...", 1, :green
169
169
  return authenticated_request(method, path, options, retry_count + 1)
170
170
  else
171
- puts "Failed to create a session, falling back to direct mode...".light_yellow
171
+ debug "Failed to create a session, falling back to direct mode...", 1, :light_yellow
172
172
  @direct_mode = true
173
173
  return authenticated_request(method, path, options, retry_count + 1)
174
174
  end
data/lib/idrac/jobs.rb CHANGED
@@ -46,6 +46,8 @@ module IDRAC
46
46
  end
47
47
 
48
48
  # Clear all jobs from the job queue
49
+ # Apparently too many jobs will slow down the iDRAC. Let's clear them out.
50
+ # https://github.com/dell/iDRAC-Redfish-Scripting/issues/116
49
51
  def clear_jobs!
50
52
  # Get list of jobs
51
53
  jobs_response = authenticated_request(:get, '/redfish/v1/Managers/iDRAC.Embedded.1/Jobs?$expand=*($levels=1)')
@@ -78,6 +80,8 @@ module IDRAC
78
80
  # Force clear the job queue
79
81
  def force_clear_jobs!
80
82
  # Clear the job queue using force option which will also clear any pending data and restart processes
83
+ # Once you executed the command to force clear the job queue, wait a few minutes and then execute command
84
+ # below to check LC status. Continue to execute this command until you see LC status reported as Ready which shouldn't take longer than a couple of minutes.
81
85
  path = '/redfish/v1/Dell/Managers/iDRAC.Embedded.1/DellJobService/Actions/DellJobService.DeleteJobQueue'
82
86
  payload = { "JobID" => "JID_CLEARALL_FORCE" }
83
87
 
@@ -3,221 +3,113 @@ require 'colorize'
3
3
 
4
4
  module IDRAC
5
5
  module LifecycleMethods
6
- # Get the Lifecycle Controller status
6
+ # Check if the Lifecycle Controller is enabled
7
7
  def get_lifecycle_status
8
- # Try first method (older iDRACs)
9
- path1 = '/redfish/v1/Dell/Managers/iDRAC.Embedded.1/DellLCService/Actions/DellLCService.GetRemoteServicesAPIStatus'
8
+ # Try the standard Attributes endpoint first
9
+ path = "/redfish/v1/Managers/iDRAC.Embedded.1/Attributes"
10
+ response = authenticated_request(:get, path)
10
11
 
11
- begin
12
- response = authenticated_request(
13
- :post,
14
- path1,
15
- body: {}.to_json,
16
- headers: { 'Content-Type' => 'application/json' }
17
- )
18
-
19
- if response.status.between?(200, 299)
20
- begin
21
- lc_data = JSON.parse(response.body)
22
- puts "LC Status: #{lc_data['LCStatus']}".light_cyan
23
- return lc_data
24
- rescue JSON::ParserError
25
- # Fall through to alternative method
12
+ if response.status == 200
13
+ begin
14
+ attributes_data = JSON.parse(response.body)
15
+ if attributes_data["Attributes"] && attributes_data["Attributes"]["LCAttributes.1.LifecycleControllerState"]
16
+ lifecycle_state = attributes_data["Attributes"]["LCAttributes.1.LifecycleControllerState"]
17
+ debug "Lifecycle Controller state (from Attributes): #{lifecycle_state}".light_cyan, 1
18
+ return lifecycle_state == "Enabled"
26
19
  end
20
+ rescue JSON::ParserError
21
+ debug "Failed to parse Attributes response".yellow, 1
22
+ # Fall through to registry method if parsing fails or attribute not found
27
23
  end
28
- rescue => e
29
- # Fall through to alternative method
24
+ else
25
+ debug "Failed to get Attributes endpoint (Status: #{response.status}), trying registry method...".yellow, 1
30
26
  end
31
27
 
32
- # Try alternative method (newer iDRACs)
33
- path2 = '/redfish/v1/Managers/iDRAC.Embedded.1/Attributes'
28
+ # Try getting the DellAttributes for LifecycleController directly
29
+ # The key insight is that we need to use just the base path without the fragment
30
+ attributes_path = "/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellAttributes/LifecycleController.Embedded.1"
31
+ attributes_response = authenticated_request(:get, attributes_path)
34
32
 
35
- begin
36
- response = authenticated_request(:get, path2)
37
-
38
- if response.status.between?(200, 299)
39
- begin
40
- attributes_data = JSON.parse(response.body)
41
-
42
- if attributes_data["Attributes"] && attributes_data["Attributes"]["LCAttributes.1.LifecycleControllerState"]
43
- lifecycle_state = attributes_data["Attributes"]["LCAttributes.1.LifecycleControllerState"]
44
- puts "Lifecycle Controller state: #{lifecycle_state}".light_cyan
45
- return { "LCStatus" => lifecycle_state }
46
- end
47
- rescue JSON::ParserError
48
- # Fall through to final error
49
- end
50
- end
51
- rescue => e
52
- # Fall through to final error
53
- end
54
-
55
- # If we get here, try one last approach - try to get iDRAC status
56
- begin
57
- response = authenticated_request(:get, '/redfish/v1/Managers/iDRAC.Embedded.1')
58
-
59
- if response.status.between?(200, 299)
60
- begin
61
- data = JSON.parse(response.body)
62
- status = data["Status"] && data["Status"]["State"]
63
- if status
64
- puts "iDRAC State: #{status}".light_cyan
65
- puts "Note: Could not retrieve direct LC status, showing iDRAC status instead".yellow
66
- return { "iDRACStatus" => status }
67
- end
68
- rescue JSON::ParserError
69
- # Fall through to final error
33
+ if attributes_response.status == 200
34
+ begin
35
+ dell_attr_data = JSON.parse(attributes_response.body)
36
+ if dell_attr_data["Attributes"] && dell_attr_data["Attributes"]["LCAttributes.1.LifecycleControllerState"]
37
+ lifecycle_state = dell_attr_data["Attributes"]["LCAttributes.1.LifecycleControllerState"]
38
+ debug "Lifecycle Controller state (from Dell Attributes): #{lifecycle_state}".light_cyan, 1
39
+ return lifecycle_state == "Enabled"
70
40
  end
41
+ rescue JSON::ParserError
42
+ debug "Failed to parse Dell Attributes response".yellow, 1
43
+ # Fall through to registry method if parsing fails or attribute not found
71
44
  end
72
- rescue => e
73
- # Fall through to final error
45
+ else
46
+ debug "Failed to get Dell Attributes (Status: #{attributes_response.status}), trying registry method...".yellow, 1
74
47
  end
75
-
76
- # If we reached here, all methods failed
77
- puts "Unable to retrieve Lifecycle Controller status through any available method".red
78
- raise Error, "Failed to get Lifecycle Controller status through any available method"
79
- end
80
-
81
- # Check if the Lifecycle Controller is enabled
82
- def get_idrac_lifecycle_status
83
- # Use the DellLCService GetRemoteServicesAPIStatus
84
- path = '/redfish/v1/Dell/Managers/iDRAC.Embedded.1/DellLCService/Actions/DellLCService.GetRemoteServicesAPIStatus'
85
48
 
86
- response = authenticated_request(
87
- :post,
88
- path,
89
- body: {}.to_json,
90
- headers: { 'Content-Type' => 'application/json' }
49
+ # Fallback to the registry method if both Attributes endpoints fail
50
+ registry_response = authenticated_request(
51
+ :get,
52
+ "/redfish/v1/Registries/ManagerAttributeRegistry/ManagerAttributeRegistry.v1_0_0.json"
91
53
  )
92
54
 
93
- if response.status.between?(200, 299)
94
- begin
95
- lc_data = JSON.parse(response.body)
96
- status = lc_data["LCStatus"]
97
-
98
- debug "LC Status: #{status}", 1
99
-
100
- # Get the LCReplication status
101
- attributes_path = "/redfish/v1/Managers/iDRAC.Embedded.1/Attributes"
102
- attributes_response = authenticated_request(:get, attributes_path)
103
-
104
- if attributes_response.status == 200
105
- begin
106
- attributes_data = JSON.parse(attributes_response.body)
107
- lc_replication = attributes_data["Attributes"]["ServiceModule.1.LCLReplication"]
108
-
109
- debug "ServiceModule.1.LCLReplication: #{lc_replication}", 1
110
-
111
- is_enabled = lc_replication == "Enabled"
112
-
113
- puts "Lifecycle Controller replication is #{is_enabled ? 'enabled' : 'disabled'}".light_cyan
114
- puts "Lifecycle Controller status: #{status}".light_cyan
115
- return is_enabled
116
- rescue => e
117
- debug "Error parsing attributes: #{e.message}", 1
118
- end
119
- end
120
-
121
- # If we can't determine from attributes, just return if LC is Ready
122
- is_ready = status == "Ready"
123
- puts "Lifecycle Controller is #{is_ready ? 'Ready' : status}".light_cyan
124
- return is_ready
125
- rescue JSON::ParserError
126
- raise Error, "Failed to parse Lifecycle Controller status response: #{response.body}"
55
+ if registry_response.status != 200
56
+ debug "Failed to get Lifecycle Controller Attributes Registry", 0, :red
57
+ return false
58
+ end
59
+
60
+ begin
61
+ registry_data = JSON.parse(registry_response.body)
62
+ # This is the attribute we want:
63
+ target = registry_data['RegistryEntries']['Attributes'].find {|q| q['AttributeName'] =~ /LCAttributes.1.LifecycleControllerState/ }
64
+ if !target
65
+ debug "Could not find LCAttributes.1.LifecycleControllerState in registry", 0, :red
66
+ return false
127
67
  end
128
- else
129
- raise Error, "Failed to get Lifecycle Controller status. Status code: #{response.status}"
68
+
69
+ debug "Found attribute in registry but couldn't access it via other endpoints".yellow, 1
70
+ return false
71
+ rescue JSON::ParserError, NoMethodError, StandardError => e
72
+ debug "Error during registry access: #{e.message}", 0, :red
73
+ return false
130
74
  end
131
75
  end
132
76
 
133
77
  # Set the Lifecycle Controller status (enable/disable)
134
- def set_idrac_lifecycle_status(status)
135
- enabled = !!status # Convert to boolean
136
-
137
- debug "Setting Lifecycle Controller status to #{enabled ? 'enabled' : 'disabled'}", 1
138
-
139
- # Use the attributes method to set the ServiceModule.1.LCLReplication
140
- path = "/redfish/v1/Managers/iDRAC.Embedded.1/Attributes"
141
-
142
- # Create the payload with the attribute we want to modify
143
- payload = {
144
- "Attributes": {
145
- "ServiceModule.1.LCLReplication": enabled ? "Enabled" : "Disabled"
146
- }
147
- }
148
-
149
- debug "Using attributes endpoint: #{path}", 1
150
- debug "Payload: #{payload.inspect}", 1
78
+ def set_lifecycle_status(status)
79
+ payload = { "Attributes": { "LCAttributes.1.LifecycleControllerState": status ? 'Enabled' : 'Disabled' } }
80
+ response = authenticated_request(
81
+ :patch,
82
+ "/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellAttributes/LifecycleController.Embedded.1",
83
+ body: payload.to_json,
84
+ headers: { 'Content-Type': 'application/json' }
85
+ )
151
86
 
152
- begin
153
- response = authenticated_request(
154
- :patch,
155
- path,
156
- body: payload.to_json,
157
- headers: { 'Content-Type' => 'application/json' }
158
- )
159
-
160
- debug "Response status: #{response.status}", 1
161
- debug "Response body: #{response.body}", 2 if response.body
162
-
163
- if response.status.between?(200, 299)
164
- puts "Successfully #{enabled ? 'enabled' : 'disabled'} Lifecycle Controller".green
165
- return true
166
- else
167
- error_message = "Failed to set Lifecycle Controller status. Status code: #{response.status}"
168
-
169
- # Print the full response body for debugging
170
- puts "Full error response body:".red
171
- puts response.body.inspect.red
172
-
173
- begin
174
- error_data = JSON.parse(response.body)
175
- puts "Extended error information:".red if error_data['@Message.ExtendedInfo']
176
-
177
- if error_data['error'] && error_data['error']['message']
178
- error_message += ", Message: #{error_data['error']['message']}"
179
- end
180
-
181
- if error_data['@Message.ExtendedInfo']
182
- error_data['@Message.ExtendedInfo'].each do |info|
183
- puts " Message: #{info['Message']}".red
184
- puts " Resolution: #{info['Resolution']}".yellow if info['Resolution']
185
- puts " Severity: #{info['Severity']}".yellow if info['Severity']
186
- puts " MessageId: #{info['MessageId']}".yellow if info['MessageId']
187
- end
188
-
189
- if error_data['@Message.ExtendedInfo'].first
190
- error_message += ", Message: #{error_data['@Message.ExtendedInfo'].first['Message']}"
191
- error_message += ", Resolution: #{error_data['@Message.ExtendedInfo'].first['Resolution']}" if error_data['@Message.ExtendedInfo'].first['Resolution']
192
- end
193
- end
194
- rescue => e
195
- debug "Error parsing response: #{e.message}", 1
196
- # Ignore JSON parsing errors
197
- end
198
-
199
- raise Error, error_message
200
- end
201
- rescue => e
202
- debug "Error in request: #{e.message}", 1
203
- raise Error, "Failed to set Lifecycle Controller status: #{e.message}"
87
+ code = response.status
88
+ case code
89
+ when 200..299
90
+ debug "Lifecycle Controller is now #{status ? 'Enabled' : 'Disabled'}".green, 1
91
+ when 400..499
92
+ debug "[#{code}] This iDRAC does not support Lifecycle Controller", 0, :red
93
+ when 500..599
94
+ debug "[#{code}] iDRAC does not support Lifecycle Controller", 0, :red
95
+ else
204
96
  end
205
97
  end
206
98
 
207
99
  # Ensure the Lifecycle Controller is enabled
208
100
  def ensure_lifecycle_controller!
209
- if !get_idrac_lifecycle_status
210
- puts "Lifecycle Controller is disabled, enabling...".yellow
211
- set_idrac_lifecycle_status(true)
101
+ if !get_lifecycle_status
102
+ debug "Lifecycle Controller is disabled, enabling...".yellow, 1
103
+ set_lifecycle_status(true)
212
104
 
213
105
  # Verify it was enabled
214
- if !get_idrac_lifecycle_status
106
+ if !get_lifecycle_status
215
107
  raise Error, "Failed to enable Lifecycle Controller"
216
108
  end
217
109
 
218
- puts "Lifecycle Controller successfully enabled".green
110
+ debug "Lifecycle Controller successfully enabled".green, 1
219
111
  else
220
- puts "Lifecycle Controller is already enabled".green
112
+ debug "Lifecycle Controller is already enabled".green, 1
221
113
  end
222
114
 
223
115
  return true
@@ -236,10 +128,10 @@ module IDRAC
236
128
  )
237
129
 
238
130
  if response.status.between?(200, 299)
239
- puts "Lifecycle log cleared".green
131
+ debug "Lifecycle log cleared", 0, :green
240
132
  return true
241
133
  else
242
- puts "Failed to clear Lifecycle log".red
134
+ debug "Failed to clear Lifecycle log", 0, :red
243
135
 
244
136
  error_message = "Failed to clear Lifecycle log. Status code: #{response.status}"
245
137
 
@@ -279,10 +171,10 @@ module IDRAC
279
171
  response = authenticated_request(:post, path, body: {}.to_json, headers: { 'Content-Type' => 'application/json' })
280
172
 
281
173
  if response.status.between?(200, 299)
282
- puts "System Event Logs cleared".green
174
+ debug "System Event Logs cleared", 0, :green
283
175
  return true
284
176
  else
285
- puts "Failed to clear System Event Logs".red
177
+ debug "Failed to clear System Event Logs", 0, :red
286
178
 
287
179
  error_message = "Failed to clear System Event Logs. Status code: #{response.status}"
288
180
 
@@ -296,5 +188,10 @@ module IDRAC
296
188
  raise Error, error_message
297
189
  end
298
190
  end
191
+
192
+ # Updates the status message for the lifecycle controller
193
+ def update_status_message(status)
194
+ debug "Lifecycle Controller is now #{status ? 'Enabled' : 'Disabled'}".green, 1
195
+ end
299
196
  end
300
197
  end
data/lib/idrac/power.rb CHANGED
@@ -166,6 +166,33 @@ module IDRAC
166
166
  end
167
167
  end
168
168
 
169
+ def get_power_usage_watts
170
+ # Login to iDRAC if needed
171
+ login unless @session_id
172
+
173
+ response = authenticated_request(:get, "/redfish/v1/Chassis/System.Embedded.1/Power")
174
+
175
+ if response.status == 200
176
+ begin
177
+ data = JSON.parse(response.body)
178
+ watts = data["PowerControl"][0]["PowerConsumedWatts"]
179
+ # puts "Power usage: #{watts} watts".light_cyan
180
+ return watts.to_f
181
+ rescue JSON::ParserError
182
+ raise Error, "Failed to parse power usage response: #{response.body}"
183
+ end
184
+ else
185
+ error_message = "Failed to get power usage. Status code: #{response.status}"
186
+ begin
187
+ error_data = JSON.parse(response.body)
188
+ error_message += ", Message: #{error_data['error']['message']}" if error_data['error'] && error_data['error']['message']
189
+ rescue
190
+ # Ignore JSON parsing errors
191
+ end
192
+ raise Error, error_message
193
+ end
194
+ end
195
+
169
196
  private
170
197
 
171
198
  def wait_for_power_state(target_state:, tries: 6)
@@ -192,4 +219,4 @@ module IDRAC
192
219
  return false
193
220
  end
194
221
  end
195
- end
222
+ end
data/lib/idrac/session.rb CHANGED
@@ -50,24 +50,24 @@ module IDRAC
50
50
 
51
51
  # Force clear all sessions by directly using Basic Auth
52
52
  def force_clear_sessions
53
- debug "Attempting to force clear all sessions...", 0
53
+ debug "Attempting to force clear all sessions...", 1
54
54
 
55
55
  max_retries = 3
56
56
  retry_count = 0
57
57
 
58
58
  while retry_count < max_retries
59
59
  if delete_all_sessions_with_basic_auth
60
- debug "Successfully cleared sessions using Basic Auth", 0, :green
60
+ debug "Successfully cleared sessions using Basic Auth", 1, :green
61
61
  return true
62
62
  else
63
63
  retry_count += 1
64
64
  if retry_count < max_retries
65
65
  # Exponential backoff
66
66
  sleep_time = 2 ** retry_count
67
- debug "Retrying session clear after #{sleep_time} seconds (attempt #{retry_count+1}/#{max_retries})", 0, :light_yellow
67
+ debug "Retrying session clear after #{sleep_time} seconds (attempt #{retry_count+1}/#{max_retries})", 1, :light_yellow
68
68
  sleep(sleep_time)
69
69
  else
70
- debug "Failed to clear sessions after #{max_retries} attempts", 0, :red
70
+ debug "Failed to clear sessions after #{max_retries} attempts", 1, :red
71
71
  return false
72
72
  end
73
73
  end
@@ -78,7 +78,7 @@ module IDRAC
78
78
 
79
79
  # Delete all sessions using Basic Authentication
80
80
  def delete_all_sessions_with_basic_auth
81
- debug "Attempting to delete all sessions using Basic Authentication...", 0
81
+ debug "Attempting to delete all sessions using Basic Authentication...", 1
82
82
 
83
83
  # First, get the list of sessions
84
84
  sessions_url = determine_session_endpoint
@@ -88,10 +88,10 @@ module IDRAC
88
88
  response = request_with_basic_auth(:get, sessions_url, nil, 'application/json')
89
89
 
90
90
  if response.status != 200
91
- debug "Failed to get sessions list: #{response.status} - #{response.body}", 0, :red
91
+ debug "Failed to get sessions list: #{response.status} - #{response.body}", 1, :red
92
92
  # If we received HTML error, assume we can't get sessions and try direct session deletion
93
93
  if response.headers['content-type']&.include?('text/html') || response.body.to_s.include?('DOCTYPE html')
94
- debug "Received HTML error response, trying direct session deletion", 0, :light_yellow
94
+ debug "Received HTML error response, trying direct session deletion", 1, :light_yellow
95
95
  return try_delete_latest_sessions
96
96
  end
97
97
  return false
@@ -102,7 +102,7 @@ module IDRAC
102
102
  sessions_data = JSON.parse(response.body)
103
103
 
104
104
  if sessions_data['Members'] && sessions_data['Members'].any?
105
- debug "Found #{sessions_data['Members'].count} active sessions", 0, :light_yellow
105
+ debug "Found #{sessions_data['Members'].count} active sessions", 1, :light_yellow
106
106
 
107
107
  # Delete each session
108
108
  success = true
@@ -118,7 +118,7 @@ module IDRAC
118
118
  if delete_response.status == 200 || delete_response.status == 204
119
119
  debug "Successfully deleted session: #{session_url}", 1, :green
120
120
  else
121
- debug "Failed to delete session #{session_url}: #{delete_response.status}", 0, :red
121
+ debug "Failed to delete session #{session_url}: #{delete_response.status}", 1, :red
122
122
  success = false
123
123
  end
124
124
 
@@ -128,17 +128,17 @@ module IDRAC
128
128
 
129
129
  return success
130
130
  else
131
- debug "No active sessions found", 0, :light_yellow
131
+ debug "No active sessions found", 1, :light_yellow
132
132
  return true
133
133
  end
134
134
  rescue JSON::ParserError => e
135
- debug "Error parsing sessions response: #{e.message}", 0, :red
136
- debug "Trying direct session deletion", 0, :light_yellow
135
+ debug "Error parsing sessions response: #{e.message}", 1, :red
136
+ debug "Trying direct session deletion", 1, :light_yellow
137
137
  return try_delete_latest_sessions
138
138
  end
139
139
  rescue => e
140
- debug "Error during session deletion with Basic Auth: #{e.message}", 0, :red
141
- debug "Trying direct session deletion", 0, :light_yellow
140
+ debug "Error during session deletion with Basic Auth: #{e.message}", 1, :red
141
+ debug "Trying direct session deletion", 1, :light_yellow
142
142
  return try_delete_latest_sessions
143
143
  end
144
144
  end
@@ -146,7 +146,7 @@ module IDRAC
146
146
  # Try to delete sessions by direct URL when we can't list sessions
147
147
  def try_delete_latest_sessions
148
148
  # Try to delete sessions by direct URL when we can't list sessions
149
- debug "Attempting to delete recent sessions directly...", 0
149
+ debug "Attempting to delete recent sessions directly...", 1
150
150
  base_url = determine_session_endpoint
151
151
  success = false
152
152
 
@@ -177,7 +177,7 @@ module IDRAC
177
177
  def create
178
178
  # Skip if we're in direct mode
179
179
  if @direct_mode
180
- debug "Skipping Redfish session creation (direct mode)", 0, :light_yellow
180
+ debug "Skipping Redfish session creation (direct mode)", 1, :light_yellow
181
181
  return false
182
182
  end
183
183
 
@@ -186,7 +186,7 @@ module IDRAC
186
186
 
187
187
  payload = { "UserName" => username, "Password" => password }
188
188
 
189
- debug "Attempting to create Redfish session at #{base_url}#{session_endpoint}", 0
189
+ debug "Attempting to create Redfish session at #{base_url}#{session_endpoint}", 1
190
190
  debug "SSL verification: #{verify_ssl ? 'Enabled' : 'Disabled'}", 1
191
191
  print_connection_debug_info if @verbosity >= 2
192
192
 
@@ -206,7 +206,7 @@ module IDRAC
206
206
  return unless @x_auth_token && @session_location
207
207
 
208
208
  begin
209
- debug "Deleting Redfish session...", 0
209
+ debug "Deleting Redfish session...", 1
210
210
 
211
211
  # Use the X-Auth-Token for authentication
212
212
  headers = { 'X-Auth-Token' => @x_auth_token }
@@ -216,16 +216,16 @@ module IDRAC
216
216
  end
217
217
 
218
218
  if response.status == 200 || response.status == 204
219
- debug "Redfish session deleted successfully", 0, :green
219
+ debug "Redfish session deleted successfully", 1, :green
220
220
  @x_auth_token = nil
221
221
  @session_location = nil
222
222
  return true
223
223
  else
224
- debug "Failed to delete Redfish session: #{response.status} - #{response.body}", 0, :red
224
+ debug "Failed to delete Redfish session: #{response.status} - #{response.body}", 1, :red
225
225
  return false
226
226
  end
227
227
  rescue => e
228
- debug "Error during Redfish session deletion: #{e.message}", 0, :red
228
+ debug "Error during Redfish session deletion: #{e.message}", 1, :red
229
229
  return false
230
230
  end
231
231
  end
@@ -315,12 +315,12 @@ module IDRAC
315
315
  debug "Request headers: #{req.headers.reject { |k,v| k =~ /auth/i }.to_json}", 2
316
316
  end
317
317
  rescue Faraday::SSLError => e
318
- debug "SSL Error in Basic Auth request: #{e.message}", 0, :red
318
+ debug "SSL Error in Basic Auth request: #{e.message}", 1, :red
319
319
  debug "OpenSSL version: #{OpenSSL::OPENSSL_VERSION}", 1
320
320
  debug e.backtrace.join("\n"), 3 if e.backtrace && @verbosity >= 3
321
321
  raise e
322
322
  rescue => e
323
- debug "Error during #{method} request with Basic Auth: #{e.class.name}: #{e.message}", 0, :red
323
+ debug "Error during #{method} request with Basic Auth: #{e.class.name}: #{e.message}", 1, :red
324
324
  debug e.backtrace.join("\n"), 2 if e.backtrace && @verbosity >= 2
325
325
  raise e
326
326
  end
@@ -338,7 +338,7 @@ module IDRAC
338
338
 
339
339
  def create_session_with_content_type(url, payload)
340
340
  begin
341
- debug "Creating session with Content-Type: application/json", 0
341
+ debug "Creating session with Content-Type: application/json", 1
342
342
 
343
343
  response = connection.post(url) do |req|
344
344
  req.headers['Content-Type'] = 'application/json'
@@ -353,18 +353,18 @@ module IDRAC
353
353
  debug "Response body: #{response.body}", 2
354
354
 
355
355
  if response.status == 405
356
- debug "405 Method Not Allowed: Check if the endpoint supports POST requests and verify the request format.", 0, :red
356
+ debug "405 Method Not Allowed: Check if the endpoint supports POST requests and verify the request format.", 1, :red
357
357
  return false
358
358
  end
359
359
 
360
360
  if process_session_response(response)
361
- debug "Redfish session created successfully", 0, :green
361
+ debug "Redfish session created successfully", 1, :green
362
362
  return true
363
363
  end
364
364
 
365
365
  # If the response status is 415 (Unsupported Media Type), try with different Content-Type
366
366
  if response.status == 415 || (response.body.to_s.include?("unsupported media type"))
367
- debug "415 Unsupported Media Type, trying alternate content type", 0, :yellow
367
+ debug "415 Unsupported Media Type, trying alternate content type", 1, :yellow
368
368
 
369
369
  # Try with no content-type header, just the payload
370
370
  alt_response = connection.post(url) do |req|
@@ -374,18 +374,18 @@ module IDRAC
374
374
  end
375
375
 
376
376
  if process_session_response(alt_response)
377
- debug "Redfish session created successfully with alternate content type", 0, :green
377
+ debug "Redfish session created successfully with alternate content type", 1, :green
378
378
  return true
379
379
  end
380
380
  end
381
381
  rescue Faraday::SSLError => e
382
- debug "SSL Error: #{e.message}", 0, :red
382
+ debug "SSL Error: #{e.message}", 1, :red
383
383
  debug "OpenSSL version: #{OpenSSL::OPENSSL_VERSION}", 1
384
384
  debug "Connection URL: #{base_url}#{url}", 1
385
385
  debug e.backtrace.join("\n"), 3 if e.backtrace && @verbosity >= 3
386
386
  return false
387
387
  rescue => e
388
- debug "First session creation attempt failed: #{e.class.name}: #{e.message}", 0, :light_red
388
+ debug "First session creation attempt failed: #{e.class.name}: #{e.message}", 1, :light_red
389
389
  debug e.backtrace.join("\n"), 2 if e.backtrace && @verbosity >= 2
390
390
  end
391
391
  false
@@ -393,7 +393,7 @@ module IDRAC
393
393
 
394
394
  def create_session_with_basic_auth(url, payload)
395
395
  begin
396
- debug "Creating session with Basic Auth", 0
396
+ debug "Creating session with Basic Auth", 1
397
397
 
398
398
  # Try first with JSON format
399
399
  response = request_with_basic_auth(:post, url, payload.to_json, 'application/json')
@@ -406,26 +406,26 @@ module IDRAC
406
406
  end
407
407
 
408
408
  if process_session_response(response)
409
- debug "Redfish session created successfully with Basic Auth (JSON)", 0, :green
409
+ debug "Redfish session created successfully with Basic Auth (JSON)", 1, :green
410
410
  return true
411
411
  end
412
412
 
413
413
  # If that fails, try with form-urlencoded
414
414
  if response.status == 415 || (response.body.to_s.include?("unsupported media type"))
415
- debug "415 Unsupported Media Type with JSON, trying form-urlencoded", 0, :yellow
415
+ debug "415 Unsupported Media Type with JSON, trying form-urlencoded", 1, :yellow
416
416
 
417
417
  form_data = "UserName=#{URI.encode_www_form_component(username)}&Password=#{URI.encode_www_form_component(password)}"
418
418
  form_response = request_with_basic_auth(:post, url, form_data, 'application/x-www-form-urlencoded')
419
419
 
420
420
  if process_session_response(form_response)
421
- debug "Redfish session created successfully with Basic Auth (form-urlencoded)", 0, :green
421
+ debug "Redfish session created successfully with Basic Auth (form-urlencoded)", 1, :green
422
422
  return true
423
423
  elsif form_response.status == 400
424
424
  # Check for maximum sessions error
425
425
  if (form_response.body.include?("maximum number of user sessions") ||
426
426
  form_response.body.include?("RAC0218") ||
427
427
  form_response.body.include?("Internal Server Error"))
428
- debug "Maximum sessions reached detected during session creation", 0, :light_red
428
+ debug "Maximum sessions reached detected during session creation", 1, :light_red
429
429
  @sessions_maxed = true
430
430
  return false
431
431
  end
@@ -435,14 +435,14 @@ module IDRAC
435
435
  if (response.body.include?("maximum number of user sessions") ||
436
436
  response.body.include?("RAC0218") ||
437
437
  response.body.include?("Internal Server Error"))
438
- debug "Maximum sessions reached detected during session creation", 0, :light_red
438
+ debug "Maximum sessions reached detected during session creation", 1, :light_red
439
439
  @sessions_maxed = true
440
440
  return false
441
441
  end
442
442
  end
443
443
 
444
444
  # Try one more approach with no Content-Type header
445
- debug "Trying Basic Auth with no Content-Type header", 0, :yellow
445
+ debug "Trying Basic Auth with no Content-Type header", 1, :yellow
446
446
  no_content_type_response = connection.post(url) do |req|
447
447
  req.headers['Authorization'] = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
448
448
  req.headers['Accept'] = '*/*'
@@ -450,19 +450,19 @@ module IDRAC
450
450
  end
451
451
 
452
452
  if process_session_response(no_content_type_response)
453
- debug "Redfish session created successfully with Basic Auth (no content type)", 0, :green
453
+ debug "Redfish session created successfully with Basic Auth (no content type)", 1, :green
454
454
  return true
455
455
  end
456
456
 
457
- debug "Failed to create Redfish session: #{response.status} - #{response.body}", 0, :red
457
+ debug "Failed to create Redfish session: #{response.status} - #{response.body}", 1, :red
458
458
  return false
459
459
  rescue Faraday::SSLError => e
460
- debug "SSL Error in Basic Auth request: #{e.message}", 0, :red
460
+ debug "SSL Error in Basic Auth request: #{e.message}", 1, :red
461
461
  debug "OpenSSL version: #{OpenSSL::OPENSSL_VERSION}", 1
462
462
  debug e.backtrace.join("\n"), 3 if e.backtrace && @verbosity >= 3
463
463
  return false
464
464
  rescue => e
465
- debug "Error during Redfish session creation with Basic Auth: #{e.class.name}: #{e.message}", 0, :red
465
+ debug "Error during Redfish session creation with Basic Auth: #{e.class.name}: #{e.message}", 1, :red
466
466
  debug e.backtrace.join("\n"), 2 if e.backtrace && @verbosity >= 2
467
467
  return false
468
468
  end
@@ -471,10 +471,10 @@ module IDRAC
471
471
  def handle_max_sessions_and_retry(url, payload)
472
472
  return false unless @sessions_maxed
473
473
 
474
- debug "Maximum sessions reached, attempting to clear sessions", 0
474
+ debug "Maximum sessions reached, attempting to clear sessions", 1
475
475
  if @auto_delete_sessions
476
476
  if force_clear_sessions
477
- debug "Successfully cleared sessions, trying to create a new session", 0, :green
477
+ debug "Successfully cleared sessions, trying to create a new session", 1, :green
478
478
 
479
479
  # Give the iDRAC a moment to process the session deletions
480
480
  sleep(3)
@@ -488,28 +488,28 @@ module IDRAC
488
488
  end
489
489
 
490
490
  if process_session_response(response)
491
- debug "Redfish session created successfully after clearing sessions", 0, :green
491
+ debug "Redfish session created successfully after clearing sessions", 1, :green
492
492
  return true
493
493
  else
494
- debug "Failed to create Redfish session after clearing sessions: #{response.status} - #{response.body}", 0, :red
494
+ debug "Failed to create Redfish session after clearing sessions: #{response.status} - #{response.body}", 1, :red
495
495
  # If still failing, try direct mode
496
- debug "Falling back to direct mode", 0, :light_yellow
496
+ debug "Falling back to direct mode", 1, :light_yellow
497
497
  @direct_mode = true
498
498
  return false
499
499
  end
500
500
  rescue => e
501
- debug "Error during session creation after clearing: #{e.class.name}: #{e.message}", 0, :red
502
- debug "Falling back to direct mode", 0, :light_yellow
501
+ debug "Error during session creation after clearing: #{e.class.name}: #{e.message}", 1, :red
502
+ debug "Falling back to direct mode", 1, :light_yellow
503
503
  @direct_mode = true
504
504
  return false
505
505
  end
506
506
  else
507
- debug "Failed to clear sessions, switching to direct mode", 0, :light_yellow
507
+ debug "Failed to clear sessions, switching to direct mode", 1, :light_yellow
508
508
  @direct_mode = true
509
509
  return false
510
510
  end
511
511
  else
512
- debug "Auto delete sessions is disabled, switching to direct mode", 0, :light_yellow
512
+ debug "Auto delete sessions is disabled, switching to direct mode", 1, :light_yellow
513
513
  @direct_mode = true
514
514
  return false
515
515
  end
@@ -518,7 +518,7 @@ module IDRAC
518
518
  def create_session_with_form_urlencoded(url, payload)
519
519
  # Only try with form-urlencoded if we had a 415 error previously
520
520
  begin
521
- debug "Trying with form-urlencoded content type", 0
521
+ debug "Trying with form-urlencoded content type", 1
522
522
  debug "URL: #{base_url}#{url}", 1
523
523
 
524
524
  # Try first without any authorization header
@@ -534,21 +534,21 @@ module IDRAC
534
534
  debug "Response body: #{response.body}", 3
535
535
 
536
536
  if process_session_response(response)
537
- debug "Redfish session created successfully with form-urlencoded", 0, :green
537
+ debug "Redfish session created successfully with form-urlencoded", 1, :green
538
538
  return true
539
539
  end
540
540
 
541
541
  # If that fails, try with Basic Auth + form-urlencoded
542
- debug "Trying form-urlencoded with Basic Auth", 0
542
+ debug "Trying form-urlencoded with Basic Auth", 1
543
543
  auth_response = request_with_basic_auth(:post, url, "UserName=#{URI.encode_www_form_component(username)}&Password=#{URI.encode_www_form_component(password)}", 'application/x-www-form-urlencoded')
544
544
 
545
545
  if process_session_response(auth_response)
546
- debug "Redfish session created successfully with form-urlencoded + Basic Auth", 0, :green
546
+ debug "Redfish session created successfully with form-urlencoded + Basic Auth", 1, :green
547
547
  return true
548
548
  end
549
549
 
550
550
  # Last resort: try with both headers (some iDRAC versions need this)
551
- debug "Trying with both Content-Type headers", 0
551
+ debug "Trying with both Content-Type headers", 1
552
552
  both_response = connection.post(url) do |req|
553
553
  req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
554
554
  req.headers['Accept'] = 'application/json'
@@ -558,20 +558,20 @@ module IDRAC
558
558
  end
559
559
 
560
560
  if process_session_response(both_response)
561
- debug "Redfish session created successfully with multiple content types", 0, :green
561
+ debug "Redfish session created successfully with multiple content types", 1, :green
562
562
  return true
563
563
  else
564
- debug "Failed with form-urlencoded too: #{response.status} - #{response.body}", 0, :red
564
+ debug "Failed with form-urlencoded too: #{response.status} - #{response.body}", 1, :red
565
565
  return false
566
566
  end
567
567
  rescue Faraday::SSLError => e
568
- debug "SSL Error in form-urlencoded request: #{e.message}", 0, :red
568
+ debug "SSL Error in form-urlencoded request: #{e.message}", 1, :red
569
569
  debug "OpenSSL version: #{OpenSSL::OPENSSL_VERSION}", 1
570
570
  debug "Connection URL: #{base_url}#{url}", 1
571
571
  debug e.backtrace.join("\n"), 3 if e.backtrace && @verbosity >= 3
572
572
  return false
573
573
  rescue => e
574
- debug "Error during form-urlencoded session creation: #{e.class.name}: #{e.message}", 0, :red
574
+ debug "Error during form-urlencoded session creation: #{e.class.name}: #{e.message}", 1, :red
575
575
  debug e.backtrace.join("\n"), 2 if e.backtrace && @verbosity >= 2
576
576
  return false
577
577
  end
@@ -607,21 +607,21 @@ module IDRAC
607
607
  end
608
608
  end
609
609
  rescue JSON::ParserError => e
610
- debug "Error parsing Redfish version: #{e.message}", 0, :red
610
+ debug "Error parsing Redfish version: #{e.message}", 1, :red
611
611
  debug e.backtrace.join("\n"), 3 if e.backtrace && @verbosity >= 3
612
612
  rescue => e
613
- debug "Error determining Redfish version: #{e.message}", 0, :red
613
+ debug "Error determining Redfish version: #{e.message}", 1, :red
614
614
  debug e.backtrace.join("\n"), 3 if e.backtrace && @verbosity >= 3
615
615
  end
616
616
  end
617
617
  rescue => e
618
- debug "Error checking Redfish version: #{e.message}", 0, :red
618
+ debug "Error checking Redfish version: #{e.message}", 1, :red
619
619
  debug e.backtrace.join("\n"), 3 if e.backtrace && @verbosity >= 3
620
620
  end
621
621
 
622
622
  # Default to /redfish/v1/Sessions if we can't determine version
623
623
  default_endpoint = '/redfish/v1/Sessions'
624
- debug "Defaulting to endpoint #{default_endpoint}", 0, :light_yellow
624
+ debug "Defaulting to endpoint #{default_endpoint}", 1, :light_yellow
625
625
  default_endpoint
626
626
  end
627
627
  end
@@ -629,34 +629,34 @@ module IDRAC
629
629
  # Module containing extracted session methods to be included in Client
630
630
  module SessionMethods
631
631
  def force_clear_sessions
632
- debug = ->(msg, level=0, color=:light_cyan) {
632
+ debug = ->(msg, level=1, color=:light_cyan) {
633
633
  verbosity = respond_to?(:verbosity) ? verbosity : 0
634
634
  return unless verbosity >= level
635
635
  msg = msg.send(color) if color && msg.respond_to?(color)
636
636
  puts msg
637
637
  }
638
638
 
639
- debug.call "Attempting to force clear all sessions...", 0
639
+ debug.call "Attempting to force clear all sessions...", 1
640
640
 
641
641
  if delete_all_sessions_with_basic_auth
642
- debug.call "Successfully cleared sessions using Basic Auth", 0, :green
642
+ debug.call "Successfully cleared sessions using Basic Auth", 1, :green
643
643
  true
644
644
  else
645
- debug.call "Failed to clear sessions using Basic Auth", 0, :red
645
+ debug.call "Failed to clear sessions using Basic Auth", 1, :red
646
646
  false
647
647
  end
648
648
  end
649
649
 
650
650
  # Delete all sessions using Basic Authentication
651
651
  def delete_all_sessions_with_basic_auth
652
- debug = ->(msg, level=0, color=:light_cyan) {
652
+ debug = ->(msg, level=1, color=:light_cyan) {
653
653
  verbosity = respond_to?(:verbosity) ? verbosity : 0
654
654
  return unless verbosity >= level
655
655
  msg = msg.send(color) if color && msg.respond_to?(color)
656
656
  puts msg
657
657
  }
658
658
 
659
- debug.call "Attempting to delete all sessions using Basic Authentication...", 0
659
+ debug.call "Attempting to delete all sessions using Basic Authentication...", 1
660
660
 
661
661
  # First, get the list of sessions
662
662
  sessions_url = session&.determine_session_endpoint || '/redfish/v1/Sessions'
@@ -666,7 +666,7 @@ module IDRAC
666
666
  response = authenticated_request(:get, sessions_url)
667
667
 
668
668
  if response.status != 200
669
- debug.call "Failed to get sessions list: #{response.status} - #{response.body}", 0, :red
669
+ debug.call "Failed to get sessions list: #{response.status} - #{response.body}", 1, :red
670
670
  return false
671
671
  end
672
672
 
@@ -675,7 +675,7 @@ module IDRAC
675
675
  sessions_data = JSON.parse(response.body)
676
676
 
677
677
  if sessions_data['Members'] && sessions_data['Members'].any?
678
- debug.call "Found #{sessions_data['Members'].count} active sessions", 0, :light_yellow
678
+ debug.call "Found #{sessions_data['Members'].count} active sessions", 1, :light_yellow
679
679
 
680
680
  # Delete each session
681
681
  success = true
@@ -691,7 +691,7 @@ module IDRAC
691
691
  if delete_response.status == 200 || delete_response.status == 204
692
692
  debug.call "Successfully deleted session: #{session_url}", 1, :green
693
693
  else
694
- debug.call "Failed to delete session #{session_url}: #{delete_response.status}", 0, :red
694
+ debug.call "Failed to delete session #{session_url}: #{delete_response.status}", 1, :red
695
695
  success = false
696
696
  end
697
697
 
@@ -701,15 +701,15 @@ module IDRAC
701
701
 
702
702
  return success
703
703
  else
704
- debug.call "No active sessions found", 0, :light_yellow
704
+ debug.call "No active sessions found", 1, :light_yellow
705
705
  return true
706
706
  end
707
707
  rescue JSON::ParserError => e
708
- debug.call "Error parsing sessions response: #{e.message}", 0, :red
708
+ debug.call "Error parsing sessions response: #{e.message}", 1, :red
709
709
  return false
710
710
  end
711
711
  rescue => e
712
- debug.call "Error during session deletion with Basic Auth: #{e.message}", 0, :red
712
+ debug.call "Error during session deletion with Basic Auth: #{e.message}", 1, :red
713
713
  return false
714
714
  end
715
715
  end
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.90"
4
+ VERSION = "0.1.92"
5
5
  end
data/lib/idrac.rb CHANGED
@@ -14,7 +14,7 @@ module IDRAC
14
14
  # Provides debugging functionality to IDRAC classes
15
15
  module Debuggable
16
16
  # Debug output helper - only outputs if verbosity level is high enough
17
- def debug(message, level = 0, color = :light_cyan)
17
+ def debug(message, level = 1, color = :light_cyan)
18
18
  return unless respond_to?(:verbosity) && verbosity >= level
19
19
  color_method = color.is_a?(Symbol) && String.method_defined?(color) ? color : :to_s
20
20
  puts message.send(color_method)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idrac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.90
4
+ version: 0.1.92
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-03 00:00:00.000000000 Z
11
+ date: 2025-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty