radfish 0.2.4 → 0.2.6
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 +7 -5
- data/lib/radfish/client.rb +32 -1
- data/lib/radfish/core/storage.rb +5 -0
- data/lib/radfish/version.rb +1 -1
- data/lib/radfish/volume.rb +60 -0
- data/lib/radfish.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93a5fb3d6426c95928fb99dea4bf9fe1ec89d9e248bdee0998ca7905130a2c0a
|
4
|
+
data.tar.gz: 83d58cea483fd3b9f4a2ccf2bc9bea4671e6d905b66aea0c543a2a33f7722492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1613faa69f988928629451af00a4ee1631945eaf869a86b823079503d87123bbde630af14fa8cb04aa4cee178794432f0267ef202c05da57946b08ec0b94fe56
|
7
|
+
data.tar.gz: 3edb39da507013792b8bdb65fe8dd38d0a1bb8a65007891dec52278b95c9f99be3ca86eed7ae0048e86d4123a8fb2544b51153fee56ffdbce2f9abebe9e6edc0
|
data/lib/radfish/cli.rb
CHANGED
@@ -406,11 +406,13 @@ module Radfish
|
|
406
406
|
puts "No volumes found".yellow
|
407
407
|
else
|
408
408
|
all_volumes.each do |vol|
|
409
|
-
name = vol
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
409
|
+
name = vol.name
|
410
|
+
bytes = vol.respond_to?(:capacity_bytes) ? vol.capacity_bytes : nil
|
411
|
+
capacity = bytes ? (bytes.to_f / (1000**3)).round(2) : nil
|
412
|
+
raid_type = vol.raid_type
|
413
|
+
status = vol.health
|
414
|
+
cap_str = capacity ? "#{capacity} GB" : "Unknown size"
|
415
|
+
puts "#{name}: #{cap_str} - #{raid_type} (Status: #{status})".cyan
|
414
416
|
end
|
415
417
|
end
|
416
418
|
end
|
data/lib/radfish/client.rb
CHANGED
@@ -182,7 +182,8 @@ module Radfish
|
|
182
182
|
|
183
183
|
def volumes(controller)
|
184
184
|
raise ArgumentError, "Controller required" unless controller.is_a?(Controller)
|
185
|
-
@adapter.volumes(controller)
|
185
|
+
raw = @adapter.volumes(controller)
|
186
|
+
Array(raw).map { |v| build_volume(v, controller) }
|
186
187
|
end
|
187
188
|
|
188
189
|
private
|
@@ -214,5 +215,35 @@ module Radfish
|
|
214
215
|
adapter_data: raw
|
215
216
|
)
|
216
217
|
end
|
218
|
+
|
219
|
+
def build_volume(raw, controller)
|
220
|
+
fetch = ->(key) do
|
221
|
+
if raw.respond_to?(:[])
|
222
|
+
raw[key.to_s] || raw[key.to_sym]
|
223
|
+
elsif raw.respond_to?(key.to_sym)
|
224
|
+
raw.public_send(key.to_sym)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
Volume.new(
|
229
|
+
client: self,
|
230
|
+
controller: controller,
|
231
|
+
id: fetch.call(:id),
|
232
|
+
name: fetch.call(:name),
|
233
|
+
capacity_bytes: fetch.call(:capacity_bytes),
|
234
|
+
raid_type: fetch.call(:raid_type),
|
235
|
+
volume_type: fetch.call(:volume_type),
|
236
|
+
drives: fetch.call(:drives),
|
237
|
+
encrypted: fetch.call(:encrypted),
|
238
|
+
lock_status: fetch.call(:lock_status),
|
239
|
+
stripe_size: fetch.call(:stripe_size),
|
240
|
+
operation_percent_complete: fetch.call(:operation_percent_complete),
|
241
|
+
operation_name: fetch.call(:operation_name),
|
242
|
+
write_cache_policy: fetch.call(:write_cache_policy),
|
243
|
+
read_cache_policy: fetch.call(:read_cache_policy),
|
244
|
+
health: fetch.call(:health),
|
245
|
+
adapter_data: raw
|
246
|
+
)
|
247
|
+
end
|
217
248
|
end
|
218
249
|
end
|
data/lib/radfish/core/storage.rb
CHANGED
@@ -19,6 +19,11 @@ module Radfish
|
|
19
19
|
raise NotImplementedError, "Adapter must implement #storage_summary"
|
20
20
|
end
|
21
21
|
|
22
|
+
# Given a Volume, return its physical drive objects
|
23
|
+
def volume_drives(volume)
|
24
|
+
raise NotImplementedError, "Adapter must implement #volume_drives(volume)"
|
25
|
+
end
|
26
|
+
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
data/lib/radfish/version.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Radfish
|
4
|
+
class Volume
|
5
|
+
# Canonical, normalized attributes only.
|
6
|
+
attr_reader :id, :name, :capacity_bytes, :raid_type, :volume_type, :drives,
|
7
|
+
:encrypted, :lock_status, :stripe_size,
|
8
|
+
:operation_percent_complete, :operation_name,
|
9
|
+
:write_cache_policy, :read_cache_policy, :health,
|
10
|
+
:adapter_data, :controller
|
11
|
+
|
12
|
+
def initialize(client:, controller:, id: nil, name: nil, capacity_bytes: nil,
|
13
|
+
raid_type: nil, volume_type: nil, drives: nil, encrypted: nil,
|
14
|
+
lock_status: nil, stripe_size: nil,
|
15
|
+
operation_percent_complete: nil, operation_name: nil,
|
16
|
+
write_cache_policy: nil, read_cache_policy: nil,
|
17
|
+
health: nil, adapter_data: nil)
|
18
|
+
@client = client
|
19
|
+
@controller = controller
|
20
|
+
@id = id
|
21
|
+
@name = name
|
22
|
+
@capacity_bytes = capacity_bytes
|
23
|
+
@raid_type = raid_type
|
24
|
+
@volume_type = volume_type
|
25
|
+
@drives = Array(drives) # normalized list of drive reference ids (e.g., @odata.id)
|
26
|
+
@encrypted = encrypted
|
27
|
+
@lock_status = lock_status
|
28
|
+
@stripe_size = stripe_size
|
29
|
+
@operation_percent_complete = operation_percent_complete
|
30
|
+
@operation_name = operation_name
|
31
|
+
@write_cache_policy = write_cache_policy
|
32
|
+
@read_cache_policy = read_cache_policy
|
33
|
+
@health = health
|
34
|
+
@adapter_data = adapter_data
|
35
|
+
end
|
36
|
+
|
37
|
+
def drives
|
38
|
+
@client.adapter.volume_drives(self)
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_h
|
42
|
+
{
|
43
|
+
id: id,
|
44
|
+
name: name,
|
45
|
+
capacity_bytes: capacity_bytes,
|
46
|
+
raid_type: raid_type,
|
47
|
+
volume_type: volume_type,
|
48
|
+
drives: drives,
|
49
|
+
encrypted: encrypted,
|
50
|
+
lock_status: lock_status,
|
51
|
+
stripe_size: stripe_size,
|
52
|
+
operation_percent_complete: operation_percent_complete,
|
53
|
+
operation_name: operation_name,
|
54
|
+
write_cache_policy: write_cache_policy,
|
55
|
+
read_cache_policy: read_cache_policy,
|
56
|
+
health: health
|
57
|
+
}.compact
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/radfish.rb
CHANGED
@@ -93,6 +93,7 @@ require_relative 'radfish/power_info'
|
|
93
93
|
require_relative 'radfish/thermal_info'
|
94
94
|
require_relative 'radfish/pci_info'
|
95
95
|
require_relative 'radfish/controller'
|
96
|
+
require_relative 'radfish/volume'
|
96
97
|
require_relative 'radfish/client'
|
97
98
|
|
98
99
|
# Auto-load adapters if available
|
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.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Siegel
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- lib/radfish/thermal_info.rb
|
188
188
|
- lib/radfish/vendor_detector.rb
|
189
189
|
- lib/radfish/version.rb
|
190
|
+
- lib/radfish/volume.rb
|
190
191
|
- radfish.gemspec
|
191
192
|
homepage: https://github.com/buildio/radfish
|
192
193
|
licenses:
|