Skip to content

Commit

Permalink
Update the model and dialog log file timestamp to be now
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jan 29, 2020
1 parent 5a86129 commit 62cf888
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/models/miq_server/log_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ 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 @@ -145,9 +150,13 @@ def post_one_log_pattern(pattern, logfile, log_type)
def post_automate_models(taskid, log_depot)
domain_zip = Rails.root.join("log", "domain.zip")
backup_automate_models(domain_zip)
now = Time.zone.now

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 => now,
:logging_ended_on => now)
post_one_log_pattern(domain_zip, logfile, "Models")
ensure
FileUtils.rm_rf(domain_zip)
Expand All @@ -163,9 +172,13 @@ def post_automate_dialogs(taskid, log_depot)
dialog_directory = Rails.root.join("log", "service_dialogs")
FileUtils.mkdir_p(dialog_directory)
backup_automate_dialogs(dialog_directory)
now = Time.zone.now

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 => now,
:logging_ended_on => now)
post_one_log_pattern(dialog_directory.join("*"), logfile, "Dialogs")
ensure
FileUtils.rm_rf(dialog_directory)
Expand Down

0 comments on commit 62cf888

Please sign in to comment.