radfish-ami 0.1.7 → 0.1.10

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: 7a8366ebff88acb6537e811e7e94e4e07ed0d00e0f8ee9ee48b7cd003133f2dd
4
- data.tar.gz: cc728ce842585bd10f7e6fe97506da24ee8d1405c865288f9dcffff22d00695c
3
+ metadata.gz: fd85e3b625acf54dd8f3a6ab8e6e626e7678b2ee6bb893c20812eacebe901262
4
+ data.tar.gz: 25fda3a8c8187a2f5f8d6c0b1745aaa4223917d810940f7e3f86abec3ea8050a
5
5
  SHA512:
6
- metadata.gz: 4c74710a833e5fa6af773b910e679a5d0ead7a444e4c0ef3f66097cf1b4e5a3586e46b143baaed3c9f44a5b745680206e558c19b7a00ecf2a1ac4374b8942169
7
- data.tar.gz: 1f3841480ba7b7affead0434fddf6350f47f20f8ee8c4a5f904fe27a62d7750af0b19840d20da1901682107021ae76647a9d016c7925b5edd1c67a925961ccf5
6
+ metadata.gz: 502361dc9fbc00539f97539df2d8510d95682d5e90b1cc275f404087a248e53aa5f3547a9dde944b3ed30ce0b4da3875cbd9ba4ab86038c58519fcf79fa888cf
7
+ data.tar.gz: 8d5cc66f2b8c2271f1860782cecd6eecb3c5fa15c51e43a98d0256f57908b7b3af453bdfae888be03294bf5caea3850aeed9b10cdc56cf2ece0c28da80469681
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radfish
4
4
  module Ami
5
- VERSION = "0.1.7"
5
+ VERSION = "0.1.10"
6
6
  end
7
7
  end
@@ -288,6 +288,34 @@ module Radfish
288
288
  0
289
289
  end
290
290
 
291
+ # PCI Devices
292
+ def pci_devices
293
+ # Try PCIeDevices endpoint first (Redfish standard)
294
+ response = authenticated_request(:get, "/redfish/v1/Systems/#{SYSTEM_ID}/PCIeDevices")
295
+ if response.status == 200
296
+ collection = JSON.parse(response.body)
297
+ members = collection["Members"] || []
298
+
299
+ return members.map do |member|
300
+ device_response = authenticated_request(:get, member["@odata.id"])
301
+ next nil unless device_response.status == 200
302
+ data = JSON.parse(device_response.body)
303
+ OpenStruct.new(
304
+ id: data["Id"],
305
+ name: data["Name"],
306
+ manufacturer: data["Manufacturer"],
307
+ model: data["Model"],
308
+ device_type: data["DeviceType"],
309
+ pcie_interface: data["PCIeInterface"],
310
+ status: data.dig("Status", "Health") || "OK"
311
+ )
312
+ end.compact
313
+ end
314
+
315
+ # Fallback: return empty array if not supported
316
+ []
317
+ end
318
+
291
319
  # Storage
292
320
  def storage_controllers
293
321
  response = authenticated_request(:get, "/redfish/v1/Systems/#{SYSTEM_ID}/Storage")
@@ -300,19 +328,25 @@ module Radfish
300
328
  controller_response = authenticated_request(:get, member["@odata.id"])
301
329
  next nil unless controller_response.status == 200
302
330
  data = JSON.parse(controller_response.body)
