idrac 0.1.38 → 0.1.41
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 +76 -14
- data/bin/idrac +246 -89
- data/lib/idrac/client.rb +72 -382
- data/lib/idrac/firmware.rb +26 -2
- data/lib/idrac/jobs.rb +212 -0
- data/lib/idrac/lifecycle.rb +300 -0
- data/lib/idrac/power.rb +195 -0
- data/lib/idrac/session.rb +717 -0
- data/lib/idrac/version.rb +1 -1
- data/lib/idrac/web.rb +187 -0
- data/lib/idrac.rb +29 -7
- metadata +8 -4
- data/lib/idrac/screenshot.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ca237b7873f9c7011ab3cc8f8da9661edd442752b2d31a20d4ad497ebf436fa
|
4
|
+
data.tar.gz: 7de812bcd331d79be897e08481a578742a93b5128c0df57858dc706cd67a3239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d9692f031a229c5f2da0540834d68e5ce5feab575c72e8a4d3e0633b00a6880dd34b52221f3fe5f3d5f08dfbec18b8cddedb21b48b7c7454a4a442d55319adb
|
7
|
+
data.tar.gz: '0004391394c8a4e00b3ddd3ad54cff7fea51d372335a4cceb492bcc817f8c5d315dd29943256885ca5d5c9221dc0c880ce31b15861206dc32c45ead32e353090'
|
data/README.md
CHANGED
@@ -12,6 +12,9 @@ A Ruby client for the Dell iDRAC API. This gem provides a command-line interface
|
|
12
12
|
- Comprehensive error handling with clear user guidance
|
13
13
|
- Automatic job tracking and monitoring for firmware updates
|
14
14
|
- Color-coded terminal output for improved readability and user experience
|
15
|
+
- Job queue management (clear, monitor, list)
|
16
|
+
- Lifecycle log and System Event Log (SEL) management
|
17
|
+
- Lifecycle Controller status management
|
15
18
|
|
16
19
|
## Installation
|
17
20
|
|
@@ -37,9 +40,9 @@ The gem provides a command-line interface for interacting with iDRAC servers:
|
|
37
40
|
|
38
41
|
```bash
|
39
42
|
# Take a screenshot of the iDRAC console
|
40
|
-
idrac screenshot --host=192.168.1.100
|
43
|
+
idrac screenshot --host=192.168.1.100
|
41
44
|
# Specify a custom output filename
|
42
|
-
idrac screenshot --host=192.168.1.100
|
45
|
+
idrac screenshot --host=192.168.1.100
|
43
46
|
|
44
47
|
# Download the Dell firmware catalog (no host required)
|
45
48
|
idrac catalog download
|
@@ -47,18 +50,36 @@ idrac catalog download
|
|
47
50
|
idrac firmware:catalog
|
48
51
|
|
49
52
|
# Check firmware status and available updates
|
50
|
-
idrac firmware:status --host=192.168.1.100
|
53
|
+
idrac firmware:status --host=192.168.1.100
|
51
54
|
|
52
55
|
# Update firmware using a specific file
|
53
|
-
idrac firmware:update /path/to/firmware.exe --host=192.168.1.100
|
56
|
+
idrac firmware:update /path/to/firmware.exe --host=192.168.1.100
|
54
57
|
|
55
58
|
# Interactive firmware update
|
56
|
-
idrac firmware:interactive --host=192.168.1.100
|
59
|
+
idrac firmware:interactive --host=192.168.1.100
|
57
60
|
|
58
61
|
# Display a summary of system information
|
59
|
-
idrac summary --host=192.168.1.100
|
62
|
+
idrac summary --host=192.168.1.100
|
60
63
|
# With verbose output for debugging
|
61
|
-
idrac summary --host=192.168.1.100
|
64
|
+
idrac summary --host=192.168.1.100
|
65
|
+
|
66
|
+
# Job Management Commands
|
67
|
+
idrac jobs:list --host=192.168.1.100
|
68
|
+
idrac jobs:detail --host=192.168.1.100
|
69
|
+
idrac jobs:clear --host=192.168.1.100
|
70
|
+
idrac jobs:force_clear --host=192.168.1.100
|
71
|
+
idrac jobs:wait JID_12345678 --host=192.168.1.100
|
72
|
+
idrac tasks --host=192.168.1.100
|
73
|
+
|
74
|
+
# Lifecycle Controller Commands
|
75
|
+
idrac lifecycle:status --host=192.168.1.100
|
76
|
+
idrac lifecycle:enable --host=192.168.1.100
|
77
|
+
idrac lifecycle:disable --host=192.168.1.100
|
78
|
+
idrac lifecycle:ensure --host=192.168.1.100
|
79
|
+
idrac lifecycle:clear --host=192.168.1.100
|
80
|
+
|
81
|
+
# System Event Log (SEL) Commands
|
82
|
+
idrac sel:clear --host=192.168.1.100
|
62
83
|
```
|
63
84
|
|
64
85
|
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.
|
@@ -92,15 +113,10 @@ client = IDRAC.new(
|
|
92
113
|
# The client automatically handles session expiration (401 errors)
|
93
114
|
# by re-authenticating and retrying the request
|
94
115
|
|
95
|
-
# Take a screenshot (using the client
|
116
|
+
# Take a screenshot (using the client method)
|
96
117
|
filename = client.screenshot
|
97
118
|
puts "Screenshot saved to: #{filename}"
|
98
119
|
|
99
|
-
# Or use the Screenshot class directly for more control
|
100
|
-
screenshot = IDRAC::Screenshot.new(client)
|
101
|
-
filename = screenshot.capture
|
102
|
-
puts "Screenshot saved to: #{filename}"
|
103
|
-
|
104
120
|
# Firmware operations
|
105
121
|
firmware = IDRAC::Firmware.new(client)
|
106
122
|
|
@@ -122,6 +138,38 @@ end
|
|
122
138
|
job_id = firmware.update('/path/to/firmware.exe', wait: true)
|
123
139
|
puts "Update completed with job ID: #{job_id}"
|
124
140
|
|
141
|
+
# Job management
|
142
|
+
jobs = client.jobs
|
143
|
+
puts "Found #{jobs['Members'].count} jobs"
|
144
|
+
|
145
|
+
# List job details
|
146
|
+
client.jobs_detail
|
147
|
+
|
148
|
+
# Clear all jobs
|
149
|
+
client.clear_jobs!
|
150
|
+
|
151
|
+
# Force clear job queue (use with caution)
|
152
|
+
client.force_clear_jobs!
|
153
|
+
|
154
|
+
# Wait for a specific job to complete
|
155
|
+
job_data = client.wait_for_job("JID_12345678")
|
156
|
+
|
157
|
+
# Lifecycle Controller operations
|
158
|
+
# Check if Lifecycle Controller is enabled
|
159
|
+
status = client.get_idrac_lifecycle_status
|
160
|
+
|
161
|
+
# Enable Lifecycle Controller
|
162
|
+
client.set_idrac_lifecycle_status(true)
|
163
|
+
|
164
|
+
# Ensure Lifecycle Controller is enabled
|
165
|
+
client.ensure_lifecycle_controller!
|
166
|
+
|
167
|
+
# Clear Lifecycle log
|
168
|
+
client.clear_lifecycle!
|
169
|
+
|
170
|
+
# Clear System Event Logs
|
171
|
+
client.clear_system_event_logs!
|
172
|
+
|
125
173
|
# Create a client with auto_delete_sessions disabled
|
126
174
|
client = IDRAC.new(
|
127
175
|
host: '192.168.1.100',
|
@@ -139,6 +187,20 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
139
187
|
|
140
188
|
## Changelog
|
141
189
|
|
190
|
+
### Version 0.1.39
|
191
|
+
- **Added Job Management**: New methods for managing iDRAC jobs
|
192
|
+
- List jobs using `jobs` and `jobs_detail`
|
193
|
+
- Clear jobs with `clear_jobs!`
|
194
|
+
- Force clear job queue with `force_clear_jobs!`
|
195
|
+
- Wait for specific jobs with `wait_for_job`
|
196
|
+
- **Added Lifecycle Controller Management**: New methods for managing the Lifecycle Controller
|
197
|
+
- Check Lifecycle Controller status with `get_idrac_lifecycle_status`
|
198
|
+
- Enable/disable Lifecycle Controller with `set_idrac_lifecycle_status`
|
199
|
+
- Ensure Lifecycle Controller is enabled with `ensure_lifecycle_controller!`
|
200
|
+
- Clear Lifecycle logs with `clear_lifecycle!`
|
201
|
+
- Clear System Event Logs with `clear_system_event_logs!`
|
202
|
+
- Improved API organization with dedicated modules for related functionality
|
203
|
+
|
142
204
|
### Version 0.1.38
|
143
205
|
- **Enhanced License Display**: Updated the summary command to show both license type and description
|
144
206
|
- Improved readability by displaying license information in the format "Type (Description)"
|
@@ -246,4 +308,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
246
308
|
|
247
309
|
### Version 0.1.21
|
248
310
|
- **Improved Authentication Flow**: Completely restructured the login process
|
249
|
-
- Renamed `
|
311
|
+
- Renamed `
|
data/bin/idrac
CHANGED
@@ -23,30 +23,160 @@ module IDRAC
|
|
23
23
|
class_option :no_ssl, type: :boolean, default: false, desc: "Disable SSL"
|
24
24
|
class_option :verify_ssl, type: :boolean, default: false, desc: "Enable SSL verification (not recommended for iDRAC's self-signed certificates)"
|
25
25
|
class_option :auto_delete_sessions, type: :boolean, default: true, desc: "Automatically delete sessions when maximum sessions are reached"
|
26
|
+
class_option :verbose, type: :boolean, default: false, aliases: '-v', desc: "Enable verbose output"
|
27
|
+
class_option :very_verbose, type: :boolean, default: false, aliases: '-vv', desc: "Enable very verbose output with detailed headers and requests"
|
28
|
+
class_option :debug, type: :boolean, default: false, aliases: '-vvv', desc: "Enable debug output with detailed stack traces and SSL info"
|
26
29
|
|
27
|
-
|
30
|
+
def self.exit_on_failure?
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
# Helper methods that shouldn't be exposed as commands
|
35
|
+
no_commands do
|
36
|
+
# Override the built-in help command to modify displayed command names
|
37
|
+
def help(command = nil)
|
38
|
+
if command
|
39
|
+
super
|
40
|
+
else
|
41
|
+
# Get the formatted help output
|
42
|
+
output = capture_stdout { super }
|
43
|
+
|
44
|
+
# First handle methods with multiple underscores (like jobs_force_clear)
|
45
|
+
modified_output = output.gsub(/idrac (\w+)_(\w+)_(\w+)/) do |match|
|
46
|
+
"idrac #{$1}:#{$2}:#{$3}"
|
47
|
+
end
|
48
|
+
|
49
|
+
# Then handle methods with a single underscore (like lifecycle_status)
|
50
|
+
modified_output = modified_output.gsub(/idrac (\w+)_(\w+)/) do |match|
|
51
|
+
"idrac #{$1}:#{$2}"
|
52
|
+
end
|
53
|
+
|
54
|
+
puts modified_output
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Utility method to capture stdout
|
59
|
+
def capture_stdout
|
60
|
+
original_stdout = $stdout
|
61
|
+
$stdout = StringIO.new
|
62
|
+
yield
|
63
|
+
$stdout.string
|
64
|
+
ensure
|
65
|
+
$stdout = original_stdout
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "jobs_list", "List all iDRAC jobs"
|
70
|
+
map "jobs:list" => :jobs_list
|
71
|
+
def jobs_list
|
72
|
+
with_idrac_client do |client|
|
73
|
+
client.jobs
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "jobs_detail", "List detailed job information"
|
78
|
+
map "jobs:detail" => :jobs_detail
|
79
|
+
def jobs_detail
|
80
|
+
with_idrac_client do |client|
|
81
|
+
client.jobs_detail
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "jobs_clear", "Clear all jobs from the job queue"
|
86
|
+
map "jobs:clear" => :jobs_clear
|
87
|
+
def jobs_clear
|
88
|
+
with_idrac_client do |client|
|
89
|
+
client.clear_jobs!
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "jobs_force_clear", "Force clear the job queue"
|
94
|
+
map "jobs:force_clear" => :jobs_force_clear
|
95
|
+
map "jobs:force:clear" => :jobs_force_clear
|
96
|
+
def jobs_force_clear
|
97
|
+
with_idrac_client do |client|
|
98
|
+
client.force_clear_jobs!
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
desc "jobs_wait JOB_ID", "Wait for a specific job to complete"
|
103
|
+
map "jobs:wait" => :jobs_wait
|
104
|
+
def jobs_wait(job_id)
|
105
|
+
with_idrac_client do |client|
|
106
|
+
job_data = client.wait_for_job(job_id)
|
107
|
+
puts "Job completed: #{job_data['Id']} - #{job_data['JobState']} - #{job_data['Message']}".green
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
desc "tasks", "List iDRAC tasks"
|
112
|
+
def tasks
|
113
|
+
with_idrac_client do |client|
|
114
|
+
client.tasks
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
desc "lifecycle_status", "Check if Lifecycle Controller is enabled"
|
119
|
+
map "lifecycle:status" => :lifecycle_status
|
120
|
+
def lifecycle_status
|
121
|
+
with_idrac_client do |client|
|
122
|
+
client.get_idrac_lifecycle_status
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
desc "lifecycle_enable", "Enable Lifecycle Controller"
|
127
|
+
map "lifecycle:enable" => :lifecycle_enable
|
128
|
+
def lifecycle_enable
|
129
|
+
with_idrac_client do |client|
|
130
|
+
client.set_idrac_lifecycle_status(true)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
desc "lifecycle_disable", "Disable Lifecycle Controller"
|
135
|
+
map "lifecycle:disable" => :lifecycle_disable
|
136
|
+
def lifecycle_disable
|
137
|
+
with_idrac_client do |client|
|
138
|
+
client.set_idrac_lifecycle_status(false)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
desc "lifecycle_ensure", "Ensure Lifecycle Controller is enabled"
|
143
|
+
map "lifecycle:ensure" => :lifecycle_ensure
|
144
|
+
def lifecycle_ensure
|
145
|
+
with_idrac_client do |client|
|
146
|
+
client.ensure_lifecycle_controller!
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
desc "lifecycle_clear", "Clear Lifecycle log"
|
151
|
+
map "lifecycle:clear" => :lifecycle_clear
|
152
|
+
def lifecycle_clear
|
153
|
+
with_idrac_client do |client|
|
154
|
+
client.clear_lifecycle!
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
desc "sel_clear", "Clear System Event Logs (SEL)"
|
159
|
+
map "sel:clear" => :sel_clear
|
160
|
+
def sel_clear
|
161
|
+
with_idrac_client do |client|
|
162
|
+
client.clear_system_event_logs!
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
desc "firmware_update PATH", "Update firmware using the specified file"
|
167
|
+
map "firmware:update" => :firmware_update
|
28
168
|
method_option :wait, type: :boolean, default: true, desc: "Wait for the update to complete"
|
29
169
|
method_option :timeout, type: :numeric, default: 3600, desc: "Timeout in seconds when waiting"
|
30
170
|
def firmware_update(path)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
check_ssl_verification
|
35
|
-
client = create_client
|
36
|
-
firmware = IDRAC::Firmware.new(client)
|
37
|
-
|
38
|
-
begin
|
171
|
+
with_idrac_client do |client|
|
172
|
+
firmware = IDRAC::Firmware.new(client)
|
39
173
|
job_id = firmware.update(path, wait: options[:wait], timeout: options[:timeout])
|
40
174
|
puts "Firmware update initiated with job ID: #{job_id}"
|
41
|
-
rescue IDRAC::Error => e
|
42
|
-
puts "Error: #{e.message}"
|
43
|
-
exit 1
|
44
|
-
ensure
|
45
|
-
client.logout
|
46
175
|
end
|
47
176
|
end
|
48
177
|
|
49
|
-
desc "
|
178
|
+
desc "firmware_catalog [DIRECTORY]", "Download Dell firmware catalog"
|
179
|
+
map "firmware:catalog" => :firmware_catalog
|
50
180
|
def firmware_catalog(directory = nil)
|
51
181
|
# This command doesn't require a host
|
52
182
|
catalog = IDRAC::FirmwareCatalog.new
|
@@ -61,17 +191,13 @@ module IDRAC
|
|
61
191
|
end
|
62
192
|
end
|
63
193
|
|
64
|
-
desc "
|
194
|
+
desc "firmware_status", "Show current firmware status and available updates"
|
195
|
+
map "firmware:status" => :firmware_status
|
65
196
|
method_option :catalog, type: :string, desc: "Path to existing catalog file"
|
66
197
|
def firmware_status
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
check_ssl_verification
|
71
|
-
client = create_client
|
72
|
-
firmware = IDRAC::Firmware.new(client)
|
73
|
-
|
74
|
-
begin
|
198
|
+
with_idrac_client do |client|
|
199
|
+
firmware = IDRAC::Firmware.new(client)
|
200
|
+
|
75
201
|
# Get system inventory - the Firmware class will print its own message
|
76
202
|
inventory = firmware.get_system_inventory
|
77
203
|
|
@@ -102,25 +228,16 @@ module IDRAC
|
|
102
228
|
else
|
103
229
|
puts "\nTo check for updates, download the catalog first with 'idrac firmware:catalog'".yellow
|
104
230
|
end
|
105
|
-
rescue IDRAC::Error => e
|
106
|
-
puts "Error: #{e.message}".red.bold
|
107
|
-
exit 1
|
108
|
-
ensure
|
109
|
-
client.logout
|
110
231
|
end
|
111
232
|
end
|
112
233
|
|
113
|
-
desc "
|
234
|
+
desc "firmware_interactive", "Interactive firmware update"
|
235
|
+
map "firmware:interactive" => :firmware_interactive
|
114
236
|
method_option :catalog, type: :string, desc: "Path to existing catalog file"
|
115
237
|
def firmware_interactive
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
check_ssl_verification
|
120
|
-
client = create_client
|
121
|
-
firmware = IDRAC::Firmware.new(client)
|
122
|
-
|
123
|
-
begin
|
238
|
+
with_idrac_client do |client|
|
239
|
+
firmware = IDRAC::Firmware.new(client)
|
240
|
+
|
124
241
|
catalog_path = options[:catalog]
|
125
242
|
|
126
243
|
# Default catalog location is now ~/.idrac/Catalog.xml
|
@@ -164,30 +281,18 @@ module IDRAC
|
|
164
281
|
puts "3. If no updates appear to be in progress, you may need to restart the iDRAC".light_yellow
|
165
282
|
puts " (iDRAC web interface > Settings > iDRAC Settings > Reset iDRAC)".light_yellow
|
166
283
|
else
|
167
|
-
|
284
|
+
raise # re-raise for the wrapper to handle
|
168
285
|
end
|
169
286
|
end
|
170
|
-
rescue => e
|
171
|
-
puts "Error: #{e.message}".red.bold
|
172
|
-
exit 1
|
173
|
-
ensure
|
174
|
-
client.logout
|
175
287
|
end
|
176
288
|
end
|
177
289
|
|
178
290
|
desc "screenshot", "Take a screenshot of the current iDRAC console"
|
179
291
|
method_option :output, type: :string, desc: "Output filename (default: idrac_screenshot_timestamp.png)"
|
180
292
|
def screenshot
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
check_ssl_verification
|
185
|
-
client = create_client
|
186
|
-
|
187
|
-
begin
|
188
|
-
# Create a Screenshot instance directly
|
189
|
-
screenshot = IDRAC::Screenshot.new(client)
|
190
|
-
filename = screenshot.capture
|
293
|
+
with_idrac_client do |client|
|
294
|
+
# Capture a screenshot using the client
|
295
|
+
filename = client.screenshot
|
191
296
|
|
192
297
|
# Rename the file if output option is provided
|
193
298
|
if options[:output]
|
@@ -197,41 +302,31 @@ module IDRAC
|
|
197
302
|
end
|
198
303
|
|
199
304
|
puts "Screenshot saved to: #{filename}"
|
200
|
-
rescue IDRAC::Error => e
|
201
|
-
puts "Error: #{e.message}"
|
202
|
-
exit 1
|
203
|
-
ensure
|
204
|
-
client.logout
|
205
305
|
end
|
206
306
|
end
|
207
307
|
|
208
308
|
desc "summary", "Display a summary of system information"
|
209
|
-
method_option :verbose, type: :boolean, default: false, desc: "Show verbose output including raw API responses"
|
210
309
|
def summary
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
check_ssl_verification
|
215
|
-
client = create_client
|
216
|
-
|
217
|
-
begin
|
310
|
+
with_idrac_client do |client|
|
311
|
+
verbose = options[:verbose] || options[:very_verbose] || options[:debug]
|
312
|
+
|
218
313
|
# Get system information using authenticated_request
|
219
|
-
puts "Retrieving system information...".light_yellow if
|
314
|
+
puts "Retrieving system information...".light_yellow if verbose
|
220
315
|
system_response = client.authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1")
|
221
316
|
system_info = JSON.parse(system_response.body)
|
222
|
-
puts JSON.pretty_generate(system_info).light_yellow if
|
317
|
+
puts JSON.pretty_generate(system_info).light_yellow if verbose
|
223
318
|
|
224
319
|
# Get iDRAC information using authenticated_request
|
225
|
-
puts "Retrieving iDRAC information...".light_yellow if
|
320
|
+
puts "Retrieving iDRAC information...".light_yellow if verbose
|
226
321
|
idrac_response = client.authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1")
|
227
322
|
idrac_info = JSON.parse(idrac_response.body)
|
228
|
-
puts JSON.pretty_generate(idrac_info).light_yellow if
|
323
|
+
puts JSON.pretty_generate(idrac_info).light_yellow if verbose
|
229
324
|
|
230
325
|
# Get network information using authenticated_request
|
231
|
-
puts "Retrieving network information...".light_yellow if
|
326
|
+
puts "Retrieving network information...".light_yellow if verbose
|
232
327
|
network_response = client.authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/EthernetInterfaces/NIC.1")
|
233
328
|
network_info = JSON.parse(network_response.body)
|
234
|
-
puts JSON.pretty_generate(network_info).light_yellow if
|
329
|
+
puts JSON.pretty_generate(network_info).light_yellow if verbose
|
235
330
|
|
236
331
|
# Initialize license_type to Unknown
|
237
332
|
license_type = "Unknown"
|
@@ -239,16 +334,16 @@ module IDRAC
|
|
239
334
|
|
240
335
|
# Try to get license information using DMTF standard method
|
241
336
|
begin
|
242
|
-
puts "Retrieving license information (DMTF method)...".light_yellow if
|
337
|
+
puts "Retrieving license information (DMTF method)...".light_yellow if verbose
|
243
338
|
license_response = client.authenticated_request(:get, "/redfish/v1/LicenseService/Licenses")
|
244
339
|
license_info = JSON.parse(license_response.body)
|
245
|
-
puts JSON.pretty_generate(license_info).light_yellow if
|
340
|
+
puts JSON.pretty_generate(license_info).light_yellow if verbose
|
246
341
|
|
247
342
|
# Extract license type if licenses are found
|
248
343
|
if license_info["Members"] && !license_info["Members"].empty?
|
249
344
|
license_entry_response = client.authenticated_request(:get, license_info["Members"][0]["@odata.id"])
|
250
345
|
license_entry = JSON.parse(license_entry_response.body)
|
251
|
-
puts JSON.pretty_generate(license_entry).light_yellow if
|
346
|
+
puts JSON.pretty_generate(license_entry).light_yellow if verbose
|
252
347
|
|
253
348
|
# Get license type from EntitlementId or LicenseType
|
254
349
|
if license_entry["EntitlementId"] && license_entry["EntitlementId"].include?("Enterprise")
|
@@ -261,20 +356,20 @@ module IDRAC
|
|
261
356
|
license_description = license_entry["Description"] if license_entry["Description"]
|
262
357
|
end
|
263
358
|
rescue => e
|
264
|
-
puts "Error retrieving license information using DMTF method: #{e.message}".light_red if
|
359
|
+
puts "Error retrieving license information using DMTF method: #{e.message}".light_red if verbose
|
265
360
|
|
266
361
|
# If DMTF method fails, try Dell OEM method
|
267
362
|
begin
|
268
|
-
puts "Retrieving license information (Dell OEM method)...".light_yellow if
|
363
|
+
puts "Retrieving license information (Dell OEM method)...".light_yellow if verbose
|
269
364
|
dell_license_response = client.authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLicenses")
|
270
365
|
dell_license_info = JSON.parse(dell_license_response.body)
|
271
|
-
puts JSON.pretty_generate(dell_license_info).light_yellow if
|
366
|
+
puts JSON.pretty_generate(dell_license_info).light_yellow if verbose
|
272
367
|
|
273
368
|
# Extract license type if licenses are found
|
274
369
|
if dell_license_info["Members"] && !dell_license_info["Members"].empty?
|
275
370
|
dell_license_entry_response = client.authenticated_request(:get, dell_license_info["Members"][0]["@odata.id"])
|
276
371
|
dell_license_entry = JSON.parse(dell_license_entry_response.body)
|
277
|
-
puts JSON.pretty_generate(dell_license_entry).light_yellow if
|
372
|
+
puts JSON.pretty_generate(dell_license_entry).light_yellow if verbose
|
278
373
|
|
279
374
|
# Get license type from LicenseType or Description
|
280
375
|
if dell_license_entry["LicenseType"]
|
@@ -287,7 +382,7 @@ module IDRAC
|
|
287
382
|
license_description = dell_license_entry["Description"] if dell_license_entry["Description"]
|
288
383
|
end
|
289
384
|
rescue => e2
|
290
|
-
puts "Error retrieving Dell license information: #{e2.message}".light_red if
|
385
|
+
puts "Error retrieving Dell license information: #{e2.message}".light_red if verbose
|
291
386
|
end
|
292
387
|
end
|
293
388
|
|
@@ -314,6 +409,74 @@ module IDRAC
|
|
314
409
|
puts "License:".ljust(25) + license_display.light_cyan
|
315
410
|
|
316
411
|
puts "=" * 50
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
desc "power_state", "Get current server power state"
|
416
|
+
map "power:state" => :power_state
|
417
|
+
def power_state
|
418
|
+
with_idrac_client do |client|
|
419
|
+
state = client.get_power_state
|
420
|
+
puts "Current power state: #{state}".light_cyan
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
desc "power_on", "Power on the server"
|
425
|
+
map "power:on" => :power_on
|
426
|
+
def power_on
|
427
|
+
with_idrac_client do |client|
|
428
|
+
client.power_on
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
desc "power_off", "Power off the server"
|
433
|
+
map "power:off" => :power_off
|
434
|
+
def power_off
|
435
|
+
with_idrac_client do |client|
|
436
|
+
client.power_off
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
desc "power_reboot", "Reboot the server"
|
441
|
+
map "power:reboot" => :power_reboot
|
442
|
+
def power_reboot
|
443
|
+
with_idrac_client do |client|
|
444
|
+
client.reboot
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
desc "redfish_version", "Display the Redfish API version"
|
449
|
+
map "redfish:version" => :redfish_version
|
450
|
+
def redfish_version
|
451
|
+
with_idrac_client do |client|
|
452
|
+
version = client.redfish_version
|
453
|
+
puts version
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
private
|
458
|
+
|
459
|
+
def with_idrac_client
|
460
|
+
ensure_host_provided
|
461
|
+
check_ssl_verification
|
462
|
+
client = create_client
|
463
|
+
|
464
|
+
# Set verbosity level for the client
|
465
|
+
if client.respond_to?(:verbosity=)
|
466
|
+
if options[:debug]
|
467
|
+
client.verbosity = 3
|
468
|
+
elsif options[:very_verbose]
|
469
|
+
client.verbosity = 2
|
470
|
+
elsif options[:verbose]
|
471
|
+
client.verbosity = 1
|
472
|
+
else
|
473
|
+
client.verbosity = 0
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
# Execute command with proper error handling
|
478
|
+
begin
|
479
|
+
yield client
|
317
480
|
rescue IDRAC::Error => e
|
318
481
|
puts "Error: #{e.message}".red.bold
|
319
482
|
exit 1
|
@@ -321,13 +484,6 @@ module IDRAC
|
|
321
484
|
client.logout
|
322
485
|
end
|
323
486
|
end
|
324
|
-
|
325
|
-
map "firmware:update" => :firmware_update
|
326
|
-
map "firmware:catalog" => :firmware_catalog
|
327
|
-
map "firmware:status" => :firmware_status
|
328
|
-
map "firmware:interactive" => :firmware_interactive
|
329
|
-
|
330
|
-
private
|
331
487
|
|
332
488
|
def ensure_host_provided
|
333
489
|
if !options[:host]
|
@@ -352,7 +508,8 @@ module IDRAC
|
|
352
508
|
password: options[:password],
|
353
509
|
port: options[:port],
|
354
510
|
use_ssl: !options[:no_ssl],
|
355
|
-
verify_ssl: options[:verify_ssl]
|
511
|
+
verify_ssl: options[:verify_ssl],
|
512
|
+
auto_delete_sessions: options[:auto_delete_sessions]
|
356
513
|
)
|
357
514
|
end
|
358
515
|
end
|