radfish-idrac 0.1.4 → 0.2.0

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: a58b55f6a0455e66cd44bed5363451e773c675d2a9fd65d7fa5e6bae77669778
4
- data.tar.gz: fab0e351a3112e0376b6d065e5faeb6280f7a2dfea90db9d8845bca67e82e4fb
3
+ metadata.gz: ddb4b7b186fabe9d2a7f58677c4f5f073a31a2b97f9a10ac225d295ec51a134b
4
+ data.tar.gz: fb9346eb375ae8f4a99a5cdba15b7828aaa1e99a99306e3793a6d477f2768c3f
5
5
  SHA512:
6
- metadata.gz: 05f39a32177f9ef7f07fed8d5911d5a0d6bccaad7d315868895356e645866a39ab6a2a6bb1063349925d82336cc65736ffee6a594dad88e643f501035289e658
7
- data.tar.gz: 8e5e9cd3ef3f62d3152b695c35702bccd924df41540bac3434d20182f67c829eee7fa65ccd553ecaf43b75cd9bbbecfef1313269e63a2855aa5b984f831d0178
6
+ metadata.gz: 692a409e789ea2d3ed0fecec7e5340525cb87d1bcb3fa4b9554a2f8f0eb4b985450f8e92cb9bb01ea8805df0bb4f18d7cdbd6f65faa18639b2087b530c97f52d
7
+ data.tar.gz: 4827a7b9506c00a953f84ca5b521a64488ca8182899b6fe013beedb4ffec71b79a00f0368a538e3d97907eadf29464789dd92b65a76b73198f5d966df726ce8b
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radfish
4
4
  module Idrac
5
- VERSION = "0.1.4"
5
+ VERSION = "0.2.0"
6
6
  end
7
- end
7
+ end
@@ -302,16 +302,75 @@ module Radfish
302
302
  end
303
303
  end
304
304
 
305
- def drives
306
- @idrac_client.drives
305
+ def drives(controller)
306
+ # The iDRAC gem requires a controller identifier; derive it from the controller
307
+ raise ArgumentError, "Controller required" unless controller
308
+ controller_id = extract_controller_identifier(controller)
309
+ raise ArgumentError, "Controller identifier missing" unless controller_id
310
+
311
+ drive_data = @idrac_client.drives(controller_id)
312
+
313
+ # Convert to OpenStruct for consistency
314
+ drive_data.map { |drive| OpenStruct.new(drive) }
307
315
  end
308
316
 
309
- def volumes
310
- @idrac_client.volumes
317
+ def volumes(controller)
318
+ # The iDRAC gem requires a controller identifier; derive it from the controller
319
+ raise ArgumentError, "Controller required" unless controller
320
+ controller_id = extract_controller_identifier(controller)
321
+ raise ArgumentError, "Controller identifier missing" unless controller_id
322
+
323
+ volume_data = @idrac_client.volumes(controller_id)
324
+
325
+ # Convert to OpenStruct for consistency
326
+ volume_data.map { |volume| OpenStruct.new(volume) }
311
327
  end
312
328
 
313
329
  def storage_summary
314
- @idrac_client.storage_summary
330
+ # The iDRAC gem doesn't have a storage_summary method
331
+ # We need to build it from controllers, drives, and volumes
332
+ begin
333
+ controllers = @idrac_client.controllers
334
+ total_drives = 0
335
+ total_volumes = 0
336
+
337
+ controllers.each do |controller|
338
+ if controller["@odata.id"]
339
+ drives = @idrac_client.drives(controller["@odata.id"]) rescue []
340
+ volumes = @idrac_client.volumes(controller["@odata.id"]) rescue []
341
+ total_drives += drives.size
342
+ total_volumes += volumes.size
343
+ end
344
+ end
345
+
346
+ {
347
+ "controller_count" => controllers.size,
348
+ "drive_count" => total_drives,
349
+ "volume_count" => total_volumes
350
+ }
351
+ rescue => e
352
+ puts "Error fetching storage summary: #{e.message}" if @debug
353
+ {
354
+ "controller_count" => 0,
355
+ "drive_count" => 0,
356
+ "volume_count" => 0
357
+ }
358
+ end
359
+ end
360
+
361
+ private
362
+
363
+ def extract_controller_identifier(controller)
364
+ # Prefer vendor-native handle from adapter_data
365
+ raw = controller.respond_to?(:adapter_data) ? controller.adapter_data : controller
366
+ if defined?(OpenStruct) && raw.is_a?(OpenStruct)
367
+ table = raw.instance_variable_get(:@table)
368
+ table && (table[:"@odata.id"] || table["@odata.id"]) || controller.id
369
+ elsif raw.respond_to?(:[])
370
+ raw['@odata.id'] || raw[:'@odata.id'] || controller.id
371
+ else
372
+ controller.id
373
+ end
315
374
  end
316
375
 
317
376
  # Virtual Media
@@ -694,4 +753,4 @@ module Radfish
694
753
  # Register the adapter
695
754
  Radfish.register_adapter('dell', IdracAdapter)
696
755
  Radfish.register_adapter('idrac', IdracAdapter)
697
- end
756
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radfish-idrac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel