idrac 0.5.1 → 0.5.3

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: 75d31422362fd2d548fff6e03265162bdf4cfb34237085a7e9e14170bcd8d5eb
4
- data.tar.gz: 219ca3faaaf4e3b8d85ceb0db0baebe5ffa81c2e5afc61ba13851c76fd1f6b41
3
+ metadata.gz: '08c0c927c8906901064229e84e01071445c5cb43d8e27146f53d9adc2084f2c3'
4
+ data.tar.gz: a81b63a1c90c5a545abd1d2ea0f45dc50be607f023fb3c881b4611af6f670ebf
5
5
  SHA512:
6
- metadata.gz: b37b6e6094ee872b2989dcd4d66a8a965502ed7193a66813d5ed3ff60592cfae47c26f9caf9b2f0c34580d366845b49414f55bd909519618d8439cdb71fe8473
7
- data.tar.gz: 30ffb9cbd571489a12f71c553777089541c3550287aca5a267bc4b964da41ff268219ca9e4306097c0aced7ae29a1bd7d17f6ccccfefd45f77778a29891801e1
6
+ metadata.gz: 12073234311cbf0078aaa386d4c27214b3e467ca46065d2bfbb0f9a23e0a26bb587145738bccbcce006d51aef14de4910ae0201d38cc846a21804a8a52278bde
7
+ data.tar.gz: 17612a2c01808f249bdcbe1e587804a299df1d16512965d032f2b574a88071937c2ac9ccf9e36b71ca11545cb7736b72e9bb4723154351f8812be937889455a9
data/bin/idrac CHANGED
@@ -312,103 +312,24 @@ module IDRAC
312
312
  with_idrac_client do |client|
313
313
  verbose = options[:verbose] || options[:very_verbose] || options[:debug]
314
314
 
315
- # Get system information using authenticated_request
316
- puts "Retrieving system information...".light_yellow if verbose
317
- system_response = client.authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1")
318
- system_info = JSON.parse(system_response.body)
319
- puts JSON.pretty_generate(system_info).light_yellow if verbose
320
-
321
- # Get iDRAC information using authenticated_request
322
- puts "Retrieving iDRAC information...".light_yellow if verbose
323
- idrac_response = client.authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1")
324
- idrac_info = JSON.parse(idrac_response.body)
325
- puts JSON.pretty_generate(idrac_info).light_yellow if verbose
326
-
327
- # Get network information using authenticated_request
328
- puts "Retrieving network information...".light_yellow if verbose
329
- network_response = client.authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/EthernetInterfaces/NIC.1")
330
- network_info = JSON.parse(network_response.body)
331
- puts JSON.pretty_generate(network_info).light_yellow if verbose
332
-
333
- # Initialize license_type to Unknown
334
- license_type = "Unknown"
335
- license_description = nil
336
-
337
- # Try to get license information using DMTF standard method
338
- begin
339
- puts "Retrieving license information (DMTF method)...".light_yellow if verbose
340
- license_response = client.authenticated_request(:get, "/redfish/v1/LicenseService/Licenses")
341
- license_info = JSON.parse(license_response.body)
342
- puts JSON.pretty_generate(license_info).light_yellow if verbose
343
-
344
- # Extract license type if licenses are found
345
- if license_info["Members"] && !license_info["Members"].empty?
346
- license_entry_response = client.authenticated_request(:get, license_info["Members"][0]["@odata.id"])
347
- license_entry = JSON.parse(license_entry_response.body)
348
- puts JSON.pretty_generate(license_entry).light_yellow if verbose
349
-
350
- # Get license type from EntitlementId or LicenseType
351
- if license_entry["EntitlementId"] && license_entry["EntitlementId"].include?("Enterprise")
352
- license_type = "Enterprise"
353
- elsif license_entry["LicenseType"]
354
- license_type = license_entry["LicenseType"]
355
- end
356
-
357
- # Get license description if available
358
- license_description = license_entry["Description"] if license_entry["Description"]
359
- end
360
- rescue => e
361
- puts "Error retrieving license information using DMTF method: #{e.message}".light_red if verbose
362
-
363
- # If DMTF method fails, try Dell OEM method
364
- begin
365
- puts "Retrieving license information (Dell OEM method)...".light_yellow if verbose
366
- dell_license_response = client.authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLicenses")
367
- dell_license_info = JSON.parse(dell_license_response.body)
368
- puts JSON.pretty_generate(dell_license_info).light_yellow if verbose
369
-
370
- # Extract license type if licenses are found
371
- if dell_license_info["Members"] && !dell_license_info["Members"].empty?
372
- dell_license_entry_response = client.authenticated_request(:get, dell_license_info["Members"][0]["@odata.id"])
373
- dell_license_entry = JSON.parse(dell_license_entry_response.body)
374
- puts JSON.pretty_generate(dell_license_entry).light_yellow if verbose
375
-
376
- # Get license type from LicenseType or Description
377
- if dell_license_entry["LicenseType"]
378
- license_type = dell_license_entry["LicenseType"]
379
- elsif dell_license_entry["Description"] && dell_license_entry["Description"].include?("Enterprise")
380
- license_type = "Enterprise"
381
- end
382
-
383
- # Get license description if available
384
- license_description = dell_license_entry["Description"] if dell_license_entry["Description"]
385
- end
386
- rescue => e2
387
- puts "Error retrieving Dell license information: #{e2.message}".light_red if verbose
388
- end
389
- end
390
-
391
- # Format the license display string
392
- license_display = license_type
393
- if license_description
394
- license_display = "#{license_type} (#{license_description})"
395
- end
315
+ # Get summary from client
316
+ system_summary = client.get_system_summary
396
317
 
