radfish-ami 0.1.5 → 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: 472ba0bdf31346a59b277da4019f4d0d84cff7a2bac7831cd0335b2976cef8ea
4
- data.tar.gz: b78f18b561ebc89e3647f4e29454e45054017fc231753e3c8eca83b3e0dfbafe
3
+ metadata.gz: 8437153ec6bf1a793ee23f287fdea85dc0b3511b2e8a87e7fb615dd8ea9737d4
4
+ data.tar.gz: 18c7ea5001939cc76bbdd31673e1ad012ec94b79ab373f43ef216ff7fe9b6f35
5
5
  SHA512:
6
- metadata.gz: b18bc999bb6607fae5568abaf52dca97f099d1b22d0b99b98a8e8c541f1e71df865b0a4936133ebcdeb81962acbe1a064b455edb4c8e35c2309878b1417af89d
7
- data.tar.gz: 50e6c3098399c64b645d81dc9a8caefc5a480aa6836f9e3476c11a7194b5467576b7df32259ce2b30c4849f797364516f48d3de63ec439bb7c17ff83dee0cb25
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.5"
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,62 +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
- # CPU info wrapper
166
- class CpuInfo
167
- attr_reader :socket, :manufacturer, :model, :cores, :threads, :speed_mhz, :status, :raw_data
168
-
169
- def initialize(data)
170
- @raw_data = data
171
- @socket = data["Socket"] || data["Id"]
172
- @manufacturer = data["Manufacturer"]
173
- @model = data.dig("ProcessorId", "EffectiveFamily")&.strip || data["Model"]
174
- @cores = data["TotalCores"]
175
- @threads = data["TotalThreads"]
176
- @speed_mhz = data["MaxSpeedMHz"]
177
- @status = data.dig("Status", "Health") || "Unknown"
178
- end
179
-
180
- def to_h
181
- {
182
- socket: @socket,
183
- manufacturer: @manufacturer,
184
- model: @model,
185
- cores: @cores,
186
- threads: @threads,
187
- speed_mhz: @speed_mhz,
188
- status: @status
189
- }
190
- end
191
-
192
- def [](key)
193
- @raw_data[key]
194
- end
195
- end
196
-
197
149
  def bmc_info
198
150
  manager = get_manager_info
199
151
  network = get_bmc_network
@@ -219,7 +171,15 @@ module Radfish
219
171
  cpu_response = authenticated_request(:get, member["@odata.id"])
220
172
  next nil unless cpu_response.status == 200
221
173
  data = JSON.parse(cpu_response.body)
222
- CpuInfo.new(data)
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
+ )
223
183
  end.compact
224
184
  end
225
185
 
@@ -233,7 +193,17 @@ module Radfish
233
193
  members.map do |member|
234
194
  mem_response = authenticated_request(:get, member["@odata.id"])
235
195
  next nil unless mem_response.status == 200
236
- 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
+ )
237
207
  end.compact
238
208
  end
239
209
 
@@ -247,23 +217,58 @@ module Radfish
247
217
  members.map do |member|
248
218
  nic_response = authenticated_request(:get, member["@odata.id"])
249
219
  next nil unless nic_response.status == 200
250
- 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
+ )
251
230
  end.compact
252
231
  end
253
232
 
254
233
  def fans
255
234
  thermal = get_thermal_data
256
- 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
257
244
  end
258
245
 
259
246
  def temperatures
260
247
  thermal = get_thermal_data
261
- 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
262
257
  end
263
258
 
264
259
  def psus
265
260
  power_data = get_power_data
266
- 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
267
272
  end
268
273
 
269
274
  def power_consumption
@@ -312,7 +317,19 @@ module Radfish
312
317
  drive_refs.map do |ref|
313
318
  drive_response = authenticated_request(:get, ref["@odata.id"])
314
319
  next nil unless drive_response.status == 200
315
- 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
+ )
316
333
  end.compact
317
334
  end
318
335
 
@@ -365,7 +382,18 @@ module Radfish
365
382
  drive_refs.map do |ref|
366
383
  drive_response = authenticated_request(:get, ref["@odata.id"])
367
384
  next nil unless drive_response.status == 200
368
- 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
+ )
369
397
  end.compact
370
398
  end
371
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.5
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