idrac 0.1.21 → 0.1.22
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 +29 -0
- data/bin/idrac +3 -1
- data/lib/idrac/client.rb +39 -27
- 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: 84cc513a711ebdea97f786857702ff36f607a0787e32dfe9b923f2587fc0f547
|
4
|
+
data.tar.gz: f6ff7e6b297064d268c702bbe89c7a6c663a9e0b7b4096bb92ae3ba922731e49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40c1af62898da133ddb2ecf7dab1888c4b3b6758c7af912f9cdd3f2f644c089d42dea211c58a0aa5ceb056a04dec9df3cd98cdbe3b664c271aec3e4bc03f686a
|
7
|
+
data.tar.gz: b1977e34694d5a5c41d54fe461bcb8c03724e4bdf5a6c59aa08fd6325ddd22c41a50d0e615fbfba86428aaf73b6960f03f6dedf1a4811617d98aa466d04dbfa7
|
data/README.md
CHANGED
@@ -52,6 +52,20 @@ idrac firmware:interactive --host=192.168.1.100 --username=root --password=calvi
|
|
52
52
|
|
53
53
|
All commands automatically handle session expiration by re-authenticating when necessary, ensuring that long-running operations like firmware updates complete successfully even if the iDRAC session times out.
|
54
54
|
|
55
|
+
#### Session Management Options
|
56
|
+
|
57
|
+
By default, the client will automatically delete existing sessions when the maximum session limit is reached. You can control this behavior with the `--auto-delete-sessions` option:
|
58
|
+
|
59
|
+
```bash
|
60
|
+
# Disable automatic session deletion (use direct mode instead when max sessions reached)
|
61
|
+
idrac firmware:status --host=192.168.1.100 --no-auto-delete-sessions
|
62
|
+
|
63
|
+
# Explicitly enable automatic session deletion (this is the default)
|
64
|
+
idrac firmware:status --host=192.168.1.100 --auto-delete-sessions
|
65
|
+
```
|
66
|
+
|
67
|
+
When `--auto-delete-sessions` is enabled (the default), the client will attempt to delete existing sessions when it encounters a "maximum number of user sessions" error. When disabled, it will switch to direct mode (using Basic Authentication) instead of trying to clear sessions.
|
68
|
+
|
55
69
|
### Ruby API
|
56
70
|
|
57
71
|
```ruby
|
@@ -95,6 +109,14 @@ end
|
|
95
109
|
# Update firmware
|
96
110
|
job_id = firmware.update('/path/to/firmware.exe', wait: true)
|
97
111
|
puts "Update completed with job ID: #{job_id}"
|
112
|
+
|
113
|
+
# Create a client with auto_delete_sessions disabled
|
114
|
+
client = IDRAC.new(
|
115
|
+
host: '192.168.1.100',
|
116
|
+
username: 'root',
|
117
|
+
password: 'calvin',
|
118
|
+
auto_delete_sessions: false
|
119
|
+
)
|
98
120
|
```
|
99
121
|
|
100
122
|
## Development
|
@@ -105,6 +127,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
105
127
|
|
106
128
|
## Changelog
|
107
129
|
|
130
|
+
### Version 0.1.22
|
131
|
+
- **Session Management Control**: Added `--auto-delete-sessions` CLI option (default: true)
|
132
|
+
- When enabled, the client automatically deletes existing sessions when maximum session limit is reached
|
133
|
+
- When disabled, the client switches to direct mode instead of trying to clear sessions
|
134
|
+
- Added detailed logging for session management decisions
|
135
|
+
- Updated documentation with examples of how to use the new option
|
136
|
+
|
108
137
|
### Version 0.1.21
|
109
138
|
- **Improved Authentication Flow**: Completely restructured the login process
|
110
139
|
- Renamed `legacy_login` to `webui_login` and limited its use to screenshot functionality only
|
data/bin/idrac
CHANGED
@@ -19,6 +19,7 @@ module IDRAC
|
|
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
21
|
class_option :verify_ssl, type: :boolean, default: false, desc: "Enable SSL verification (not recommended for iDRAC's self-signed certificates)"
|
22
|
+
class_option :auto_delete_sessions, type: :boolean, default: true, desc: "Automatically delete sessions when maximum sessions are reached (default: true)"
|
22
23
|
|
23
24
|
desc "firmware:update PATH", "Update firmware using the specified file"
|
24
25
|
method_option :wait, type: :boolean, default: true, desc: "Wait for the update to complete"
|
@@ -191,7 +192,8 @@ module IDRAC
|
|
191
192
|
password: options[:password],
|
192
193
|
port: options[:port],
|
193
194
|
use_ssl: !options[:no_ssl],
|
194
|
-
verify_ssl: options[:verify_ssl]
|
195
|
+
verify_ssl: options[:verify_ssl],
|
196
|
+
auto_delete_sessions: options[:auto_delete_sessions]
|
195
197
|
)
|
196
198
|
end
|
197
199
|
end
|
data/lib/idrac/client.rb
CHANGED
@@ -8,10 +8,10 @@ require 'json'
|
|
8
8
|
|
9
9
|
module IDRAC
|
10
10
|
class Client
|
11
|
-
attr_reader :host, :username, :password, :port, :use_ssl, :verify_ssl
|
11
|
+
attr_reader :host, :username, :password, :port, :use_ssl, :verify_ssl, :auto_delete_sessions
|
12
12
|
attr_accessor :direct_mode
|
13
13
|
|
14
|
-
def initialize(host:, username:, password:, port: 443, use_ssl: true, verify_ssl: true, direct_mode: false)
|
14
|
+
def initialize(host:, username:, password:, port: 443, use_ssl: true, verify_ssl: true, direct_mode: false, auto_delete_sessions: true)
|
15
15
|
@host = host
|
16
16
|
@username = username
|
17
17
|
@password = password
|
@@ -24,6 +24,7 @@ module IDRAC
|
|
24
24
|
@direct_mode = direct_mode
|
25
25
|
@sessions_maxed = false
|
26
26
|
@tried_clearing_sessions = false
|
27
|
+
@auto_delete_sessions = auto_delete_sessions
|
27
28
|
end
|
28
29
|
|
29
30
|
def connection
|
@@ -154,30 +155,37 @@ module IDRAC
|
|
154
155
|
puts "Maximum sessions reached during Redfish session creation"
|
155
156
|
@sessions_maxed = true
|
156
157
|
|
157
|
-
# Try to clear sessions
|
158
|
-
if
|
159
|
-
puts "
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
158
|
+
# Try to clear sessions if auto_delete_sessions is enabled
|
159
|
+
if @auto_delete_sessions
|
160
|
+
puts "Auto-delete sessions is enabled, attempting to clear sessions"
|
161
|
+
if force_clear_sessions
|
162
|
+
puts "Successfully cleared sessions, trying to create a new session"
|
163
|
+
|
164
|
+
# Try one more time after clearing
|
165
|
+
response = connection.post(url) do |req|
|
166
|
+
req.headers.merge!(basic_auth_headers)
|
167
|
+
req.body = payload.to_json
|
168
|
+
end
|
169
|
+
|
170
|
+
if response.status == 201 || response.status == 200
|
171
|
+
@x_auth_token = response.headers['X-Auth-Token']
|
172
|
+
@session_location = response.headers['Location']
|
173
|
+
puts "Redfish session created successfully after clearing sessions"
|
174
|
+
@sessions_maxed = false
|
175
|
+
return true
|
176
|
+
else
|
177
|
+
puts "Failed to create Redfish session after clearing: #{response.status} - #{response.body}"
|
178
|
+
# If we still can't create a session, switch to direct mode
|
179
|
+
@direct_mode = true
|
180
|
+
return false
|
181
|
+
end
|
173
182
|
else
|
174
|
-
puts "Failed to
|
175
|
-
# If we still can't create a session, switch to direct mode
|
183
|
+
puts "Failed to clear sessions, switching to direct mode"
|
176
184
|
@direct_mode = true
|
177
185
|
return false
|
178
186
|
end
|
179
187
|
else
|
180
|
-
puts "
|
188
|
+
puts "Auto-delete sessions is disabled, switching to direct mode"
|
181
189
|
@direct_mode = true
|
182
190
|
return false
|
183
191
|
end
|
@@ -237,12 +245,16 @@ module IDRAC
|
|
237
245
|
# Check for maximum sessions error
|
238
246
|
if error_message.include?("maximum number of user sessions")
|
239
247
|
puts "Maximum sessions reached for WebUI, attempting to clear sessions (attempt #{retry_count + 1}/3)..."
|
240
|
-
# Try to clear any existing sessions
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
248
|
+
# Try to clear any existing sessions if auto_delete_sessions is enabled
|
249
|
+
if @auto_delete_sessions
|
250
|
+
force_clear_sessions
|
251
|
+
# Wait for the server to process the session changes
|
252
|
+
sleep(3)
|
253
|
+
# Try logging in again with incremented retry counter
|
254
|
+
return webui_login(retry_count + 1)
|
255
|
+
else
|
256
|
+
raise Error, "Maximum sessions reached and auto-delete sessions is disabled"
|
257
|
+
end
|
246
258
|
end
|
247
259
|
|
248
260
|
raise Error, "Error Message: #{error_message}"
|
data/lib/idrac/version.rb
CHANGED