radfish 0.1.6 → 0.1.7
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/cli.rb +85 -9
- data/lib/radfish/core/storage.rb +4 -4
- data/lib/radfish/version.rb +1 -1
- 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: 064a6be3fcb21aa68b6786d7ca29470b67367b81153c9eea6b687957a4e7b94b
|
4
|
+
data.tar.gz: c3ce598858e7d82dde4be0d3694ce076f1e758f20687b2050cb845857ee60f01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61143335dfd6f5cf5cd75867a5798510bc9c46f8fba8183df67b41deea3d3e7198619bf69e397e90391427daf7c05314736c3e6c0f5c5d0900f8e59496051de1
|
7
|
+
data.tar.gz: deaf413a2c8293ed11ce6f83a67815993036ae6a6ac6308ef80e33247b91371f0acc6b56e9ed52d7b9e99b8b612bb64076a365be7044a5df315c064db73ef34b
|
data/lib/radfish/cli.rb
CHANGED
@@ -351,23 +351,96 @@ module Radfish
|
|
351
351
|
end
|
352
352
|
end
|
353
353
|
when 'drives', 'disks'
|
354
|
-
|
354
|
+
# Get all drives from all controllers
|
355
|
+
controllers = client.storage_controllers
|
356
|
+
all_drives = []
|
357
|
+
|
358
|
+
controllers.each do |controller|
|
359
|
+
# Handle different ways the controller ID might be stored
|
360
|
+
controller_id = if controller.is_a?(OpenStruct)
|
361
|
+
# For OpenStruct, access the internal table
|
362
|
+
controller.instance_variable_get(:@table)[:"@odata.id"] ||
|
363
|
+
controller.instance_variable_get(:@table)["@odata.id"] ||
|
364
|
+
controller.id
|
365
|
+
elsif controller.respond_to?(:[])
|
366
|
+
# For Hash-like objects
|
367
|
+
controller['@odata.id'] || controller['id']
|
368
|
+
else
|
369
|
+
# For other objects
|
370
|
+
controller.id rescue nil
|
371
|
+
end
|
372
|
+
|
373
|
+
if controller_id
|
374
|
+
begin
|
375
|
+
drives = client.drives(controller_id)
|
376
|
+
all_drives.concat(drives) if drives
|
377
|
+
rescue => e
|
378
|
+
puts "Error fetching drives for controller #{controller['name'] || controller_id}: #{e.message}".yellow if options[:verbose]
|
379
|
+
end
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
355
383
|
if options[:json]
|
356
|
-
puts JSON.pretty_generate(
|
384
|
+
puts JSON.pretty_generate(all_drives)
|
357
385
|
else
|
358
386
|
puts "=== Physical Drives ===".green
|
359
|
-
|
360
|
-
puts "
|
387
|
+
if all_drives.empty?
|
388
|
+
puts "No drives found".yellow
|
389
|
+
else
|
390
|
+
all_drives.each do |drive|
|
391
|
+
cert_status = drive['certified'] || drive.certified rescue nil
|
392
|
+
cert_info = cert_status ? " [Certified: #{cert_status}]" : ""
|
393
|
+
capacity = drive['capacity_gb'] || drive.capacity_gb rescue "Unknown"
|
394
|
+
status = drive['status'] || drive.status rescue "Unknown"
|
395
|
+
name = drive['name'] || drive.name rescue "Unknown"
|
396
|
+
puts "#{name}: #{capacity} GB - #{status}#{cert_info}".cyan
|
397
|
+
end
|
361
398
|
end
|
362
399
|
end
|
363
400
|
when 'volumes', 'raids'
|
364
|
-
|
401
|
+
# Get all volumes from all controllers
|
402
|
+
controllers = client.storage_controllers
|
403
|
+
all_volumes = []
|
404
|
+
|
405
|
+
controllers.each do |controller|
|
406
|
+
# Handle different ways the controller ID might be stored
|
407
|
+
controller_id = if controller.is_a?(OpenStruct)
|
408
|
+
# For OpenStruct, access the internal table
|
409
|
+
controller.instance_variable_get(:@table)[:"@odata.id"] ||
|
410
|
+
controller.instance_variable_get(:@table)["@odata.id"] ||
|
411
|
+
controller.id
|
412
|
+
elsif controller.respond_to?(:[])
|
413
|
+
# For Hash-like objects
|
414
|
+
controller['@odata.id'] || controller['id']
|
415
|
+
else
|
416
|
+
# For other objects
|
417
|
+
controller.id rescue nil
|
418
|
+
end
|
419
|
+
|
420
|
+
if controller_id
|
421
|
+
begin
|
422
|
+
volumes = client.volumes(controller_id)
|
423
|
+
all_volumes.concat(volumes) if volumes
|
424
|
+
rescue => e
|
425
|
+
puts "Error fetching volumes for controller #{controller['name'] || controller_id}: #{e.message}".yellow if options[:verbose]
|
426
|
+
end
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
365
430
|
if options[:json]
|
366
|
-
puts JSON.pretty_generate(
|
431
|
+
puts JSON.pretty_generate(all_volumes)
|
367
432
|
else
|
368
433
|
puts "=== Volumes ===".green
|
369
|
-
|
370
|
-
puts "
|
434
|
+
if all_volumes.empty?
|
435
|
+
puts "No volumes found".yellow
|
436
|
+
else
|
437
|
+
all_volumes.each do |vol|
|
438
|
+
name = vol['name'] || vol.name rescue "Unknown"
|
439
|
+
capacity = vol['capacity_gb'] || vol.capacity_gb rescue "Unknown"
|
440
|
+
raid_type = vol['raid_type'] || vol.raid_type rescue "Unknown"
|
441
|
+
status = vol['status'] || vol.status rescue "Unknown"
|
442
|
+
puts "#{name}: #{capacity} GB - #{raid_type} (Status: #{status})".cyan
|
443
|
+
end
|
371
444
|
end
|
372
445
|
end
|
373
446
|
else
|
@@ -795,7 +868,10 @@ module Radfish
|
|
795
868
|
puts "\n=== Power Supplies ===".green
|
796
869
|
data.each do |psu|
|
797
870
|
status_color = psu['status'] == 'OK' ? :green : :red
|
798
|
-
|
871
|
+
voltage_info = psu['voltage'] ? "#{psu['voltage']}V (#{psu['voltage_human'] || 'Unknown'})" : ""
|
872
|
+
puts "#{psu['name']}: #{voltage_info} #{psu['watts']}W - #{psu['status']}".send(status_color)
|
873
|
+
puts " Model: #{psu['model']}" if psu['model']
|
874
|
+
puts " Serial: #{psu['serial']}" if psu['serial']
|
799
875
|
end
|
800
876
|
end
|
801
877
|
end
|
data/lib/radfish/core/storage.rb
CHANGED
@@ -7,12 +7,12 @@ module Radfish
|
|
7
7
|
raise NotImplementedError, "Adapter must implement #storage_controllers"
|
8
8
|
end
|
9
9
|
|
10
|
-
def drives
|
11
|
-
raise NotImplementedError, "Adapter must implement #drives"
|
10
|
+
def drives(controller_id)
|
11
|
+
raise NotImplementedError, "Adapter must implement #drives(controller_id)"
|
12
12
|
end
|
13
13
|
|
14
|
-
def volumes
|
15
|
-
raise NotImplementedError, "Adapter must implement #volumes"
|
14
|
+
def volumes(controller_id)
|
15
|
+
raise NotImplementedError, "Adapter must implement #volumes(controller_id)"
|
16
16
|
end
|
17
17
|
|
18
18
|
def storage_summary
|
data/lib/radfish/version.rb
CHANGED