module IDRAC::Storage

def drives(controller_id) # expects @odata.id as string

expects @odata.id as string
Get information about physical drives
def drives(controller_id) # expects @odata.id as string
  raise Error, "Controller ID not provided" unless controller_id
  raise Error, "Expected controller ID string, got #{controller_id.class}" unless controller_id.is_a?(String)
  
  controller_path = controller_id.split("v1/").last
  response = authenticated_request(:get, "/redfish/v1/#{controller_path}?$expand=*($levels=1)")
  
  if response.status == 200
    begin
      data = JSON.parse(response.body)
      
      # Debug dump of drive data - this happens with -vv or -vvv
      dump_drive_data(data["Drives"])
      
      drives = data["Drives"].map do |body|
        serial = body["SerialNumber"] 
        serial = body["Identifiers"].first["DurableName"] if serial.blank?
        {
          "serial" => serial,
          "model" => body["Model"],
          "name" => body["Name"],
          "capacity_bytes" => body["CapacityBytes"],
          "health" => body.dig("Status", "Health") || "N/A",
          "speed_gbp" => body["CapableSpeedGbs"],
          "manufacturer" => body["Manufacturer"],
          "media_type" => body["MediaType"],
          "failure_predicted" => body["FailurePredicted"],
          "life_left_percent" => body["PredictedMediaLifeLeftPercent"],
          "certified" => body.dig("Oem", "Dell", "DellPhysicalDisk", "Certified"),
          "raid_status" => body.dig("Oem", "Dell", "DellPhysicalDisk", "RaidStatus"),
          "operation_name" => body.dig("Oem", "Dell", "DellPhysicalDisk", "OperationName"),
          "operation_progress" => body.dig("Oem", "Dell", "DellPhysicalDisk", "OperationPercentCompletePercent"),
          "encryption_ability" => body["EncryptionAbility"],
          "@odata.id" => body["@odata.id"]
        }
      end
      
      return drives.sort_by { |d| d["name"] }
    rescue JSON::ParserError
      raise Error, "Failed to parse drives response: #{response.body}"
    end
  else
    raise Error, "Failed to get drives. Status code: #{response.status}"
  end
end