radfish-supermicro 0.2.1 → 0.2.3
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 +58 -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: 45d69cff8a4fa9b65df7c4d70d77b5ffa0f1235630f47d2f9cea14260ee49819
|
4
|
+
data.tar.gz: 993665ad5c2b9c66c916e60803db3958fdfca4eccb2f4561c60ab6647d973118
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 354be81ceb943af7f5598b81deac1ff632df2a2caf100d3782c15582a67fb998922d5629c8050eb721fc0273220e9728c32056ae8998bdb4dd20a6fe53f8397f
|
7
|
+
data.tar.gz: 510680fa6b291f7a580a388171dd635a5d987205e6ed79e2ca472b2d7982cdef695b98b8775d795bea1db41aed011046a90ea755a77eafdbaa6283e671a57fd7
|
@@ -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
|
@@ -340,9 +346,61 @@ module Radfish
|
|
340
346
|
|
341
347
|
volume_data = @supermicro_client.volumes(controller_id)
|
342
348
|
|
349
|
+
# Normalize basic fields for consistency, and attach drive refs if missing
|
350
|
+
volume_data.each do |v|
|
351
|
+
v["raid_type"] ||= v["RAIDType"] if v["RAIDType"]
|
352
|
+
v["volume_type"] ||= v["VolumeType"] if v["VolumeType"]
|
353
|
+
v["health"] ||= v.dig("Status", "Health") if v["Status"].is_a?(Hash)
|
354
|
+
if v["drives"].nil? && v["@odata.id"]
|
355
|
+
begin
|
356
|
+
resp = @supermicro_client.authenticated_request(:get, v["@odata.id"])
|
357
|
+
if resp.status == 200
|
358
|
+
data = JSON.parse(resp.body)
|
359
|
+
v["drives"] = data.dig('Links', 'Drives') || []
|
360
|
+
end
|
361
|
+
rescue => e
|
362
|
+
debug "Could not fetch volume drives: #{e.message}", 2, :yellow
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
343
367
|
# Convert to OpenStruct for consistency
|
344
368
|
volume_data.map { |volume| OpenStruct.new(volume) }
|
345
369
|
end
|
370
|
+
|
371
|
+
def volume_drives(volume)
|
372
|
+
raise ArgumentError, "Volume required" unless volume
|
373
|
+
controller_id = extract_controller_identifier(volume.controller)
|
374
|
+
# Try to fetch volume details to get Links->Drives
|
375
|
+
raw = volume.adapter_data
|
376
|
+
odata_id = nil
|
377
|
+
if raw.respond_to?(:[])
|
378
|
+
odata_id = raw['@odata.id'] || raw[:'@odata.id']
|
379
|
+
elsif raw.respond_to?(:instance_variable_get)
|
380
|
+
table = raw.instance_variable_get(:@table) rescue nil
|
381
|
+
odata_id = table && (table['@odata.id'] || table[:'@odata.id'])
|
382
|
+
end
|
383
|
+
drive_ids = []
|
384
|
+
if odata_id
|
385
|
+
begin
|
386
|
+
response = @supermicro_client.authenticated_request(:get, odata_id)
|
387
|
+
if response.status == 200
|
388
|
+
data = JSON.parse(response.body)
|
389
|
+
refs = data.dig('Links', 'Drives') || []
|
390
|
+
drive_ids = refs.map { |r| (r['@odata.id'] || '').split('/').last }.compact
|
391
|
+
end
|
392
|
+
rescue => e
|
393
|
+
debug "Error fetching volume details: #{e.message}", 1, :yellow
|
394
|
+
end
|
395
|
+
end
|
396
|
+
# Fallback: if no odata links, return all controller drives (unknown membership)
|
397
|
+
all_drives = @supermicro_client.drives(controller_id) rescue []
|
398
|
+
if drive_ids.any?
|
399
|
+
all_drives = all_drives.select { |d| d['id'] == d[:id] rescue false } if all_drives.is_a?(Array)
|
400
|
+
all_drives.select! { |d| drive_ids.include?(d['id'] || d[:id]) }
|
401
|
+
end
|
402
|
+
all_drives.map { |d| OpenStruct.new(d) }
|
403
|
+
end
|
346
404
|
|
347
405
|
def storage_summary
|
348
406
|
@supermicro_client.storage_summary
|