idrac 0.6.1 → 0.6.2

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: 2e29d49fd29e12b9b169c281408e19002beb792c6ad957595190547b8d40ea04
4
- data.tar.gz: 0b52402b5396fd59801c2be34ce764d2e27e90049d6f14dbf501bbb02308339a
3
+ metadata.gz: a6eb419ab79c9a759eccad22d236e0c4889ea3498aa83860d7691dbd334601bd
4
+ data.tar.gz: 344f17aa9bee4aa1bd3899ced2f8af98c04ce7c27d885af6efa6f0a7a4f7a165
5
5
  SHA512:
6
- metadata.gz: 1aba6ce8154a8a3d91eebf28a65ce2c7522207e37fd3777ad5b34dd7e8f61d198d9fa726cdd6f4f1b5d7176c4d2b9a6a274451df01c09a177e7024c7c6102f7f
7
- data.tar.gz: 502b02ee0ab18757af3dfe345011ef0311b2432c8d1c7895a6a774fdf8dd099ae2cadbde4c89f7b5939f36505ce9a6fcab7540586472d03e719224be97cffce9
6
+ metadata.gz: 16695a7a4df759074c7c8e15c3493668b25067377f5b11e82cd2474f4151d290f26e998172180ddc92aad58cc579d9d68042f0d324c6ab7e42814fab18836220
7
+ data.tar.gz: b164817a15ae532794b9ea27c8a03a033be63dfc73e751261f7409d8b9927281e56df1c7f6adcbb1d1c5243cd0b8bf3f4c787e55835a504588a2d8c5540fd1b8
data/bin/idrac CHANGED
@@ -918,6 +918,27 @@ module IDRAC
918
918
  end
919
919
  end
920
920
 
921
+ desc "system_pci_devices", "Get PCI device information"
922
+ map "system:pci-devices" => :system_pci_devices
923
+ map "system:pci:devices" => :system_pci_devices
924
+ def system_pci_devices
925
+ with_idrac_client do |client|
926
+ pci_devices = client.pci_devices
927
+
928
+ puts "\nPCI Devices (#{pci_devices.size}):".green.bold
929
+ pci_devices.each do |device|
930
+ puts "#{device["name"]}:".bold
931
+ puts " Manufacturer: #{device["manufacturer"]}".cyan if device["manufacturer"]
932
+ puts " Device Class: #{device["device_class"]}".cyan if device["device_class"]
933
+ puts " Description: #{device["description"]}".cyan if device["description"]
934
+ puts " ID: #{device["id"]}".cyan if device["id"]
935
+ puts " Slot Type: #{device["slot_type"]}".cyan if device["slot_type"]
936
+ puts " Bus Width: #{device["bus_width"]}".cyan if device["bus_width"]
937
+ puts ""
938
+ end
939
+ end
940
+ end
941
+
921
942
  desc "system_idrac_network", "Get iDRAC network configuration"
922
943
  map "system:idrac_network" => :system_idrac_network
923
944
  def system_idrac_network
@@ -1085,16 +1106,16 @@ module IDRAC
1085
1106
  with_idrac_client do |client|
1086
1107
  info = client.system_info
1087
1108
 
1088
- if info.is_dell
1109
+ if info["is_dell"]
1089
1110
  puts "Dell iDRAC System:".green.bold
1090
- puts " Service Tag: #{info.service_tag}".cyan
1091
- puts " Model: #{info.model}".cyan
1092
- puts " iDRAC Version: #{info.idrac_version}".cyan
1093
- puts " Firmware Version: #{info.firmware_version}".cyan
1111
+ puts " Service Tag: #{info["service_tag"]}".cyan
1112
+ puts " Model: #{info["model"]}".cyan
1113
+ puts " iDRAC Version: #{info["idrac_version"]}".cyan
1114
+ puts " Firmware Version: #{info["firmware_version"]}".cyan
1094
1115
  else
1095
1116
  puts "Not a Dell iDRAC system".yellow