397
318
  # Format and display the information
398
319
  puts "System Summary:".green.bold
399
320
  puts "=" * 50
400
321
 
401
- puts "Power State:".ljust(25) + (system_info["PowerState"] || "Unknown").light_cyan
402
- puts "Model:".ljust(25) + (system_info["Model"] || "Unknown").light_cyan
403
- puts "Host Name:".ljust(25) + (system_info["HostName"] || "Unknown").light_cyan
404
- puts "Operating System:".ljust(25) + (system_info.dig("Oem", "Dell", "OperatingSystem") || "Unknown").light_cyan
405
- puts "Operating System Version:".ljust(25) + (system_info.dig("Oem", "Dell", "OperatingSystemVersion") || "Unknown").light_cyan
406
- puts "Service Tag:".ljust(25) + (system_info["SKU"] || "Unknown").light_cyan
407
- puts "BIOS Version:".ljust(25) + (system_info.dig("BiosVersion") || "Unknown").light_cyan
408
- puts "iDRAC Firmware Version:".ljust(25) + (idrac_info.dig("FirmwareVersion") || "Unknown").light_cyan
409
- puts "IP Address:".ljust(25) + (network_info.dig("IPv4Addresses", 0, "Address") || "Unknown").light_cyan
410
- puts "iDRAC MAC Address:".ljust(25) + (network_info.dig("MACAddress") || "Unknown").light_cyan
411
- puts "License:".ljust(25) + license_display.light_cyan
322
+ puts "Power State:".ljust(25) + (system_summary[:power_state] || "Unknown").light_cyan
323
+ puts "Model:".ljust(25) + (system_summary[:model] || "Unknown").light_cyan
324
+ puts "Host Name:".ljust(25) + (system_summary[:host_name] || "Unknown").light_cyan
325
+ puts "Operating System:".ljust(25) + (system_summary[:operating_system] || "Unknown").light_cyan
326
+ puts "Operating System Version:".ljust(25) + (system_summary[:os_version] || "Unknown").light_cyan
327
+ puts "Service Tag:".ljust(25) + (system_summary[:service_tag] || "Unknown").light_cyan
328
+ puts "BIOS Version:".ljust(25) + (system_summary[:bios_version] || "Unknown").light_cyan
329
+ puts "iDRAC Firmware Version:".ljust(25) + (system_summary[:idrac_firmware] || "Unknown").light_cyan
330
+ puts "IP Address:".ljust(25) + (system_summary[:ip_address] || "Unknown").light_cyan
331
+ puts "iDRAC MAC Address:".ljust(25) + (system_summary[:mac_address] || "Unknown").light_cyan
332
+ puts "License:".ljust(25) + system_summary[:license].light_cyan
412
333
 
413
334
  puts "=" * 50
414
335
  end
@@ -463,11 +384,11 @@ module IDRAC
463
384
  license = client.license_info
464
385
  if license
465
386
  puts "\nLicense Information:".green.bold
466
- puts "Description: #{license['Description']}".cyan
467
- puts "License Type: #{license['LicenseType']}".cyan
387
+ puts "Description: #{license.Description}".cyan
388
+ puts "License Type: #{license.LicenseType}".cyan
468
389
  puts "License Version: #{client.license_version || 'Unknown'}".cyan
469
- puts "Removable: #{license['Removable']}".cyan
470
- puts "Status: #{license.dig('Status', 'Health') || 'Unknown'}".cyan
390
+ puts "Removable: #{license.Removable}".cyan
391
+ puts "Status: #{license&.Status&.Health || 'Unknown'}".cyan
471
392
  else
472
393
  puts "No license information available".yellow
473
394
  end
@@ -1184,13 +1105,8 @@ module IDRAC
1184
1105
  map "system:config" => :system_config
1185
1106
  def system_config
1186
1107
  with_idrac_client do |client|
1187
- response = client.authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1?$expand=*($levels=1)")
1188
- if response.status == 200
1189
- config = JSON.parse(response.body)
1190
- puts JSON.pretty_generate(config)
1191
- else
1192
- puts "Failed to retrieve system configuration: #{response.status}".red
1193
- end
1108
+ config = client.get_system_config
1109
+ puts JSON.pretty_generate(config)
1194
1110
  end
1195
1111
  end
1196
1112
 
@@ -1318,9 +1234,8 @@ module IDRAC
1318
1234
  # System info test
1319
1235
  puts "\n[TEST] System information".cyan.bold
1320
1236
  begin
1321
- response = client.authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1")
1322
- system_info = JSON.parse(response.body)
1323
- puts "✓ System info: #{system_info['Model']} (#{system_info['SKU']})".green
1237
+ system_info = client.get_basic_system_info
1238
+ puts "✓ System info: #{system_info[:model]} (#{system_info[:sku]})".green
1324
1239
  test_results["system_info"] = { status: "PASS", message: "Retrieved system information successfully" }
1325
1240
  rescue => e
1326
1241
  puts "✗ System info failed: #{e.message}".red
data/lib/idrac/license.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module IDRAC
2
2
  module License
3
3
  # Gets the license information from the iDRAC
4
- # @return [Hash] License details
4
+ # @return [RecursiveOpenStruct] License details
5
5
  def license_info
6
6
  response = authenticated_request(:get, "/redfish/v1/LicenseService/Licenses")
7
7
  if response.status != 200
@@ -32,7 +32,7 @@ module IDRAC
32
32
  license_details = JSON.parse(license_response.body)
33
33
  debug "License details: #{license_details}", 2
34
34
 
35
- return license_details
35
+ return RecursiveOpenStruct.new(license_details, recurse_over_arrays: true)
36
36
  end
37
37
 
38
38
  # Extracts the iDRAC version from the license description
@@ -43,15 +43,15 @@ module IDRAC
43
43
 
44
44
  # Check the Description field, which often contains the version
45
45
  # Example: "iDRAC9 Enterprise License"
46
- if license["Description"] && license["Description"].match(/iDRAC(\d+)/i)
47
- version = license["Description"].match(/iDRAC(\d+)/i)[1].to_i
46
+ if license.Description && license.Description.match(/iDRAC(\d+)/i)
47
+ version = license.Description.match(/iDRAC(\d+)/i)[1].to_i
48
48
  debug "Found license version from Description: #{version}", 1
49
49
  return version
50
50
  end
51
51
 
52
52
  # Try alternative fields if Description didn't work
53
- if license["Name"] && license["Name"].match(/iDRAC(\d+)/i)
54
- version = license["Name"].match(/iDRAC(\d+)/i)[1].to_i
53
+ if license.Name && license.Name.match(/iDRAC(\d+)/i)
54
+ version = license.Name.match(/iDRAC(\d+)/i)[1].to_i
55
55
  debug "Found license version from Name: #{version}", 1
56
56
  return version
57
57
  end
data/lib/idrac/system.rb CHANGED
@@ -490,5 +490,117 @@ module IDRAC
490
490
  total_memory = memory_data.sum { |m| m.capacity_bytes }
491
491
  "%0.2f GB" % (total_memory.to_f / 1.gigabyte)
492
492
  end
493
+
494
+ # Get complete system configuration
495
+ def get_system_config
496
+ response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1?$expand=*($levels=1)")
497
+
498
+ if response.status == 200
499
+ return JSON.parse(response.body)
500
+ else
501
+ raise Error, "Failed to retrieve system configuration: #{response.status}"
502
+ end
503
+ end
504
+
505
+ # Get system summary information (used by CLI summary command)
506
+ def get_system_summary
507
+ # Get system information
508
+ system_response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1")
509
+ system_info = JSON.parse(system_response.body)
510
+
511
+ # Get iDRAC information
512
+ idrac_response = authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1")
513
+ idrac_info = JSON.parse(idrac_response.body)
514
+
515
+ # Get network information
516
+ network_response = authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/EthernetInterfaces/NIC.1")
517
+ network_info = JSON.parse(network_response.body)
518
+
519
+ # Initialize license_type to Unknown
520
+ license_type = "Unknown"
521
+ license_description = nil
522
+
523
+ # Try to get license information using DMTF standard method
524
+ begin
525
+ license_response = authenticated_request(:get, "/redfish/v1/LicenseService/Licenses")
526
+ license_info = JSON.parse(license_response.body)
527
+
528
+ # Extract license type if licenses are found
529
+ if license_info["Members"] && !license_info["Members"].empty?
530
+ license_entry_response = authenticated_request(:get, license_info["Members"][0]["@odata.id"])
531
+ license_entry = JSON.parse(license_entry_response.body)
532
+
533
+ # Get license type from EntitlementId or LicenseType
534
+ if license_entry["EntitlementId"] && license_entry["EntitlementId"].include?("Enterprise")
535
+ license_type = "Enterprise"
536
+ elsif license_entry["LicenseType"]
537
+ license_type = license_entry["LicenseType"]
538
+ end
539
+
540
+ # Get license description if available
541
+ license_description = license_entry["Description"] if license_entry["Description"]
542
+ end
543
+ rescue => e
544
+ # If DMTF method fails, try Dell OEM method
545
+ begin
546
+ dell_license_response = authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/DellLicenses")
547
+ dell_license_info = JSON.parse(dell_license_response.body)
548
+
549
+ # Extract license type if licenses are found
550
+ if dell_license_info["Members"] && !dell_license_info["Members"].empty?
551
+ dell_license_entry_response = authenticated_request(:get, dell_license_info["Members"][0]["@odata.id"])
552
+ dell_license_entry = JSON.parse(dell_license_entry_response.body)
553
+
554
+ # Get license type from LicenseType or Description
555
+ if dell_license_entry["LicenseType"]
556
+ license_type = dell_license_entry["LicenseType"]
557
+ elsif dell_license_entry["Description"] && dell_license_entry["Description"].include?("Enterprise")
558
+ license_type = "Enterprise"
559
+ end
560
+
561
+ # Get license description if available
562
+ license_description = dell_license_entry["Description"] if dell_license_entry["Description"]
563
+ end
564
+ rescue => e2
565
+ # License information not available
566
+ end
567
+ end
568
+
569
+ # Format the license display string
570
+ license_display = license_type
571
+ if license_description
572
+ license_display = "#{license_type} (#{license_description})"
573
+ end
574
+
575
+ # Return the system summary
576
+ {
577
+ power_state: system_info["PowerState"],
578
+ model: system_info["Model"],
579
+ host_name: system_info["HostName"],
580
+ operating_system: system_info.dig("Oem", "Dell", "OperatingSystem"),
581
+ os_version: system_info.dig("Oem", "Dell", "OperatingSystemVersion"),
582
+ service_tag: system_info["SKU"],
583
+ bios_version: system_info.dig("BiosVersion"),
584
+ idrac_firmware: idrac_info.dig("FirmwareVersion"),
585
+ ip_address: network_info.dig("IPv4Addresses", 0, "Address"),
586
+ mac_address: network_info.dig("MACAddress"),
587
+ license: license_display
588
+ }
589
+ end
590
+
591
+ # Get basic system information (used for test_live function)
592
+ def get_basic_system_info
593
+ response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1")
594
+
595
+ if response.status == 200
596
+ data = JSON.parse(response.body)
597
+ return {
598
+ model: data["Model"],
599
+ sku: data["SKU"]
600
+ }
601
+ else
602
+ raise Error, "Failed to get basic system information: #{response.status}"
603
+ end
604
+ end
493
605
  end
494
606
  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.5.1"
4
+ VERSION = "0.5.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idrac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel