radfish-supermicro 0.2.0 → 0.2.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 +4 -4
- data/lib/radfish/supermicro/version.rb +1 -1
- data/lib/radfish/supermicro_adapter.rb +42 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59513412ce8868b6e87e3ece78128ef58d5322e1589e76903b700f4d48a58465
|
4
|
+
data.tar.gz: 85c645e36f727accf1b29302ee4a33c2d12fcf72c6775218827e91a638f6eaf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41df444620a328fdcef243eeaa19a9138454908e155fe8d640a1fe427bfb1f6a59635eee7aeb024ed73e6c61dfcf0d2e36f4237a6f1a633a8342af99f1f457c0
|
7
|
+
data.tar.gz: 2c3e82d1fba691c1b1095e21e857a603e1a451dac920e9f78c73146cd8b5b6762689822a30b984b78ea14b9d0a40f57f34a0464099b76fdea81383048dff3663
|
@@ -316,6 +316,12 @@ module Radfish
|
|
316
316
|
if controller["drives"]
|
317
317
|
controller["drives"] = controller["drives"].map { |drive| OpenStruct.new(drive) }
|
318
318
|
end
|
319
|
+
# Normalize expected top-level fields
|
320
|
+
sc = controller["StorageControllers"]&.first || controller["storage_controllers"]&.first
|
321
|
+
controller["model"] ||= (sc && (sc["Model"] || sc["model"]))
|
322
|
+
controller["firmware_version"] ||= (sc && sc["FirmwareVersion"]) if sc
|
323
|
+
controller["drives_count"] ||= (controller["drives"]&.size || controller["Drives"]&.size)
|
324
|
+
# Keep status as already present; other fields may be nil
|
319
325
|
OpenStruct.new(controller)
|
320
326
|
end
|
321
327
|
end
|
@@ -343,6 +349,40 @@ module Radfish
|
|
343
349
|
# Convert to OpenStruct for consistency
|
344
350
|
volume_data.map { |volume| OpenStruct.new(volume) }
|
345
351
|
end
|
352
|
+
|
353
|
+
def volume_drives(volume)
|
354
|
+
raise ArgumentError, "Volume required" unless volume
|
355
|
+
controller_id = extract_controller_identifier(volume.controller)
|
356
|
+
# Try to fetch volume details to get Links->Drives
|
357
|
+
raw = volume.adapter_data
|
358
|
+
odata_id = nil
|
359
|
+
if raw.respond_to?(:[])
|
360
|
+
odata_id = raw['@odata.id'] || raw[:'@odata.id']
|
361
|
+
elsif raw.respond_to?(:instance_variable_get)
|
362
|
+
table = raw.instance_variable_get(:@table) rescue nil
|
363
|
+
odata_id = table && (table['@odata.id'] || table[:'@odata.id'])
|
364
|
+
end
|
365
|
+
drive_ids = []
|
366
|
+
if odata_id
|
367
|
+
begin
|
368
|
+
response = @supermicro_client.authenticated_request(:get, odata_id)
|
369
|
+
if response.status == 200
|
370
|
+
data = JSON.parse(response.body)
|
371
|
+
refs = data.dig('Links', 'Drives') || []
|
372
|
+
drive_ids = refs.map { |r| (r['@odata.id'] || '').split('/').last }.compact
|
373
|
+
end
|
374
|
+
rescue => e
|
375
|
+
debug "Error fetching volume details: #{e.message}", 1, :yellow
|
376
|
+
end
|
377
|
+
end
|
378
|
+
# Fallback: if no odata links, return all controller drives (unknown membership)
|
379
|
+
all_drives = @supermicro_client.drives(controller_id) rescue []
|
380
|
+
if drive_ids.any?
|
381
|
+
all_drives = all_drives.select { |d| d['id'] == d[:id] rescue false } if all_drives.is_a?(Array)
|
382
|
+
all_drives.select! { |d| drive_ids.include?(d['id'] || d[:id]) }
|
383
|
+
end
|
384
|
+
all_drives.map { |d| OpenStruct.new(d) }
|
385
|
+
end
|
346
386
|
|
347
387
|
def storage_summary
|
348
388
|
@supermicro_client.storage_summary
|
@@ -361,6 +401,8 @@ module Radfish
|
|
361
401
|
controller.id
|
362
402
|
end
|
363
403
|
end
|
404
|
+
|
405
|
+
public
|
364
406
|
|
365
407
|
# Virtual Media
|
366
408
|
|