303
- Radfish::Controller.new(
304
- client: self,
331
+ # Return OpenStruct - Radfish::Client will wrap in Controller
332
+ OpenStruct.new(
305
333
  id: data["Id"],
306
334
  name: data["Name"],
307
335
  model: data["Model"],
308
336
  status: data.dig("Status", "Health"),
309
- adapter_data: data
337
+ "@odata.id": member["@odata.id"]
310
338
  )
311
339
  end.compact
312
340
  end
313
341
 
314
342
  def drives(controller)
315
- controller_id = controller.is_a?(Radfish::Controller) ? controller.id : controller
343
+ controller_id = if controller.is_a?(Radfish::Controller)
344
+ controller.id
345
+ elsif controller.respond_to?(:id)
346
+ controller.id
347
+ else
348
+ controller
349
+ end
316
350
  response = authenticated_request(:get, "/redfish/v1/Systems/#{SYSTEM_ID}/Storage/#{controller_id}")
317
351
  return [] unless response.status == 200
318
352
 
@@ -339,8 +373,13 @@ module Radfish
339
373
  end
340
374
 
341
375
  def volumes(controller)
342
- controller_obj = controller.is_a?(Radfish::Controller) ? controller : nil
343
- controller_id = controller.is_a?(Radfish::Controller) ? controller.id : controller
376
+ controller_id = if controller.is_a?(Radfish::Controller)
377
+ controller.id
378
+ elsif controller.respond_to?(:id)
379
+ controller.id
380
+ else
381
+ controller
382
+ end
344
383
  response = authenticated_request(:get, "/redfish/v1/Systems/#{SYSTEM_ID}/Storage/#{controller_id}/Volumes")
345
384
  return [] unless response.status == 200
346
385
 
@@ -351,37 +390,37 @@ module Radfish
351
390
  volume_response = authenticated_request(:get, member["@odata.id"])
352
391
  next nil unless volume_response.status == 200
353
392
  data = JSON.parse(volume_response.body)
354
- Radfish::Volume.new(
355
- client: self,
356
- controller: controller_obj,
357
- id: data["Id"],
358
- name: data["Name"],
359
- capacity_bytes: data["CapacityBytes"],
360
- raid_type: data["RAIDType"],
361
- health: data.dig("Status", "Health"),
362
- adapter_data: data
363
- )
393
+ # Return hash with normalized keys - Radfish::Client will wrap in Volume
394
+ # Keep the raw data for adapter_data access
395
+ data["id"] = data["Id"]
396
+ data["name"] = data["Name"]
397
+ data["capacity_bytes"] = data["CapacityBytes"]
398
+ data["raid_type"] = data["RAIDType"]
399
+ data["health"] = data.dig("Status", "Health")
400
+ data
364
401
  end.compact
365
402
  end
366
403
 
367
404
  def volume_drives(volume)
368
405
  volume_id = volume.is_a?(Radfish::Volume) ? volume.id : volume
369
- # Get volume details to find linked drives
406
+ # Get volume details to find linked drives - adapter_data is the raw hash
370
407
  volume_data = volume.is_a?(Radfish::Volume) ? volume.adapter_data : nil
371
408
 
372
- unless volume_data
409
+ # volume_data should be a hash with "Links" -> "Drives"
410
+ unless volume_data.is_a?(Hash)
373
411
  # Need to fetch volume data
374
412
  storage_controllers.each do |controller|
375
413
  vols = volumes(controller)
376
- vol = vols.find { |v| v.id == volume_id }
414
+ # volumes() returns hashes now
415
+ vol = vols.find { |v| (v["id"] || v["Id"]) == volume_id }
377
416
  if vol
378
- volume_data = vol.adapter_data
417
+ volume_data = vol
379
418
  break
380
419
  end
381
420
  end
382
421
  end
383
422
 
384
- return [] unless volume_data
423
+ return [] unless volume_data.is_a?(Hash)
385
424
 
386
425
  drive_refs = volume_data.dig("Links", "Drives") || []
387
426
  drive_refs.map do |ref|
data/radfish-ami.gemspec CHANGED
@@ -14,8 +14,6 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 3.1.0"
16
16
 
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = spec.homepage
19
17
  spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
20
18
 
21
19
  spec.files = Dir.chdir(__dir__) do
@@ -24,7 +22,7 @@ Gem::Specification.new do |spec|
24
22
  spec.require_paths = ["lib"]
25
23
 
26
24
  spec.add_dependency "radfish", "~> 0.2"
27
- spec.add_dependency "ostruct", ">= 0"
25
+ spec.add_dependency "ostruct", "~> 0.6"
28
26
 
29
27
  spec.add_development_dependency "bundler", "~> 2.0"
30
28
  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.7
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: ostruct
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '0.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '0.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -113,8 +113,6 @@ homepage: https://github.com/buildio/radfish-ami
113
113
  licenses:
114
114
  - MIT
115
115
  metadata:
116
- homepage_uri: https://github.com/buildio/radfish-ami
117
- source_code_uri: https://github.com/buildio/radfish-ami
118
116
  changelog_uri: https://github.com/buildio/radfish-ami/blob/main/CHANGELOG.md
119
117
  post_install_message:
120
118
  rdoc_options: []