radfish 0.2.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d6c54aeb9655a43ed2fddc650f5ad6ab7042ee36c6e28977b080033a7d66ad8
4
- data.tar.gz: bd313932fe76b381a63d9b6ef1e8d91129cd61666ba0739c9629c45f3f198589
3
+ metadata.gz: 73011007c472b46cd1b41258548fdc37da25f15a4d14c370809aeafe5d67953b
4
+ data.tar.gz: 0b649b8aa1b6c5d05eae02641b2fef7fc6bb9d45b913fdd7727c875c69c62562
5
5
  SHA512:
6
- metadata.gz: 759f93847d982760321fd989f0aa3931f01602371b2485d276c8a57b623d210a47c2b791911e7d850e87360ae7d1f57b6ba697d06065a1377b73c977638ae3ae
7
- data.tar.gz: 792d117f69fb50fe9c6f62ca271edadd7886e901d958e372ea052e55d4b38d4987bb4060f4e28336e67221a1df8dfb8b9885680cf1f85ecdad6722d6e07b508b
6
+ metadata.gz: 65195d4125e3afb35707adc1b87d1370de1df0b2e19afe6a5a7e56a0ace94a8437b83f9c70d1d6ada0861074d7dede5d3ccb06c5861e1e20aec95388d79ae763
7
+ data.tar.gz: c99fcf649bb95dd02a861457920c310f276ec544f86fa3016771953dd277ac8a9c996add49207c59fa7f200384db570ae2b45d64abe2612663145e5b13085b98
@@ -188,18 +188,30 @@ module Radfish
188
188
  private
189
189
 
190
190
  def build_controller(raw)
191
- # Only extract friendly name/id if plainly available; keep raw in adapter_data
192
- id = if raw.respond_to?(:[])
193
- raw['id'] || raw[:id]
194
- elsif raw.respond_to?(:id)
195
- raw.id
196
- end
197
- name = if raw.respond_to?(:[])
198
- raw['name'] || raw[:name]
199
- elsif raw.respond_to?(:name)
200
- raw.name
201
- end
202
- Controller.new(client: self, id: id, name: name, vendor: @vendor, adapter_data: raw)
191
+ # Expect adapters to provide normalized fields; keep mapping straightforward.
192
+ fetch = ->(key) do
193
+ if raw.respond_to?(:[])
194
+ raw[key.to_s] || raw[key.to_sym]
195
+ elsif raw.respond_to?(key.to_sym)
196
+ raw.public_send(key.to_sym)
197
+ end
198
+ end
199
+
200
+ Controller.new(
201
+ client: self,
202
+ id: fetch.call(:id),
203
+ name: fetch.call(:name),
204
+ model: fetch.call(:model),
205
+ firmware_version: fetch.call(:firmware_version),
206
+ encryption_mode: fetch.call(:encryption_mode),
207
+ encryption_capability: fetch.call(:encryption_capability),
208
+ controller_type: fetch.call(:controller_type),
209
+ pci_slot: fetch.call(:pci_slot),
210
+ status: fetch.call(:status),
211
+ drives_count: fetch.call(:drives_count),
212
+ vendor: @vendor,
213
+ adapter_data: raw
214
+ )
203
215
  end
204
216
  end
205
217
  end
@@ -4,14 +4,26 @@ module Radfish
4
4
  # Lightweight value object representing a storage controller.
5
5
  # Holds a stable identifier and optional name.
6
6
  class Controller
7
- attr_reader :id, :name, :vendor, :adapter_data
7
+ attr_reader :id, :name, :model, :vendor, :adapter_data, :firmware_version,
8
+ :encryption_mode, :encryption_capability, :controller_type,
9
+ :pci_slot, :status, :drives_count
8
10
 
9
- def initialize(client:, id:, name: nil, vendor: nil, adapter_data: nil)
11
+ def initialize(client:, id:, name: nil, model: nil, vendor: nil, adapter_data: nil,
12
+ firmware_version: nil, encryption_mode: nil, encryption_capability: nil,
13
+ controller_type: nil, pci_slot: nil, status: nil, drives_count: nil)
10
14
  @client = client
11
15
  @id = id
12
16
  @name = name
17
+ @model = model
13
18
  @vendor = vendor
14
19
  @adapter_data = adapter_data
20
+ @firmware_version = firmware_version
21
+ @encryption_mode = encryption_mode
22
+ @encryption_capability = encryption_capability
23
+ @controller_type = controller_type
24
+ @pci_slot = pci_slot
25
+ @status = status
26
+ @drives_count = drives_count
15
27
  end
16
28
 
17
29
  # Convenience accessors delegate to the client wrappers
@@ -24,11 +36,24 @@ module Radfish
24
36
  end
25
37
 
26
38
  def to_h
27
- { id: id, name: name, vendor: vendor }
39
+ {
40
+ id: id,
41
+ name: name,
42
+ model: model,
43
+ vendor: vendor,
44
+ firmware_version: firmware_version,
45
+ encryption_mode: encryption_mode,
46
+ encryption_capability: encryption_capability,
47
+ controller_type: controller_type,
48
+ pci_slot: pci_slot,
49
+ status: status,
50
+ drives_count: drives_count
51
+ }.compact
28
52
  end
29
53
 
30
54
  def ==(other)
31
55
  other.is_a?(Controller) && other.id == id && other.vendor.to_s == vendor.to_s
32
56
  end
57
+
33
58
  end
34
59
  end
@@ -18,6 +18,7 @@ module Radfish
18
18
  def storage_summary
19
19
  raise NotImplementedError, "Adapter must implement #storage_summary"
20
20
  end
21
+
21
22
  end
22
23
  end
23
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Radfish
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel