radfish-ami 0.1.5 → 0.1.7

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: 7a8366ebff88acb6537e811e7e94e4e07ed0d00e0f8ee9ee48b7cd003133f2dd
4
+ data.tar.gz: cc728ce842585bd10f7e6fe97506da24ee8d1405c865288f9dcffff22d00695c
5
5
  SHA512:
6
- metadata.gz: b18bc999bb6607fae5568abaf52dca97f099d1b22d0b99b98a8e8c541f1e71df865b0a4936133ebcdeb81962acbe1a064b455edb4c8e35c2309878b1417af89d
7
- data.tar.gz: 50e6c3098399c64b645d81dc9a8caefc5a480aa6836f9e3476c11a7194b5467576b7df32259ce2b30c4849f797364516f48d3de63ec439bb7c17ff83dee0cb25
6
+ metadata.gz: 4c74710a833e5fa6af773b910e679a5d0ead7a444e4c0ef3f66097cf1b4e5a3586e46b143baaed3c9f44a5b745680206e558c19b7a00ecf2a1ac4374b8942169
7
+ data.tar.gz: 1f3841480ba7b7affead0434fddf6350f47f20f8ee8c4a5f904fe27a62d7750af0b19840d20da1901682107021ae76647a9d016c7925b5edd1c67a925961ccf5
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radfish
4
4
  module Ami
5
- VERSION = "0.1.5"
5
+ VERSION = "0.1.7"
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
@@ -20,6 +22,11 @@ module Radfish
20
22
  "ami"
21
23
  end
22
24
 
25
+ # Allow adapter to be used directly where code expects client.adapter
26
+ def adapter
27
+ self
28
+ end
29
+
23
30
  # Session management
24
31
  def login
25
32
  @session = Core::Session.new(self)
@@ -138,62 +145,12 @@ module Radfish
138
145
  def system_health
139
146
  info = system_info
140
147
  status = info["Status"] || {}
141
- HealthStatus.new(
148
+ OpenStruct.new(
142
149
  health: status["Health"] || "Unknown",
143
150
  rollup: status["HealthRollup"] || status["Health"] || "Unknown"
144
151
  )
145
152
  end
146
153
 
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
154
  def bmc_info
198
155
  manager = get_manager_info
199
156
  network = get_bmc_network
@@ -219,7 +176,15 @@ module Radfish
219
176
  cpu_response = authenticated_request(:get, member["@odata.id"])
220
177
  next nil unless cpu_response.status == 200
221
178
  data = JSON.parse(cpu_response.body)
222
- CpuInfo.new(data)
179
+ OpenStruct.new(
180
+ socket: data["Socket"] || data["Id"],
181
+ manufacturer: data["Manufacturer"],
182
+ model: data.dig("ProcessorId", "EffectiveFamily")&.strip || data["Model"],
183
+ cores: data["TotalCores"],
184
+ threads: data["TotalThreads"],
185
+ speed_mhz: data["MaxSpeedMHz"],
186
+ health: data.dig("Status", "Health") || "Unknown"
187
+ )
223
188
  end.compact
224
189
  end
225
190
 
@@ -233,7 +198,17 @@ module Radfish
233
198
  members.map do |member|
234
199
  mem_response = authenticated_request(:get, member["@odata.id"])
235
200
  next nil unless mem_response.status == 200
236
- JSON.parse(mem_response.body)
201
+ data = JSON.parse(mem_response.body)
202
+ OpenStruct.new(
203
+ name: data["Name"] || data["Id"],
204
+ capacity_bytes: data["CapacityMiB"] ? data["CapacityMiB"] * 1024 * 1024 : nil,
205
+ speed_mhz: data["OperatingSpeedMhz"],
206
+ manufacturer: data["Manufacturer"],
207
+ part_number: data["PartNumber"],
208
+ serial_number: data["SerialNumber"],
209
+ memory_type: data["MemoryDeviceType"],
210
+ status: data.dig("Status", "Health") || "OK"
211
+ )
237
212
  end.compact
238
213
  end
239
214
 
@@ -247,23 +222,58 @@ module Radfish
247
222
  members.map do |member|
248
223
  nic_response = authenticated_request(:get, member["@odata.id"])
249
224
  next nil unless nic_response.status == 200
250
- JSON.parse(nic_response.body)
225
+ data = JSON.parse(nic_response.body)
226
+ OpenStruct.new(
227
+ name: data["Name"] || data["Id"],
228
+ mac: data["MACAddress"],
229
+ speed_mbps: data["SpeedMbps"],
230
+ link_status: data["LinkStatus"],
231
+ ipv4_addresses: data["IPv4Addresses"],
232
+ ipv6_addresses: data["IPv6Addresses"],
233
+ status: data.dig("Status", "Health") || "OK"
234
+ )
251
235
  end.compact
252
236
  end
253
237
 
254
238
  def fans
255
239
  thermal = get_thermal_data
256
- thermal["Fans"] || []
240
+ (thermal["Fans"] || []).map do |fan|
241
+ OpenStruct.new(
242
+ name: fan["Name"] || fan["MemberId"],
243
+ rpm: fan["Reading"],
244
+ status: fan.dig("Status", "Health") || "OK",
245
+ min_rpm: fan["MinReadingRange"],
246
+ max_rpm: fan["MaxReadingRange"]
247
+ )
248
+ end
257
249
  end
258
250
 
259
251
  def temperatures
260
252
  thermal = get_thermal_data
261
- thermal["Temperatures"] || []
253
+ (thermal["Temperatures"] || []).map do |temp|
254
+ OpenStruct.new(
255
+ name: temp["Name"] || temp["MemberId"],
256
+ reading_celsius: temp["ReadingCelsius"],
257
+ status: temp.dig("Status", "Health") || "OK",
258
+ upper_threshold_critical: temp["UpperThresholdCritical"],
259
+ upper_threshold_fatal: temp["UpperThresholdFatal"]
260
+ )
261
+ end
262
262
  end
263
263
 
264
264
  def psus
265
265
  power_data = get_power_data
266
- power_data["PowerSupplies"] || []
266
+ (power_data["PowerSupplies"] || []).map do |psu|
267
+ OpenStruct.new(
268
+ name: psu["Name"] || psu["MemberId"],
269
+ model: psu["Model"],
270
+ serial: psu["SerialNumber"],
271
+ watts: psu["PowerCapacityWatts"],
272
+ voltage: psu.dig("InputRanges", 0, "NominalVoltageVolts"),
273
+ voltage_human: psu.dig("InputRanges", 0, "InputType"),
274
+ status: psu.dig("Status", "Health") || "OK"
275
+ )
276
+ end
267
277
  end
268
278
 
269
279
  def power_consumption
@@ -312,7 +322,19 @@ module Radfish
312
322
  drive_refs.map do |ref|
313
323
  drive_response = authenticated_request(:get, ref["@odata.id"])
314
324
  next nil unless drive_response.status == 200
315
- JSON.parse(drive_response.body)
325
+ drive_data = JSON.parse(drive_response.body)
326
+ OpenStruct.new(
327
+ name: drive_data["Name"] || drive_data["Id"],
328
+ model: drive_data["Model"],
329
+ manufacturer: drive_data["Manufacturer"],
330
+ serial: drive_data["SerialNumber"],
331
+ capacity_bytes: drive_data["CapacityBytes"],
332
+ capacity_gb: drive_data["CapacityBytes"] ? (drive_data["CapacityBytes"] / 1_000_000_000.0).round(2) : nil,
333
+ media_type: drive_data["MediaType"],
334
+ protocol: drive_data["Protocol"],
335
+ status: drive_data.dig("Status", "Health") || "OK",
336
+ certified: drive_data.dig("Oem", "Dell", "Certified") || drive_data.dig("Oem", "AMI", "Certified")
337
+ )
316
338
  end.compact
317
339
  end
318
340
 
@@ -365,7 +387,18 @@ module Radfish
365
387
  drive_refs.map do |ref|
366
388
  drive_response = authenticated_request(:get, ref["@odata.id"])
367
389
  next nil unless drive_response.status == 200
368
- JSON.parse(drive_response.body)
390
+ drive_data = JSON.parse(drive_response.body)
391
+ OpenStruct.new(
392
+ name: drive_data["Name"] || drive_data["Id"],
393
+ model: drive_data["Model"],
394
+ manufacturer: drive_data["Manufacturer"],
395
+ serial: drive_data["SerialNumber"],
396
+ capacity_bytes: drive_data["CapacityBytes"],
397
+ capacity_gb: drive_data["CapacityBytes"] ? (drive_data["CapacityBytes"] / 1_000_000_000.0).round(2) : nil,
398
+ media_type: drive_data["MediaType"],
399
+ protocol: drive_data["Protocol"],
400
+ status: drive_data.dig("Status", "Health") || "OK"
401
+ )
369
402
  end.compact
370
403
  end
371
404
 
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.7
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