idrac 0.5.2 → 0.5.4

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: e1bffe050d6256766e75d7a51d80133d14c3b86abcfc53b1de4e172be80f4747
4
- data.tar.gz: c74c883203a6b14e2f18041c7df0e4dacae125cbf6f6cc6a3da2a0dd1bc56ef6
3
+ metadata.gz: 11b28d37156ee3d58ef6a804a016cc6ca35f6a4e7c4e158c93fe86c0053398f0
4
+ data.tar.gz: c69c297450fb2715873e3dbd66f2779d3487ce1fecfca9a4032a7d917d87f8c6
5
5
  SHA512:
6
- metadata.gz: db7644ef1fd92b3af97d0c202d5e3b6d80963bb5ecbe24b4a339249184c29667e7e0dea3f7e99074afaa52af127ef249c9768cf322156a12769a230d7cee7b76
7
- data.tar.gz: 63e817a2e85d68f3c848658adefe7567ebd629546b15362d7ac32c9cb19aea4edd54f5091bf893f38a8f52c84eaa9c6ffda07b71fb4abc8872fde4bf74959961
6
+ metadata.gz: f0beadf7041ca23371999f125d536c25972a615092baf045fdb2694d3c15e2ea28c9f063943e1f8df67065855f26cca23e138622b2f80fba0c8bc8b575c8215c
7
+ data.tar.gz: c88e403f07b030a238f999498c3da04fa5b3908713d469c4e52ed28ea8ac310ec018c9a6be519695d054358a1603045d4a8785d94d029e07b90cdcbf6445a1c5
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
@@ -636,10 +557,10 @@ module IDRAC
636
557
  with_idrac_client do |client|
637
558
  controller = client.controller
638
559
  puts "\nStorage Controller Summary:".green.bold
639
- puts "Name: #{controller['Name']}".cyan
640
- puts "Model: #{controller['Model']}".cyan
641
- puts "Health: #{controller['Status']['Health']}".cyan
642
- puts "Manufacturer: #{controller['Manufacturer']}".cyan
560
+ puts "Name: #{controller.name}".cyan
561
+ puts "Model: #{controller.model}".cyan
562
+ puts "Health: #{controller.status&.health || 'Unknown'}".cyan
563
+ puts "Manufacturer: #{controller.manufacturer}".cyan
643
564
 
644
565
  if client.controller_encryption_capable?(controller)
645
566
  puts "Encryption Capable: Yes".green
@@ -689,17 +610,17 @@ module IDRAC
689
610
 
690
611
  puts "\nPhysical Drives (#{drives.size}):".green.bold
691
612
  drives.each do |drive|
692
- capacity_gb = drive[:capacity_bytes].to_f / (1024**3)
693
- health_color = drive[:health] == "OK" ? :green : :red
613
+ capacity_gb = drive.capacity_bytes.to_f / (1024**3)
614
+ health_color = drive.health == "OK" ? :green : :red
694
615
 
695
- puts "#{drive[:name]}:".bold
696
- puts " Model: #{drive[:model]}".cyan
697
- puts " Health: #{drive[:health].send(health_color)}"
616
+ puts "#{drive.name}:".bold
617
+ puts " Model: #{drive.model}".cyan
618
+ puts " Health: #{drive.health.send(health_color)}"
698
619
  puts " Capacity: #{capacity_gb.round(2)} GB".cyan
699
- puts " Media Type: #{drive[:media_type]}".cyan
700
- puts " Serial: #{drive[:serial]}".cyan
701
- if drive[:encryption_ability]
702
- puts " Encryption: #{drive[:encryption_ability]}".cyan
620
+ puts " Media Type: #{drive.media_type}".cyan
621
+ puts " Serial: #{drive.serial}".cyan
622
+ if drive.encryption_ability
623
+ puts " Encryption: #{drive.encryption_ability}".cyan
703
624
  end
704
625
  puts ""
705
626
  end
@@ -754,7 +675,7 @@ module IDRAC
754
675
  confirmation = $stdin.gets.chomp.downcase
755
676
 
756
677
  if confirmation == 'y'
757
- client.create_virtual_disk(controller['Id'], drives, name: options[:name], raid_type: options[:raid])
678
+ client.create_virtual_disk(controller.odata_Id, drives, name: options[:name], raid_type: options[:raid])
758
679
  puts "Volume created successfully".green
759
680
  else
760
681
  puts "Operation cancelled".yellow
@@ -842,7 +763,7 @@ module IDRAC
842
763
  # Get keyid if not provided
843
764
  keyid = options[:keyid] || "RAID-Key-#{Time.now.strftime('%Y%m%d')}"
844
765
 
845
- client.enable_local_key_management(controller['Id'], passphrase: passphrase, keyid: keyid)
766
+ client.enable_local_key_management(controller.odata_id, passphrase: passphrase, keyid: keyid)
846
767
  puts "Encryption enabled successfully".green
847
768
  end
848
769
  end
@@ -863,7 +784,7 @@ module IDRAC
863
784
  confirmation = $stdin.gets.chomp
864
785
 
865
786
  if confirmation == 'DISABLE'
866
- client.disable_local_key_management(controller['Id'])
787
+ client.disable_local_key_management(controller.odata_id)
867
788
  puts "Encryption disabled successfully".green
868
789
  else
869
790
  puts "Operation cancelled".yellow
@@ -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
@@ -1347,7 +1262,7 @@ module IDRAC
1347
1262
  puts "\n[TEST] Storage management".cyan.bold
1348
1263
  begin
1349
1264
  controller = client.controller
1350
- puts "✓ Storage controller: #{controller['Name']} (#{controller['Model']})".green
1265
+ puts "✓ Storage controller: #{controller.name} (#{controller.model})".green
1351
1266
 
1352
1267
  drives = client.drives(controller)
1353
1268
  puts "✓ Found #{drives.size} physical drives".green
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.2"
4
+ VERSION = "0.5.4"
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.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel