radfish-ami 0.1.4 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b9d6c1504f5b0420021db42cf51f92f4864b57e829ab2167526758889f42a0a
4
- data.tar.gz: 23b729993a4fd05476a6737f2b7eed8d21c6d4b297f850ea5b5dda35659897c8
3
+ metadata.gz: 8437153ec6bf1a793ee23f287fdea85dc0b3511b2e8a87e7fb615dd8ea9737d4
4
+ data.tar.gz: 18c7ea5001939cc76bbdd31673e1ad012ec94b79ab373f43ef216ff7fe9b6f35
5
5
  SHA512:
6
- metadata.gz: aa22eff985917551a7b889041c667f888b82dcc07c8f6dd95303c5b46c7d79152aa785bf9b3f01a22ffe4deb8683fb8a4d3486add7541e2fb51e3be658087cef
7
- data.tar.gz: 94b80ed7c35a5bbf43d8f4ee73f5b988e34f8d95a7932ed6df295241d595aa941d2df896d4f670a71c516cebbc4000fde21a7d67c6357bbdc01128d8098688ff
6
+ metadata.gz: 7663274856b229b95ec203efcf2cf9921b3bd5553b675ba2ca0a9e016671d9872f657c725fb021e4dbca04f998521054d334586bfdbaeb6e041cbd29842e1907
7
+ data.tar.gz: f26cb16d15eb2ffa2c16a94a518049e358c7aa9977c9e6e7811151aee0b33f693c7ddc440605809377b2d9c0e70010e525c89a0a19abc4605831b6d084855c3f
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radfish
4
4
  module Ami
5
- VERSION = "0.1.4"
5
+ VERSION = "0.1.6"
6
6
  end
7
7
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'ostruct'
4
+
3
5
  module Radfish
4
6
  class AmiAdapter < Core::BaseClient
5
7
  include Core::Power
@@ -138,30 +140,12 @@ module Radfish
138
140
  def system_health
139
141
  info = system_info
140
142
  status = info["Status"] || {}
