module IDRAC::Utility
def generate_tsr_logs(data_selector_values: nil, share_type: nil, share_parameters: nil)
-
(Hash)
- Result hash with status and job/task information
Parameters:
-
data_selector_values
(Array
) -- Array of log types to include (optional)
def generate_tsr_logs(data_selector_values: nil, share_type: nil, share_parameters: nil) debug "Generating TSR/SupportAssist logs...", 1 # Check EULA status first eula_status = supportassist_eula_status if eula_status["EULAAccepted"] == false || eula_status["EULAAccepted"] == "false" puts "\n" + "="*80 puts "ERROR: SupportAssist EULA Not Accepted".red.bold puts "="*80 puts "" puts "The SupportAssist End User License Agreement (EULA) must be accepted".yellow puts "before you can generate TSR/SupportAssist collections.".yellow puts "" puts "To accept the EULA, run:".cyan puts " idrac tsr_accept_eula --host #{@host} --port #{@port}".green.bold puts "" puts "="*80 return { status: :failed, error: "SupportAssist EULA not accepted" } end # Default data selector values for comprehensive TSR # Valid values for SupportAssistCollection: "DebugLogs", "GPULogs", "HWData", "OSAppData", "TTYLogs", "TelemetryReports" data_selector_values ||= ["HWData", "OSAppData"] # Map numeric values to iDRAC expected strings if needed if data_selector_values.is_a?(Array) && data_selector_values.first.to_s =~ /^\d+$/ data_selector_values = data_selector_values.map do |val| case val.to_s when "0" then "HWData" when "1" then "OSAppData" when "2" then "TTYLogs" when "3" then "DebugLogs" else "HWData" # Default to HWData end end elsif data_selector_values.is_a?(String) data_selector_values = data_selector_values.split(',') end debug "Data selector values: #{data_selector_values.inspect}", 1 # Use SupportAssistCollection for local generation as it supports "Local" ShareType payload = { "ShareType" => "Local", "DataSelectorArrayIn" => data_selector_values, "Filter" => "No", # Don't filter PII "Transmit" => "No" # Don't transmit to Dell } debug "SupportAssist collection payload: #{payload.to_json}", 1 response = authenticated_request( :post, "/redfish/v1/Dell/Managers/iDRAC.Embedded.1/DellLCService/Actions/DellLCService.SupportAssistCollection", body: payload.to_json, headers: { 'Content-Type' => 'application/json' } ) case response.status when 202 # Accepted - job created location = response.headers["location"] if location debug "TSR generation job created: #{location}", 1, :green job_id = location.split("/").last # Wait for job to complete and capture the file location job_result = wait_for_job_with_location(job_id) if job_result && (job_result["JobState"] == "Completed" || job_result["JobState"] == "CompletedWithErrors") result = { status: :success, job: job_result } # Check if we got a file location from the job completion result[:location] = job_result["FileLocation"] if job_result["FileLocation"] result else { status: :failed, error: "Job did not complete successfully" } end else { status: :accepted, message: "TSR generation initiated" } end when 200..299 debug "TSR generation completed immediately", 1, :green { status: :success } else error_msg = parse_error_response(response) debug "Failed to generate TSR: #{error_msg}", 1, :red { status: :failed, error: error_msg } end rescue => e debug "Error generating TSR: #{e.message}", 1, :red { status: :error, error: e.message } end