1096
- puts " Product: #{info.product}".cyan
1097
- if info.is_ancient_dell
1117
+ puts " Product: #{info["product"]}".cyan
1118
+ if info["is_ancient_dell"]
1098
1119
  puts " Ancient Dell System detected. Update firmware.".yellow
1099
1120
  end
1100
1121
  end
data/lib/idrac/system.rb CHANGED
@@ -235,6 +235,7 @@ module IDRAC
235
235
 
236
236
  # Get PCI device information
237
237
  def pci_devices
238
+ # First try the standard PCIeDevices endpoint
238
239
  response = authenticated_request(:get, "/redfish/v1/Chassis/System.Embedded.1/PCIeDevices?$expand=*($levels=1)")
239
240
 
240
241
  if response.status == 200
@@ -257,17 +258,17 @@ module IDRAC
257
258
 
258
259
  # Create device info with available data
259
260
  device_info = {
260
- device_class: pcie_function ? pcie_function["DeviceClass"] : nil,
261
- manufacturer: manufacturer,
262
- name: stub["Name"],
263
- description: stub["Description"],
264
- id: pcie_function ? pcie_function["Id"] : stub["Id"],
265
- slot_type: pcie_function ? pcie_function.dig("Oem", "Dell", "DellPCIeFunction", "SlotType") : nil,
266
- bus_width: pcie_function ? pcie_function.dig("Oem", "Dell", "DellPCIeFunction", "DataBusWidth") : nil,
267
- nic: pcie_function ? pcie_function.dig("Links", "EthernetInterfaces", 0, "@odata.id") : nil
261
+ "device_class" => pcie_function ? pcie_function["DeviceClass"] : nil,
262
+ "manufacturer" => manufacturer,
263
+ "name" => stub["Name"],
264
+ "description" => stub["Description"],
265
+ "id" => pcie_function ? pcie_function["Id"] : stub["Id"],
266
+ "slot_type" => pcie_function ? pcie_function.dig("Oem", "Dell", "DellPCIeFunction", "SlotType") : nil,
267
+ "bus_width" => pcie_function ? pcie_function.dig("Oem", "Dell", "DellPCIeFunction", "DataBusWidth") : nil,
268
+ "nic" => pcie_function ? pcie_function.dig("Links", "EthernetInterfaces", 0, "@odata.id") : nil
268
269
  }
269
270
 
270
- puts "PCI Device: #{device_info[:name]} > #{device_info[:manufacturer]} > #{device_info[:device_class]} > #{device_info[:description]} > #{device_info[:id]}"
271
+ puts "PCI Device: #{device_info["name"]} > #{device_info["manufacturer"]} > #{device_info["device_class"]} > #{device_info["description"]} > #{device_info["id"]}"
271
272
 
272
273
  device_info
273
274
  end
@@ -277,7 +278,117 @@ module IDRAC
277
278
  raise Error, "Failed to parse PCI devices response: #{response.body}"
278
279
  end
279
280
  else
280
- raise Error, "Failed to get PCI devices. Status code: #{response.status}"
281
+ # For iDRAC 8, try Dell's recommended approach using System endpoint with PCIeDevices select option
282
+ system_pcie_response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1?$select=PCIeDevices")
283
+
284
+ if system_pcie_response.status == 200
285
+ begin
286
+ system_data = JSON.parse(system_pcie_response.body)
287
+
288
+ if system_data.key?("PCIeDevices") && !system_data["PCIeDevices"].empty?
289
+ pci_devices = []
290
+
291
+ # Process each PCIe device
292
+ system_data["PCIeDevices"].each do |device_link|
293
+ if device_link.is_a?(Hash) && device_link["@odata.id"]
294
+ device_path = device_link["@odata.id"]
295
+ device_response = authenticated_request(:get, device_path)
296
+
297
+ if device_response.status == 200
298
+ device_data = JSON.parse(device_response.body)
299
+
300
+ pci_devices << {
301
+ "device_class" => device_data["DeviceType"] || "Unknown",
302
+ "manufacturer" => device_data["Manufacturer"],
303
+ "name" => device_data["Name"] || device_data["Id"],
304
+ "description" => device_data["Description"],
305
+ "id" => device_data["Id"],
306
+ "slot_type" => device_data.dig("Oem", "Dell", "SlotType"),
307
+ "bus_width" => device_data.dig("Oem", "Dell", "BusWidth"),
308
+ "nic" => nil
309
+ }
310
+ end
311
+ end
312
+ end
313
+
314
+ return pci_devices unless pci_devices.empty?
315
+ end
316
+ rescue JSON::ParserError
317
+ # Continue to next approach
318
+ end
319
+ end
320
+
321
+ # Try NetworkAdapters as an alternative for finding PCIe devices (especially NICs and FC adapters)
322
+ nic_response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1/NetworkAdapters?$expand=*($levels=1)")
323
+
324
+ if nic_response.status == 200
325
+ begin
326
+ nic_data = JSON.parse(nic_response.body)
327
+
328
+ pci_devices = []
329
+
330
+ # Extract PCI info from network adapters
331
+ if nic_data["Members"] && !nic_data["Members"].empty?
332
+ nic_data["Members"].each do |adapter|
333
+ next unless adapter["Model"] || adapter["Manufacturer"]
334
+
335
+ # Check if this is a Fiber Channel adapter by name or model
336
+ is_fc = (adapter["Name"] =~ /FC/i || adapter["Model"] =~ /FC/i ||
337
+ adapter["Id"] =~ /FC/i || adapter["Description"] =~ /Fibre/i) ? true : false
338
+
339
+ device_class = is_fc ? "FibreChannelController" : "NetworkController"
340
+
341
+ pci_devices << {
342
+ "device_class" => device_class,
343
+ "manufacturer" => adapter["Manufacturer"],
344
+ "name" => adapter["Name"] || adapter["Id"],
345
+ "description" => adapter["Description"],
346
+ "id" => adapter["Id"],
347
+ "slot_type" => adapter.dig("Oem", "Dell", "SlotType") ||
348
+ (adapter["Id"] =~ /Slot\.(\d+)/ ? "Slot #{$1}" : nil),
349
+ "bus_width" => nil,
350
+ "nic" => adapter["@odata.id"]
351
+ }
352
+ end
353
+
354
+ return pci_devices unless pci_devices.empty?
355
+ end
356
+ rescue JSON::ParserError
357
+ # Continue to fallback
358
+ end
359
+ end
360
+
361
+ # Last resort: check if PCIeFunctions are directly available
362
+ pcie_functions_response = authenticated_request(:get, "/redfish/v1/Systems/System.Embedded.1/PCIeFunctions?$expand=*($levels=1)")
363
+
364
+ if pcie_functions_response.status == 200
365
+ begin
366
+ functions_data = JSON.parse(pcie_functions_response.body)
367
+
368
+ if functions_data["Members"] && !functions_data["Members"].empty?
369
+ pci_devices = functions_data["Members"].map do |function|
370
+ {
371
+ "device_class" => function["DeviceClass"] || "Unknown",
372
+ "manufacturer" => function["Manufacturer"] || "Unknown",
373
+ "name" => function["Name"] || function["Id"],
374
+ "description" => function["Description"],
375
+ "id" => function["Id"],
376
+ "slot_type" => function.dig("Oem", "Dell", "SlotType"),
377
+ "bus_width" => function.dig("Oem", "Dell", "DataBusWidth"),
378
+ "nic" => nil
379
+ }
380
+ end
381
+
382
+ return pci_devices
383
+ end
384
+ rescue JSON::ParserError
385
+ # Continue to fallback
386
+ end
387
+ end
388
+
389
+ # Fallback for any version when all endpoints unavailable
390
+ puts "PCI device information not available through standard or alternative endpoints" if @verbose
391
+ return []
281
392
  end
282
393
  end
283
394
 
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.6.1"
4
+ VERSION = "0.6.2"
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.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel