radfish-ami 0.1.2 → 0.1.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: 4a6767dac25a52c3487bb03d27e87ba1f6b86446999b9c911e56e5c03a249238
4
- data.tar.gz: 8ec968e4cb4e7fab05a12268e9d4bc6e24e5b8c58e33d65fd138482362e5a6f5
3
+ metadata.gz: 472ba0bdf31346a59b277da4019f4d0d84cff7a2bac7831cd0335b2976cef8ea
4
+ data.tar.gz: b78f18b561ebc89e3647f4e29454e45054017fc231753e3c8eca83b3e0dfbafe
5
5
  SHA512:
6
- metadata.gz: 9364ad69a1ed099c1df80c6482a182c33da58ae4b1f37c31be3b44f5ec0cbed85736c5850242d4c1355c485f6080ad0ad8c53b7a6d580a11aa18815a698c6cc0
7
- data.tar.gz: f1ce4e6eb97e276db96dbfd9f1e75780a45347908bb1dfa0b9b4a0fe2f04049ca85196eddff83b3c66dd1331536477a9d4ca2d6b20d855432e4687549a611c7a
6
+ metadata.gz: b18bc999bb6607fae5568abaf52dca97f099d1b22d0b99b98a8e8c541f1e71df865b0a4936133ebcdeb81962acbe1a064b455edb4c8e35c2309878b1417af89d
7
+ data.tar.gz: 50e6c3098399c64b645d81dc9a8caefc5a480aa6836f9e3476c11a7194b5467576b7df32259ce2b30c4849f797364516f48d3de63ec439bb7c17ff83dee0cb25
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radfish
4
4
  module Ami
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.5"
6
6
  end
7
7
  end
@@ -137,7 +137,75 @@ module Radfish
137
137
 
138
138
  def system_health
139
139
  info = system_info
140
- info.dig("Status", "Health") || info.dig("Status", "HealthRollup") || "Unknown"
140
+ status = info["Status"] || {}
141
+ HealthStatus.new(
142
+ health: status["Health"] || "Unknown",
143
+ rollup: status["HealthRollup"] || status["Health"] || "Unknown"
144
+ )
145
+ end
146
+
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
+ def bmc_info
198
+ manager = get_manager_info
199
+ network = get_bmc_network
200
+
201
+ {
202
+ firmware_version: manager["FirmwareVersion"],
203
+ redfish_version: service_root["RedfishVersion"],
204
+ mac_address: network["mac_address"],
205
+ ip_address: network["ipv4_address"],
206
+ hostname: network["hostname"],
207
+ health: manager.dig("Status", "Health") || "OK"
208
+ }
141
209
  end
142
210
 
143
211
  def cpus
@@ -150,7 +218,8 @@ module Radfish
150
218
  members.map do |member|
151
219
  cpu_response = authenticated_request(:get, member["@odata.id"])
152
220
  next nil unless cpu_response.status == 200
153
- JSON.parse(cpu_response.body)
221
+ data = JSON.parse(cpu_response.body)
222
+ CpuInfo.new(data)
154
223
  end.compact
155
224
  end
156
225
 
@@ -424,6 +493,17 @@ module Radfish
424
493
  info["Boot"] || {}
425
494
  end
426
495
 
496
+ def boot_options
497
+ boot = boot_config
498
+ {
499
+ "boot_source_override_enabled" => boot["BootSourceOverrideEnabled"],
500
+ "boot_source_override_target" => boot["BootSourceOverrideTarget"],
501
+ "boot_source_override_mode" => boot["BootSourceOverrideMode"],
502
+ "boot_order" => boot["BootOrder"],
503
+ "allowed_targets" => boot["BootSourceOverrideTarget@Redfish.AllowableValues"]
504
+ }
505
+ end
506
+
427
507
  def set_boot_override(target, persistent: false)
428
508
  enabled = persistent ? "Continuous" : "Once"
429
509
  payload = {
@@ -790,6 +870,26 @@ module Radfish
790
870
  {}
791
871
  end
792
872
  end
873
+
874
+ def get_manager_info
875
+ response = authenticated_request(:get, "/redfish/v1/Managers/#{MANAGER_ID}")
876
+ if response.status == 200
877
+ JSON.parse(response.body)
878
+ else
879
+ {}
880
+ end
881
+ end
882
+
883
+ def service_root
884
+ @service_root ||= begin
885
+ response = authenticated_request(:get, "/redfish/v1")
886
+ if response.status == 200
887
+ JSON.parse(response.body)
888
+ else
889
+ {}
890
+ end
891
+ end
892
+ end
793
893
  end
794
894
 
795
895
  # Register the AMI adapter
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.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel