class IDRAC::FirmwareCatalog

def find_updates_for_system(system_id)

def find_updates_for_system(system_id)
  doc = parse
  updates = []
  
  # Find all SoftwareComponents
  doc.xpath("//SoftwareComponent").each do |component|
    # Check if this component supports our system ID
    supported_system_ids = component.xpath(".//SupportedSystems/Brand/Model/@systemID | .//SupportedSystems/Brand/Model/@id").map(&:value)
    
    next unless supported_system_ids.include?(system_id)
    
    # Get component details
    name_node = component.xpath("./Name/Display[@lang='en']").first
    name = name_node ? name_node.text.strip : ""
    
    component_type_node = component.xpath("./ComponentType/Display[@lang='en']").first
    component_type = component_type_node ? component_type_node.text.strip : ""
    
    path = component['path'] || ""
    category_node = component.xpath("./Category/Display[@lang='en']").first
    category = category_node ? category_node.text.strip : ""
    
    version = component['dellVersion'] || component['vendorVersion'] || ""
    
    # Skip if missing essential information
    next if name.empty? || path.empty? || version.empty?
    
    # Only include firmware updates
    if component_type.include?("Firmware") ||
       category.include?("BIOS") ||
       category.include?("Firmware") ||
       category.include?("iDRAC") ||
       name.include?("BIOS") ||
       name.include?("Firmware") ||
       name.include?("iDRAC")
      
      updates << {
        name: name,
        version: version,
        path: path,
        component_type: component_type,
        category: category,
        download_url: "https://downloads.dell.com/#{path}"
      }
    end
  end
  
  puts "Found #{updates.size} firmware updates for system ID #{system_id}"
  updates
end