radfish 0.1.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b58ebe70659a5db047e1d6efb8c8ec93ba7a7cce19f500f46204add014095566
4
- data.tar.gz: 754e9d84d9bc6232cadaa4daf75fa4053b3d0fa9d53918b2f1160223775c85f9
3
+ metadata.gz: 064a6be3fcb21aa68b6786d7ca29470b67367b81153c9eea6b687957a4e7b94b
4
+ data.tar.gz: c3ce598858e7d82dde4be0d3694ce076f1e758f20687b2050cb845857ee60f01
5
5
  SHA512:
6
- metadata.gz: 4653a3eb7d252f6a597db65f4a403f1b5f958dc5659d9a0a0f4eb73f669acc9b3be6b0d61b2686e4666823769e4027cd6eb31429a29c130cf08ab9b28aa64b77
7
- data.tar.gz: dc6f9ffc5dd25d59ee68d70ab0071378d3d6aa4c4004f13e612d31415c817bdf48bc70433f7344685fb34ac529397226883d9e24ecfb66e3ccfbb1b6f52d7307
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
- data = client.drives
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(data)
384
+ puts JSON.pretty_generate(all_drives)
357
385
  else
358
386
  puts "=== Physical Drives ===".green
359
- data.each do |drive|
360
- puts "#{drive['name']}: #{drive['capacity_gb']} GB - #{drive['status']}".cyan
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
- data = client.volumes
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(data)
431
+ puts JSON.pretty_generate(all_volumes)
367
432
  else
368
433
  puts "=== Volumes ===".green
369
- data.each do |vol|
370
- puts "#{vol['name']}: #{vol['capacity_gb']} GB - #{vol['raid_type']}".cyan
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
- puts "#{psu['name']}: #{psu['watts']}W - #{psu['status']}".send(status_color)
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
@@ -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
@@ -7,6 +7,22 @@ module Radfish
7
7
  raise NotImplementedError, "Adapter must implement #system_info"
8
8
  end
9
9
 
10
+ def service_tag
11
+ raise NotImplementedError, "Adapter must implement #service_tag"
12
+ end
13
+
14
+ def make
15
+ raise NotImplementedError, "Adapter must implement #make"
16
+ end
17
+
18
+ def model
19
+ raise NotImplementedError, "Adapter must implement #model"
20
+ end
21
+
22
+ def serial
23
+ raise NotImplementedError, "Adapter must implement #serial"
24
+ end
25
+
10
26
  def cpus
11
27
  raise NotImplementedError, "Adapter must implement #cpus"
12
28
  end
@@ -20,19 +20,19 @@ module Radfish
20
20
  end
21
21
 
22
22
  def service_tag
23
- fetch_system_info[:service_tag]
23
+ @cache[:service_tag] ||= @client.adapter.service_tag
24
24
  end
25
25
 
26
26
  def make
27
- fetch_system_info[:manufacturer] || fetch_system_info[:make]
27
+ @cache[:make] ||= @client.adapter.make
28
28
  end
29
29
 
30
30
  def model
31
- fetch_system_info[:model]
31
+ @cache[:model] ||= @client.adapter.model
32
32
  end
33
33
 
34
34
  def serial
35
- fetch_system_info[:serial_number] || fetch_system_info[:serial]
35
+ @cache[:serial] ||= @client.adapter.serial
36
36
  end
37
37
 
38
38
  def cpus
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Radfish
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  - !ruby/object:Gem::Version
211
211
  version: '0'
212
212
  requirements: []
213
- rubygems_version: 3.3.26
213
+ rubygems_version: 3.5.22
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Unified Redfish API Client for Server Management