radfish-ami 0.1.6 → 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: 8437153ec6bf1a793ee23f287fdea85dc0b3511b2e8a87e7fb615dd8ea9737d4
4
- data.tar.gz: 18c7ea5001939cc76bbdd31673e1ad012ec94b79ab373f43ef216ff7fe9b6f35
3
+ metadata.gz: 68366b5bbb4d8bd874dace449a8f4f87c4ce9b94f503484429b94b825db10f25
4
+ data.tar.gz: 4be49b40686ca504e3d8dcb53aa39c2d3c707779f006f1dd187f56020cb1af90
5
5
  SHA512:
6
- metadata.gz: 7663274856b229b95ec203efcf2cf9921b3bd5553b675ba2ca0a9e016671d9872f657c725fb021e4dbca04f998521054d334586bfdbaeb6e041cbd29842e1907
7
- data.tar.gz: f26cb16d15eb2ffa2c16a94a518049e358c7aa9977c9e6e7811151aee0b33f693c7ddc440605809377b2d9c0e70010e525c89a0a19abc4605831b6d084855c3f
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.6"
5
+ VERSION = "0.1.9"
6
6
  end
7
7
  end
@@ -22,6 +22,11 @@ module Radfish
22
22
  "ami"
23
23
  end
24
24
 
25
+ # Allow adapter to be used directly where code expects client.adapter
26
+ def adapter
27
+ self
28
+ end
29
+
25
30
  # Session management
26
31
  def login
27
32
  @session = Core::Session.new(self)
@@ -295,19 +300,25 @@ module Radfish
295
300
  controller_response = authenticated_request(:get, member["@odata.id"])
296
301
  next nil unless controller_response.status == 200
297
302
  data = JSON.parse(controller_response.body)
298
- Radfish::Controller.new(
299
- client: self,
303
+ # Return OpenStruct - Radfish::Client will wrap in Controller
304
+ OpenStruct.new(
300
305
  id: data["Id"],
301
306
  name: data["Name"],
302
307
  model: data["Model"],
303
308
  status: data.dig("Status", "Health"),
304
- adapter_data: data
309
+ "@odata.id": member["@odata.id"]
305
310
  )
306
311
  end.compact
307
312
  end
308
313
 
309
314
  def drives(controller)
310
- 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
311
322
  response = authenticated_request(:get, "/redfish/v1/Systems/#{SYSTEM_ID}/Storage/#{controller_id}")
312
323
  return [] unless response.status == 200
313
324
 
@@ -334,8 +345,13 @@ module Radfish
334
345
  end
335
346
 
336
347
  def volumes(controller)
337
- controller_obj = controller.is_a?(Radfish::Controller) ? controller : nil
338
- 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
339
355
  response = authenticated_request(:get, "/redfish/v1/Systems/#{SYSTEM_ID}/Storage/#{controller_id}/Volumes")
340
356
  return [] unless response.status == 200
341
357
 
@@ -346,37 +362,37 @@ module Radfish
346
362
  volume_response = authenticated_request(:get, member["@odata.id"])
347
363
  next nil unless volume_response.status == 200
348
364
  data = JSON.parse(volume_response.body)
349
- Radfish::Volume.new(
350
- client: self,
351
- controller: controller_obj,
352
- id: data["Id"],
353
- name: data["Name"],
354
- capacity_bytes: data["CapacityBytes"],
355
- raid_type: data["RAIDType"],
356
- health: data.dig("Status", "Health"),
357
- adapter_data: data
358
- )
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
359
373
  end.compact
360
374
  end
361
375
 
362
376
  def volume_drives(volume)
363
377
  volume_id = volume.is_a?(Radfish::Volume) ? volume.id : volume
364
- # Get volume details to find linked drives
378
+ # Get volume details to find linked drives - adapter_data is the raw hash
365
379
  volume_data = volume.is_a?(Radfish::Volume) ? volume.adapter_data : nil
366
380
 
367
- unless volume_data
381
+ # volume_data should be a hash with "Links" -> "Drives"
382
+ unless volume_data.is_a?(Hash)
368
383
  # Need to fetch volume data
369
384
  storage_controllers.each do |controller|
370
385
  vols = volumes(controller)
371
- vol = vols.find { |v| v.id == volume_id }
386
+ # volumes() returns hashes now
387
+ vol = vols.find { |v| (v["id"] || v["Id"]) == volume_id }
372
388
  if vol
373
- volume_data = vol.adapter_data
389
+ volume_data = vol
374
390
  break
375
391
  end
376
392
  end
377
393
  end
378
394
 
379
- return [] unless volume_data
395
+ return [] unless volume_data.is_a?(Hash)
380
396
 
381
397
  drive_refs = volume_data.dig("Links", "Drives") || []
382
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.6
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: []