radfish-ami 0.1.7 → 0.1.9

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: 68366b5bbb4d8bd874dace449a8f4f87c4ce9b94f503484429b94b825db10f25
4
+ data.tar.gz: 4be49b40686ca504e3d8dcb53aa39c2d3c707779f006f1dd187f56020cb1af90
5
5
  SHA512:
6
- metadata.gz: 4c74710a833e5fa6af773b910e679a5d0ead7a444e4c0ef3f66097cf1b4e5a3586e46b143baaed3c9f44a5b745680206e558c19b7a00ecf2a1ac4374b8942169
7
- data.tar.gz: 1f3841480ba7b7affead0434fddf6350f47f20f8ee8c4a5f904fe27a62d7750af0b19840d20da1901682107021ae76647a9d016c7925b5edd1c67a925961ccf5
6
+ metadata.gz: 6d4e9353cab999154107ca5c3b22eb394654f11559da85da560010600225a8fa1e1cb2ecfb658bf54bdd7d41693ba4f0399ec9f5b2284d6fad9852fee6a48cb5
7
+ data.tar.gz: 84b352d9f9023aa6d75221c0038ea7b4efb3efd68df87ce484d62c267b55419bcfd479f65312c1b761dfc1adc099b8effa495ef04a690e0225226901b7a068c5
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Radfish
4
4
  module Ami
5
- VERSION = "0.1.7"
5
+ VERSION = "0.1.9"
6
6
  end
7
7
  end
@@ -300,19 +300,25 @@ module Radfish
300
300
  controller_response = authenticated_request(:get, member["@odata.id"])
301
301
  next nil unless controller_response.status == 200
302
302
  data = JSON.parse(controller_response.body)
303
- Radfish::Controller.new(
304
- client: self,
303
+ # Return OpenStruct - Radfish::Client will wrap in Controller
304
+ OpenStruct.new(
305
305
  id: data["Id"],
306
306
  name: data["Name"],
307
307
  model: data["Model"],
308
308
  status: data.dig("Status", "Health"),
309
- adapter_data: data
309
+ "@odata.id": member["@odata.id"]
310
310
  )
311
311
  end.compact
312
312
  end
313
313
 
314
314
  def drives(controller)
315
- controller_id = controller.is_a?(Radfish::Controller) ? controller.id : controller
315
+ controller_id = if controller.is_a?(Radfish::Controller)
316
+ controller.id
317
+ elsif controller.respond_to?(:id)
318
+ controller.id
319
+ else
320
+ controller
321
+ end
316
322
  response = authenticated_request(:get, "/redfish/v1/Systems/#{SYSTEM_ID}/Storage/#{controller_id}")
317
323
  return [] unless response.status == 200
318
324
 
@@ -339,8 +345,13 @@ module Radfish
339
345
  end
340
346
 
341
347
  def volumes(controller)
342
- controller_obj = controller.is_a?(Radfish::Controller) ? controller : nil
343
- controller_id = controller.is_a?(Radfish::Controller) ? controller.id : controller
348
+ controller_id = if controller.is_a?(Radfish::Controller)
349
+ controller.id
350
+ elsif controller.respond_to?(:id)
351
+ controller.id
352
+ else
353
+ controller
354
+ end
344
355
  response = authenticated_request(:get, "/redfish/v1/Systems/#{SYSTEM_ID}/Storage/#{controller_id}/Volumes")
345
356
  return [] unless response.status == 200
346
357
 
@@ -351,37 +362,37 @@ module Radfish
351
362
  volume_response = authenticated_request(:get, member["@odata.id"])
352
363
  next nil unless volume_response.status == 200
353
364
  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
- )
365
+ # Return hash with normalized keys - Radfish::Client will wrap in Volume
366
+ # Keep the raw data for adapter_data access
367
+ data["id"] = data["Id"]
368
+ data["name"] = data["Name"]
369
+ data["capacity_bytes"] = data["CapacityBytes"]
370
+ data["raid_type"] = data["RAIDType"]
371
+ data["health"] = data.dig("Status", "Health")
372
+ data
364
373
  end.compact
365
374
  end
366
375
 
367
376
  def volume_drives(volume)
368
377
  volume_id = volume.is_a?(Radfish::Volume) ? volume.id : volume
369
- # Get volume details to find linked drives
378
+ # Get volume details to find linked drives - adapter_data is the raw hash
370
379
  volume_data = volume.is_a?(Radfish::Volume) ? volume.adapter_data : nil
371
380
 
372
- unless volume_data
381
+ # volume_data should be a hash with "Links" -> "Drives"
382
+ unless volume_data.is_a?(Hash)
373
383
  # Need to fetch volume data
374
384
  storage_controllers.each do |controller|
375
385
  vols = volumes(controller)
376
- vol = vols.find { |v| v.id == volume_id }
386
+ # volumes() returns hashes now
387
+ vol = vols.find { |v| (v["id"] || v["Id"]) == volume_id }
377
388
  if vol
378
- volume_data = vol.adapter_data
389
+ volume_data = vol
379
390
  break
380
391
  end
381
392
  end
382
393
  end
383
394
 
384
- return [] unless volume_data
395
+ return [] unless volume_data.is_a?(Hash)
385
396
 
386
397
  drive_refs = volume_data.dig("Links", "Drives") || []
387
398
  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.9
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: []