idrac 0.1.40 → 0.1.60
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 +75 -8
- data/bin/idrac +244 -86
- data/lib/idrac/client.rb +54 -3
- 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 +505 -66
- data/lib/idrac/version.rb +1 -1
- data/lib/idrac.rb +29 -8
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89e9115a714301ee9458c3aaf527a44ce151ddfc27c0b2776eaf8c384652aaf1
|
4
|
+
data.tar.gz: 71eb43aa5858e307cdda1a2b4aa716a91733acd56b151017800e4099e32175e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 056a1ecb5fd9606de6c2c0078f001e2fbc904e7e777fd192e0d09f8488f2ea101240263ff1567f1a60aa119e75260a7e82d08f67d3855bb77ca827cc245ae86e
|
7
|
+
data.tar.gz: 07b79738a252cc906e8283583d948f61a2246967555f38331e7cea7e96a622d98c5a0f2a04e6d08344767e35f2ef29a2af7187ae767fbaab9662764417670695
|
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.
|
@@ -117,6 +138,38 @@ end
|
|
117
138
|
job_id = firmware.update('/path/to/firmware.exe', wait: true)
|
118
139
|
puts "Update completed with job ID: #{job_id}"
|
119
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
|
+
|
120
173
|
# Create a client with auto_delete_sessions disabled
|
121
174
|
client = IDRAC.new(
|
122
175
|
host: '192.168.1.100',
|
@@ -134,6 +187,20 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
134
187
|
|
135
188
|
## Changelog
|
136
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
|
+
|
137
204
|
### Version 0.1.38
|
138
205
|
- **Enhanced License Display**: Updated the summary command to show both license type and description
|
139
206
|
- Improved readability by displaying license information in the format "Type (Description)"
|
@@ -241,4 +308,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
241
308
|
|
242
309
|
### Version 0.1.21
|
243
310
|
- **Improved Authentication Flow**: Completely restructured the login process
|
244
|
-
- 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,27 +281,16 @@ 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
|
-
ensure_host_provided
|
183
|
-
|
184
|
-
check_ssl_verification
|
185
|
-
client = create_client
|
186
|
-
|
187
|
-
begin
|
293
|
+
with_idrac_client do |client|
|
188
294
|
# Capture a screenshot using the client
|
189
295
|
filename = client.screenshot
|
190
296
|
|
@@ -196,41 +302,31 @@ module IDRAC
|
|
196
302
|
end
|
197
303
|
|
198
304
|
puts "Screenshot saved to: #{filename}"
|
199
|
-
rescue IDRAC::Error => e
|
200
|
-
puts "Error: #{e.message}"
|
201
|
-
exit 1
|
202
|
-
ensure
|
203
|
-
client.logout
|
204
305
|
end
|
205
306
|
end
|
206
307
|
|
207
308
|
desc "summary", "Display a summary of system information"
|
208
|
-
method_option :verbose, type: :boolean, default: false, desc: "Show verbose output including raw API responses"
|
209
309
|
def summary
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
check_ssl_verification
|
214
|
-
client = create_client
|
215
|
-
|
216
|
-
begin
|
310
|
+
with_idrac_client do |client|
|
311
|
+
verbose = options[:verbose] || options[:very_verbose] || options[:debug]
|
312
|
+
|
217
313
|
# Get system information using authenticated_request
|
218
|
-
puts "Retrieving system information...".light_yellow if
|
314
|
+
puts "Retrieving system information...".light_yellow if verbose
|
219
315
|
system_response = client.authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1")
|
220
316
|
system_info = JSON.parse(system_response.body)
|
221
|
-
puts JSON.pretty_generate(system_info).light_yellow if
|
317
|
+
puts JSON.pretty_generate(system_info).light_yellow if verbose
|
222
318
|
|
223
319
|
# Get iDRAC information using authenticated_request
|
224
|
-
puts "Retrieving iDRAC information...".light_yellow if
|
320
|
+
puts "Retrieving iDRAC information...".light_yellow if verbose
|
225
321
|
idrac_response = client.authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1")
|
226
322
|
idrac_info = JSON.parse(idrac_response.body)
|
227
|
-
puts JSON.pretty_generate(idrac_info).light_yellow if
|
323
|
+
puts JSON.pretty_generate(idrac_info).light_yellow if verbose
|
228
324
|
|
229
325
|
# Get network information using authenticated_request
|
230
|
-
puts "Retrieving network information...".light_yellow if
|
326
|
+
puts "Retrieving network information...".light_yellow if verbose
|
231
327
|
network_response = client.authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/EthernetInterfaces/NIC.1")
|
232
328
|
network_info = JSON.parse(network_response.body)
|
233
|
-
puts JSON.pretty_generate(network_info).light_yellow if
|
329
|
+
puts JSON.pretty_generate(network_info).light_yellow if verbose
|
234
330
|
|
235
331
|
# Initialize license_type to Unknown
|
236
332
|
license_type = "Unknown"
|
@@ -238,16 +334,16 @@ module IDRAC
|
|
238
334
|
|
239
335
|
# Try to get license information using DMTF standard method
|
240
336
|
begin
|
241
|
-
puts "Retrieving license information (DMTF method)...".light_yellow if
|
337
|
+
puts "Retrieving license information (DMTF method)...".light_yellow if verbose
|
242
338
|
license_response = client.authenticated_request(:get, "/redfish/v1/LicenseService/Licenses")
|
243
339
|
license_info = JSON.parse(license_response.body)
|
244
|
-
puts JSON.pretty_generate(license_info).light_yellow if
|
340
|
+
puts JSON.pretty_generate(license_info).light_yellow if verbose
|
245
341
|
|
246
342
|
# Extract license type if licenses are found
|
247
343
|
if license_info["Members"] && !license_info["Members"].empty?
|
248
344
|
license_entry_response = client.authenticated_request(:get, license_info["Members"][0]["@odata.id"])
|
249
345
|
license_entry = JSON.parse(license_entry_response.body)
|
250
|
-
puts JSON.pretty_generate(license_entry).light_yellow if
|
346
|
+
puts JSON.pretty_generate(license_entry).light_yellow if verbose
|
251
347
|
|
252
348
|
# Get license type from EntitlementId or LicenseType
|
253
349
|
if license_entry["EntitlementId"] && license_entry["EntitlementId"].include?("Enterprise")
|
@@ -260,20 +356,20 @@ module IDRAC
|
|
260
356
|
license_description = license_entry["Description"] if license_entry["Description"]
|
261
357
|
end
|
262
358
|
rescue => e
|
263
|
-
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
|
264
360
|
|
265
361
|
# If DMTF method fails, try Dell OEM method
|
266
362
|
begin
|
267
|
-
puts "Retrieving license information (Dell OEM method)...".light_yellow if
|
363
|
+
puts "Retrieving license information (Dell OEM method)...".light_yellow if verbose
|
268
364
|
dell_license_response = client.authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLicenses")
|
269
365
|
dell_license_info = JSON.parse(dell_license_response.body)
|
270
|
-
puts JSON.pretty_generate(dell_license_info).light_yellow if
|
366
|
+
puts JSON.pretty_generate(dell_license_info).light_yellow if verbose
|
271
367
|
|
272
368
|
# Extract license type if licenses are found
|
273
369
|
if dell_license_info["Members"] && !dell_license_info["Members"].empty?
|
274
370
|
dell_license_entry_response = client.authenticated_request(:get, dell_license_info["Members"][0]["@odata.id"])
|
275
371
|
dell_license_entry = JSON.parse(dell_license_entry_response.body)
|
276
|
-
puts JSON.pretty_generate(dell_license_entry).light_yellow if
|
372
|
+
puts JSON.pretty_generate(dell_license_entry).light_yellow if verbose
|
277
373
|
|
278
374
|
# Get license type from LicenseType or Description
|
279
375
|
if dell_license_entry["LicenseType"]
|
@@ -286,7 +382,7 @@ module IDRAC
|
|
286
382
|
license_description = dell_license_entry["Description"] if dell_license_entry["Description"]
|
287
383
|
end
|
288
384
|
rescue => e2
|
289
|
-
puts "Error retrieving Dell license information: #{e2.message}".light_red if
|
385
|
+
puts "Error retrieving Dell license information: #{e2.message}".light_red if verbose
|
290
386
|
end
|
291
387
|
end
|
292
388
|
|
@@ -313,6 +409,74 @@ module IDRAC
|
|
313
409
|
puts "License:".ljust(25) + license_display.light_cyan
|
314
410
|
|
315
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
|
316
480
|
rescue IDRAC::Error => e
|
317
481
|
puts "Error: #{e.message}".red.bold
|
318
482
|
exit 1
|
@@ -320,13 +484,6 @@ module IDRAC
|
|
320
484
|
client.logout
|
321
485
|
end
|
322
486
|
end
|
323
|
-
|
324
|
-
map "firmware:update" => :firmware_update
|
325
|
-
map "firmware:catalog" => :firmware_catalog
|
326
|
-
map "firmware:status" => :firmware_status
|
327
|
-
map "firmware:interactive" => :firmware_interactive
|
328
|
-
|
329
|
-
private
|
330
487
|
|
331
488
|
def ensure_host_provided
|
332
489
|
if !options[:host]
|
@@ -351,7 +508,8 @@ module IDRAC
|
|
351
508
|
password: options[:password],
|
352
509
|
port: options[:port],
|
353
510
|
use_ssl: !options[:no_ssl],
|
354
|
-
verify_ssl: options[:verify_ssl]
|
511
|
+
verify_ssl: options[:verify_ssl],
|
512
|
+
auto_delete_sessions: options[:auto_delete_sessions]
|
355
513
|
)
|
356
514
|
end
|
357
515
|
end
|