141
- HealthStatus.new(
143
+ OpenStruct.new(
142
144
  health: status["Health"] || "Unknown",
143
145
  rollup: status["HealthRollup"] || status["Health"] || "Unknown"
144
146
  )
145
147
  end
146
148
 
147
- # Simple struct for health status with rollup
148
- class HealthStatus
149
- attr_reader :health, :rollup
150
-
151
- def initialize(health:, rollup:)
152
- @health = health
153
- @rollup = rollup
154
- end
155
-
156
- def to_s
157
- @health
158
- end
159
-
160
- def ==(other)
161
- other.to_s == to_s
162
- end
163
- end
164
-
165
149
  def bmc_info
166
150
  manager = get_manager_info
167
151
  network = get_bmc_network
@@ -186,7 +170,16 @@ module Radfish
186
170
  members.map do |member|
187
171
  cpu_response = authenticated_request(:get, member["@odata.id"])
188
172
  next nil unless cpu_response.status == 200
189
- JSON.parse(cpu_response.body)
173
+ data = JSON.parse(cpu_response.body)
174
+ OpenStruct.new(
175
+ socket: data["Socket"] || data["Id"],
176
+ manufacturer: data["Manufacturer"],
177
+ model: data.dig("ProcessorId", "EffectiveFamily")&.strip || data["Model"],
178
+ cores: data["TotalCores"],
179
+ threads: data["TotalThreads"],
180
+ speed_mhz: data["MaxSpeedMHz"],
181
+ health: data.dig("Status", "Health") || "Unknown"
182
+ )
190
183
  end.compact
191
184
  end
192
185
 
@@ -200,7 +193,17 @@ module Radfish
200
193
  members.map do |member|
201
194
  mem_response = authenticated_request(:get, member["@odata.id"])
202
195
  next nil unless mem_response.status == 200
203
- JSON.parse(mem_response.body)
196
+ data = JSON.parse(mem_response.body)
197
+ OpenStruct.new(
198
+ name: data["Name"] || data["Id"],
199
+ capacity_bytes: data["CapacityMiB"] ? data["CapacityMiB"] * 1024 * 1024 : nil,
200
+ speed_mhz: data["OperatingSpeedMhz"],
201
+ manufacturer: data["Manufacturer"],
202
+ part_number: data["PartNumber"],
203
+ serial_number: data["SerialNumber"],
204
+ memory_type: data["MemoryDeviceType"],
205
+ status: data.dig("Status", "Health") || "OK"
206
+ )
204
207
  end.compact
205
208
  end
206
209
 
@@ -214,23 +217,58 @@ module Radfish
214
217
  members.map do |member|
215
218
  nic_response = authenticated_request(:get, member["@odata.id"])
216
219
  next nil unless nic_response.status == 200
217
- JSON.parse(nic_response.body)
220
+ data = JSON.parse(nic_response.body)
221
+ OpenStruct.new(
222
+ name: data["Name"] || data["Id"],
223
+ mac: data["MACAddress"],
224
+ speed_mbps: data["SpeedMbps"],
225
+ link_status: data["LinkStatus"],
226
+ ipv4_addresses: data["IPv4Addresses"],
227
+ ipv6_addresses: data["IPv6Addresses"],
228
+ status: data.dig("Status", "Health") || "OK"
229
+ )
218
230
  end.compact
219
231
  end
220
232
 
221
233
  def fans
222
234
  thermal = get_thermal_data
223
- thermal["Fans"] || []
235
+ (thermal["Fans"] || []).map do |fan|
236
+ OpenStruct.new(
237
+ name: fan["Name"] || fan["MemberId"],
238
+ rpm: fan["Reading"],
239
+ status: fan.dig("Status", "Health") || "OK",
240
+ min_rpm: fan["MinReadingRange"],
241
+ max_rpm: fan["MaxReadingRange"]
242
+ )
243
+ end
224
244
  end
225
245
 
226
246
  def temperatures
227
247
  thermal = get_thermal_data
228
- thermal["Temperatures"] || []
248
+ (thermal["Temperatures"] || []).map do |temp|
249
+ OpenStruct.new(
250
+ name: temp["Name"] || temp["MemberId"],
251
+ reading_celsius: temp["ReadingCelsius"],
252
+ status: temp.dig("Status", "Health") || "OK",
253
+ upper_threshold_critical: temp["UpperThresholdCritical"],
254
+ upper_threshold_fatal: temp["UpperThresholdFatal"]
255
+ )
256
+ end
229
257
  end
230
258
 
231
259
  def psus
232
260
  power_data = get_power_data
233
- power_data["PowerSupplies"] || []
261
+ (power_data["PowerSupplies"] || []).map do |psu|
262
+ OpenStruct.new(
263
+ name: psu["Name"] || psu["MemberId"],
264
+ model: psu["Model"],
265
+ serial: psu["SerialNumber"],
266
+ watts: psu["PowerCapacityWatts"],
267
+ voltage: psu.dig("InputRanges", 0, "NominalVoltageVolts"),
268
+ voltage_human: psu.dig("InputRanges", 0, "InputType"),
269
+ status: psu.dig("Status", "Health") || "OK"
270
+ )
271
+ end
234
272
  end
235
273
 
236
274
  def power_consumption
@@ -279,7 +317,19 @@ module Radfish
279
317
  drive_refs.map do |ref|
280
318
  drive_response = authenticated_request(:get, ref["@odata.id"])
281
319
  next nil unless drive_response.status == 200
282
- JSON.parse(drive_response.body)
320
+ drive_data = JSON.parse(drive_response.body)
321
+ OpenStruct.new(
322
+ name: drive_data["Name"] || drive_data["Id"],
323
+ model: drive_data["Model"],
324
+ manufacturer: drive_data["Manufacturer"],
325
+ serial: drive_data["SerialNumber"],
326
+ capacity_bytes: drive_data["CapacityBytes"],
327
+ capacity_gb: drive_data["CapacityBytes"] ? (drive_data["CapacityBytes"] / 1_000_000_000.0).round(2) : nil,
328
+ media_type: drive_data["MediaType"],
329
+ protocol: drive_data["Protocol"],
330
+ status: drive_data.dig("Status", "Health") || "OK",
331
+ certified: drive_data.dig("Oem", "Dell", "Certified") || drive_data.dig("Oem", "AMI", "Certified")
332
+ )
283
333
  end.compact
284
334
  end
285
335
 
@@ -332,7 +382,18 @@ module Radfish
332
382
  drive_refs.map do |ref|
333
383
  drive_response = authenticated_request(:get, ref["@odata.id"])
334
384
  next nil unless drive_response.status == 200
335
- JSON.parse(drive_response.body)
385
+ drive_data = JSON.parse(drive_response.body)
386
+ OpenStruct.new(
387
+ name: drive_data["Name"] || drive_data["Id"],
388
+ model: drive_data["Model"],
389
+ manufacturer: drive_data["Manufacturer"],
390
+ serial: drive_data["SerialNumber"],
391
+ capacity_bytes: drive_data["CapacityBytes"],
392
+ capacity_gb: drive_data["CapacityBytes"] ? (drive_data["CapacityBytes"] / 1_000_000_000.0).round(2) : nil,
393
+ media_type: drive_data["MediaType"],
394
+ protocol: drive_data["Protocol"],
395
+ status: drive_data.dig("Status", "Health") || "OK"
396
+ )
336
397
  end.compact
337
398
  end
338
399
 
data/radfish-ami.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_dependency "radfish", "~> 0.2"
27
+ spec.add_dependency "ostruct", ">= 0"
27
28
 
28
29
  spec.add_development_dependency "bundler", "~> 2.0"
29
30
  spec.add_development_dependency "rake", "~> 13.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radfish-ami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ostruct
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement