radfish 0.2.3 → 0.2.5

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: 73011007c472b46cd1b41258548fdc37da25f15a4d14c370809aeafe5d67953b
4
- data.tar.gz: 0b649b8aa1b6c5d05eae02641b2fef7fc6bb9d45b913fdd7727c875c69c62562
3
+ metadata.gz: 2a440779d106c4dab6553860f7a70b63c606072fdf79ebf37164d32a6e9dd5bd
4
+ data.tar.gz: 3c1c74fb4bea5668de9e8fb68fddd16e72b7ba716c62e3d650b8cbd368822da5
5
5
  SHA512:
6
- metadata.gz: 65195d4125e3afb35707adc1b87d1370de1df0b2e19afe6a5a7e56a0ace94a8437b83f9c70d1d6ada0861074d7dede5d3ccb06c5861e1e20aec95388d79ae763
7
- data.tar.gz: c99fcf649bb95dd02a861457920c310f276ec544f86fa3016771953dd277ac8a9c996add49207c59fa7f200384db570ae2b45d64abe2612663145e5b13085b98
6
+ metadata.gz: 2023d3129b3cac7eb57f0a7d1f2b999700636571a6d21080069ae49137e7efd81aac059a8cdda4419ba8f21daf4216f3b72e8ef1a1c6fcd1569aab88030f9bb9
7
+ data.tar.gz: 784a58288211fbfdca734a5581fdaa311f9f32c95edc7240b5ad0eaaa7d64617aa575a8792111d893e2e4d940ba4493a3c6caaaeb3f17d9474a2f94163e54a33
@@ -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
@@ -209,9 +210,33 @@ module Radfish
209
210
  pci_slot: fetch.call(:pci_slot),
210
211
  status: fetch.call(:status),
211
212
  drives_count: fetch.call(:drives_count),
213
+ battery_status: fetch.call(:battery_status),
212
214
  vendor: @vendor,
213
215
  adapter_data: raw
214
216
  )
215
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
+ capacity_gb: fetch.call(:capacity_gb),
235
+ raid_type: fetch.call(:raid_type) || fetch.call(:volume_type),
236
+ status: fetch.call(:status) || fetch.call(:health),
237
+ encrypted: fetch.call(:encrypted),
238
+ adapter_data: raw
239
+ )
240
+ end
216
241
  end
217
242
  end
@@ -6,11 +6,12 @@ module Radfish
6
6
  class Controller
7
7
  attr_reader :id, :name, :model, :vendor, :adapter_data, :firmware_version,
8
8
  :encryption_mode, :encryption_capability, :controller_type,
9
- :pci_slot, :status, :drives_count
9
+ :pci_slot, :status, :drives_count, :battery_status
10
10
 
11
11
  def initialize(client:, id:, name: nil, model: nil, vendor: nil, adapter_data: nil,
12
12
  firmware_version: nil, encryption_mode: nil, encryption_capability: nil,
13
- controller_type: nil, pci_slot: nil, status: nil, drives_count: nil)
13
+ controller_type: nil, pci_slot: nil, status: nil, drives_count: nil,
14
+ battery_status: nil)
14
15
  @client = client
15
16
  @id = id
16
17
  @name = name
@@ -24,6 +25,7 @@ module Radfish
24
25
  @pci_slot = pci_slot
25
26
  @status = status
26
27
  @drives_count = drives_count
28
+ @battery_status = battery_status
27
29
  end
28
30
 
29
31
  # Convenience accessors delegate to the client wrappers
@@ -47,7 +49,8 @@ module Radfish
47
49
  controller_type: controller_type,
48
50
  pci_slot: pci_slot,
49
51
  status: status,
50
- drives_count: drives_count
52
+ drives_count: drives_count,
53
+ battery_status: battery_status
51
54
  }.compact
52
55
  end
53
56
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Radfish
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Radfish
4
+ class Volume
5
+ attr_reader :id, :name, :capacity_bytes, :capacity_gb, :raid_type,
6
+ :status, :encrypted, :adapter_data, :controller
7
+
8
+ def initialize(client:, controller:, id: nil, name: nil, capacity_bytes: nil,
9
+ capacity_gb: nil, raid_type: nil, status: nil, encrypted: nil,
10
+ adapter_data: nil)
11
+ @client = client
12
+ @controller = controller
13
+ @id = id
14
+ @name = name
15
+ @capacity_bytes = capacity_bytes
16
+ @capacity_gb = capacity_gb || (capacity_bytes ? (capacity_bytes.to_f / (1000**3)).round(2) : nil)
17
+ @raid_type = raid_type
18
+ @status = status
19
+ @encrypted = encrypted
20
+ @adapter_data = adapter_data
21
+ end
22
+
23
+ def drives
24
+ @client.adapter.volume_drives(self)
25
+ end
26
+
27
+ def to_h
28
+ {
29
+ id: id,
30
+ name: name,
31
+ capacity_bytes: capacity_bytes,
32
+ capacity_gb: capacity_gb,
33
+ raid_type: raid_type,
34
+ status: status,
35
+ encrypted: encrypted
36
+ }.compact
37
+ end
38
+ end
39
+ end
40
+
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.3
4
+ version: 0.2.5
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: