Skip to content

Commit

Permalink
Update the model and dialog log file timestamp to be the regular log …
Browse files Browse the repository at this point in the history
…timestamp
  • Loading branch information
d-m-u committed Jan 28, 2020
1 parent 81d7695 commit a89402b
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions app/models/miq_server/log_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def post_logs(options)
raise _("Log depot settings not configured") unless context_log_depot
context_log_depot.update(:support_case => options[:support_case].presence)

current_logfile = post_current_logs(taskid, context_log_depot)
if include_automate_models_and_dialogs?(options[:include_automate_models_and_dialogs])
post_automate_models(taskid, context_log_depot)
post_automate_dialogs(taskid, context_log_depot)
post_automate_models(taskid, context_log_depot, current_logfile)
post_automate_dialogs(taskid, context_log_depot, current_logfile)
end

post_historical_logs(taskid, context_log_depot) unless options[:only_current]
post_current_logs(taskid, context_log_depot)
task.update_status("Finished", "Ok", "Log files were successfully collected")
end

Expand Down Expand Up @@ -109,7 +109,11 @@ def post_one_log_pattern(pattern, logfile, log_type)
task = logfile.miq_task
log_prefix = "Task: [#{task.id}]"

log_start, log_end = log_start_and_end_for_pattern(pattern)
if %w[Dialogs Models].include?(log_type)
log_start, log_end = logfile.logging_started_on, logfile.logging_ended_on
else
log_start, log_end = log_start_and_end_for_pattern(pattern)
end
date_string = "#{format_log_time(log_start)} #{format_log_time(log_end)}" unless log_start.nil? && log_end.nil?

msg = "Zipping and posting #{log_type.downcase} logs for [#{who_am_i}] from: [#{log_start}] to [#{log_end}]"
Expand Down Expand Up @@ -142,12 +146,15 @@ def post_one_log_pattern(pattern, logfile, log_type)
task.update_status("Active", "Ok", msg)
end

def post_automate_models(taskid, log_depot)
def post_automate_models(taskid, log_depot, logfile)
domain_zip = Rails.root.join("log", "domain.zip")
backup_automate_models(domain_zip)

logfile = LogFile.historical_logfile
logfile.update(:file_depot => log_depot, :miq_task => MiqTask.find(taskid))
logfile.update(:file_depot => log_depot,
:miq_task => MiqTask.find(taskid),
:logging_started_on => logfile.logging_started_on,
:logging_ended_on => logfile.logging_ended_on)
post_one_log_pattern(domain_zip, logfile, "Models")
ensure
FileUtils.rm_rf(domain_zip)
Expand All @@ -159,13 +166,16 @@ def backup_automate_models(domain_zip)
end
end

def post_automate_dialogs(taskid, log_depot)
def post_automate_dialogs(taskid, log_depot, logfile)
dialog_directory = Rails.root.join("log", "service_dialogs")
FileUtils.mkdir_p(dialog_directory)
backup_automate_dialogs(dialog_directory)

logfile = LogFile.historical_logfile
logfile.update(:file_depot => log_depot, :miq_task => MiqTask.find(taskid))
logfile.update(:file_depot => log_depot,
:miq_task => MiqTask.find(taskid),
:logging_started_on => logfile.logging_started_on,
:logging_ended_on => logfile.logging_ended_on)
post_one_log_pattern(dialog_directory.join("*"), logfile, "Dialogs")
ensure
FileUtils.rm_rf(dialog_directory)
Expand Down Expand Up @@ -210,6 +220,7 @@ def post_current_logs(taskid, log_depot)
logfile = LogFile.current_logfile
logfile.update(:file_depot => log_depot, :miq_task => MiqTask.find(taskid))
post_one_log_pattern("log/*.log", logfile, "Current")
logfile
end

def delete_old_requested_logs
Expand Down

0 comments on commit a89402b

Please sign in to comment.