idrac 0.10.1 → 0.10.2

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: 4faf659d1c3e461b586ef1201dae99bb8e82c099e68d153f1a10577bf9905aaa
4
- data.tar.gz: 656f070d756624b34eb78579e2398084dfbf8e9cf6f2ebe85f42d930e505bdef
3
+ metadata.gz: 5e3c0e2f73e3449a852e4e46ca5838705d9ac5eeb780c7fa2023329747406a94
4
+ data.tar.gz: 7430d5ee6cf11aee77dd5f01990a7a1fca680cbfeb40fbad9e65a7a933ed7619
5
5
  SHA512:
6
- metadata.gz: 8e790bf89380f88a3a78f590287732aea452557b908fff4cd9ad2220f1f8d03efeada37536a04b3dfb61d6645e8c570c219098510504f1430cab8a1cb8a72b64
7
- data.tar.gz: c67eca58928d95678a58fdd114f723f1178d0cfa6d311afb82c77e49edf3c754e2a6b7e865620ba2332c0fee19fef650a7e85817c7664667105a01c15eca9dd6
6
+ metadata.gz: 0cbb04e015b2cb0d4c5181355e34c5768250929e99b101b2a23d946b61b6b24f9b4ca8b6e803a7660ffe5f0d388d0f89c8a8b5ef9dda0cb262fcbd580260cfcc
7
+ data.tar.gz: e5284b739c221f9b96697dfdccb14d148e9a07ff1cc86131fc4975f608526583a13f540ba243b9167455de6325f1ced21bb6416230512f2d71a52f2765d6888b
@@ -86,9 +86,16 @@ module IDRAC
86
86
 
87
87
  if component_response.status == 200
88
88
  component_data = JSON.parse(component_response.body)
89
+ # Dell componentID — prefer the Oem field, else parse the inventory
90
+ # Id ("Installed-<componentID>-<version>"). Used to match DUPs by
91
+ # componentID rather than by ambiguous display name.
92
+ fw_id = component_data['Id'].to_s
93
+ component_id = component_data.dig('Oem', 'Dell', 'DellSoftwareInventory', 'ComponentID')
94
+ component_id ||= fw_id[/\A(?:Installed|Current|Previous|Available)-(\d+)-/, 1]
89
95
  firmware_inventory << {
90
96
  name: component_data['Name'],
91
97
  id: component_data['Id'],
98
+ component_id: component_id,
92
99
  version: component_data['Version'],
93
100
  updateable: component_data['Updateable'] || false,
94
101
  status: component_data['Status'] ? component_data['Status']['State'] : 'Unknown'
@@ -168,25 +175,16 @@ module IDRAC
168
175
  next if displayed_components.include?(firmware_name.downcase)
169
176
  displayed_components.add(firmware_name.downcase)
170
177
 
171
- # Extract key identifiers from the firmware name
172
- identifiers = catalog.extract_identifiers(firmware_name)
173
-
174
- # Try to find a matching update
175
- matching_updates = catalog_updates.select do |update|
176
- update_name = update[:name] || ""
177
-
178
- # Check if any of our identifiers match the update name
179
- identifiers.any? { |id| update_name.downcase.include?(id.downcase) } ||
180
- # Or if the update name contains the firmware name
181
- update_name.downcase.include?(firmware_name.downcase) ||
182
- # Or if the firmware name contains the update name
183
- firmware_name.downcase.include?(update_name.downcase)
184
- end
185
-
178
+ # Match the installed component to catalog DUPs. Prefer the Dell
179
+ # componentID (reliable) — only fall back to the legacy name heuristic
180
+ # when the inventory doesn't expose one.
181
+ matching_updates = catalog.updates_for_component(catalog_updates, fw)
182
+
186
183
  if matching_updates.any?
187
- # Use the first matching update
188
- update = matching_updates.first
189
-
184
+ # Among matches, take the newest available version (the catalog can
185
+ # list several revisions for one component).
186
+ update = matching_updates.max_by { |u| catalog.version_key(u[:version]) }
187
+
190
188
  # Check if version is newer
191
189
  needs_update = catalog.compare_versions(fw[:version], update[:version])
192
190
 
@@ -253,12 +251,7 @@ module IDRAC
253
251
 
254
252
  # Skip if this update was already matched to a current firmware
255
253
  next if inventory[:firmware].any? do |fw|
256
- firmware_name = fw[:name] || ""
257
- identifiers = catalog.extract_identifiers(firmware_name)
258
-
259
- identifiers.any? { |id| update_name.downcase.include?(id.downcase) } ||
260
- update_name.downcase.include?(firmware_name.downcase) ||
261
- firmware_name.downcase.include?(update_name.downcase)
254
+ catalog.updates_for_component([update], fw).any?
262
255
  end
263
256
 
264
257
  puts "%-30s %-20s %-20s %-10s %-15s %s" % [
@@ -161,11 +161,20 @@ module IDRAC
161
161
  category_node = component.xpath("./Category/Display[@lang='en']").first
162
162
  category = category_node ? category_node.text.strip : ""
163
163
 
164
- version = component['dellVersion'] || component['vendorVersion'] || ""
165
-
164
+ # Prefer the numeric vendorVersion (e.g. "25.5.9.0001") over dellVersion,
165
+ # which is just the package revision label ("A17"). Comparing that label
166
+ # against an installed numeric version falsely flags every component.
167
+ version = component['vendorVersion'] || component['dellVersion'] || ""
168
+
169
+ # Dell componentIDs this DUP actually flashes. This is the reliable key
170
+ # for matching a DUP to an installed component (see #check_updates) —
171
+ # names are ambiguous (every NIC DUP says "Ethernet"), so name-matching
172
+ # picks wrong DUPs and iDRAC rejects them (RED097 / "not compatible").
173
+ component_ids = component.xpath(".//SupportedDevices/Device/@componentID").map(&:value).uniq
174
+
166
175
  # Skip if missing essential information
167
176
  next if name.empty? || path.empty? || version.empty?
168
-
177
+
169
178
  # Only include firmware updates
170
179
  if component_type.include?("Firmware") ||
171
180
  category.include?("BIOS") ||
@@ -174,13 +183,14 @@ module IDRAC
174
183
  name.include?("BIOS") ||
175
184
  name.include?("Firmware") ||
176
185
  name.include?("iDRAC")
177
-
186
+
178
187
  updates << {
179
188
  name: name,
180
189
  version: version,
181
190
  path: path,
182
191
  component_type: component_type,
183
192
  category: category,
193
+ component_ids: component_ids,
184
194
  download_url: "https://downloads.dell.com/#{path}"
185
195
  }
186
196
  end
@@ -189,7 +199,35 @@ module IDRAC
189
199
  puts "Found #{updates.size} firmware updates for system ID #{system_id}"
190
200
  updates
191
201
  end
192
-
202
+
203
+ # Select the catalog DUPs that apply to one installed component (`fw` from
204
+ # the iDRAC inventory). Matches on Dell componentID — the reliable key —
205
+ # and only falls back to the legacy name heuristic when the inventory
206
+ # didn't expose a componentID (e.g. it reports "0").
207
+ def updates_for_component(catalog_updates, fw)
208
+ component_id = fw[:component_id]
209
+ if component_id && component_id != "0"
210
+ catalog_updates.select { |u| Array(u[:component_ids]).include?(component_id) }
211
+ else
212
+ name = fw[:name] || ""
213
+ ids = extract_identifiers(name)
214
+ catalog_updates.select do |u|
215
+ un = u[:name] || ""
216
+ ids.any? { |id| un.downcase.include?(id.downcase) } ||
217
+ un.downcase.include?(name.downcase) ||
218
+ name.downcase.include?(un.downcase)
219
+ end
220
+ end
221
+ end
222
+
223
+ # Sortable key for a Dell version string (e.g. "25.5.9.0001", "22.00.6").
224
+ # Non-numeric/odd versions sort lowest rather than raising.
225
+ def version_key(version)
226
+ Gem::Version.new(version.to_s[/\d[\d.]*/] || "0")
227
+ rescue ArgumentError
228
+ Gem::Version.new("0")
229
+ end
230
+
193
231
  def extract_identifiers(name)
194
232
  return [] unless name
195
233
 
data/lib/idrac/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IDRAC
4
- VERSION = "0.10.1"
4
+ VERSION = "0.10.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idrac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-02 00:00:00.000000000 Z
11
+ date: 2026-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty