radfish-idrac 0.1.5 → 0.2.1

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: bd2c3bf25651e2968b2bbb5646abfe3be4af7679d750f1f5d958a8440db7762a
4
- data.tar.gz: e6235fd71297dc9ef3feea51d9d30e8ad80e645e4b37e8000a396be45fa628ec
3
+ metadata.gz: 498ca5982c494dc12664edf49adb339c54e4a6c642b649e307ce73ca5b13b760
4
+ data.tar.gz: ef423da63f06a0a0931b82c9faf2427b46ec91d85b647dac560cb957020dc042
5
5
  SHA512:
6
- metadata.gz: c8a449130e8451cf9eacb9fc5cccbba1d8180ce874933488426b8ae1c589313a8ba6f725115351b40b2cf8c334869b6973c2d076231fe3347cbe96eed2727fb5
7
- data.tar.gz: 8835042ad7199c7a88965099f2e5473101db5e5c7597ba09a195b1b790743aee2f2c2f7a1ba1110697094ac3dd8737154123e3c84f4bded61ea1f036c842888f
6
+ metadata.gz: f02763dccf483a5c969d6752a09db593249393b0983544d664c77f68e410d53fd63f1fc69a2201ccf9434560841f501492cf7491ae2ccc2d9a5d513dcabc5596
7
+ data.tar.gz: bbbca9598994cbe3ed5e38c55a6e5fe4a7672b0607168c624b2e4944098f6140ea569b5b7251c0f97786bea370dda9f17fc438e7e901a03a7b49ccc5657dd85b
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radfish
4
4
  module Idrac
5
- VERSION = "0.1.5"
5
+ VERSION = "0.2.1"
6
6
  end
7
- end
7
+ end
@@ -302,9 +302,11 @@ module Radfish
302
302
  end
303
303
  end
304
304
 
305
- def drives(controller_id)
306
- # The iDRAC gem requires a controller_id
307
- raise ArgumentError, "Controller ID is required" unless controller_id
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
308
310
 
309
311
  drive_data = @idrac_client.drives(controller_id)
310
312
 
@@ -312,9 +314,11 @@ module Radfish
312
314
  drive_data.map { |drive| OpenStruct.new(drive) }
313
315
  end
314
316
 
315
- def volumes(controller_id)
316
- # The iDRAC gem requires a controller_id
317
- raise ArgumentError, "Controller ID is required" unless controller_id
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
318
322
 
319
323
  volume_data = @idrac_client.volumes(controller_id)
320
324
 
@@ -353,6 +357,23 @@ module Radfish
353
357
  }
354
358
  end
355
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
374
+ end
375
+
376
+ public
356
377
 
357
378
  # Virtual Media
358
379
 
@@ -734,4 +755,4 @@ module Radfish
734
755
  # Register the adapter
735
756
  Radfish.register_adapter('dell', IdracAdapter)
736
757
  Radfish.register_adapter('idrac', IdracAdapter)
737
- end
758
+ 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.5
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel