From e9e9138c0d127bbd181a827fa2f760a793f39fd9 Mon Sep 17 00:00:00 2001 From: Yuri Rudman Date: Mon, 11 Mar 2019 12:17:23 -0400 Subject: [PATCH] pass miq_task_id and miq_callback when submitting job for generating chargeback for servcie. It will allow to initialize task's started_on column and to change task status Finished when queue item delivered. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1648499 --- app/models/service.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/models/service.rb b/app/models/service.rb index f8fb100f364c..dec9910586fd 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -418,22 +418,32 @@ def chargeback_yaml end def queue_chargeback_report_generation(options = {}) + msg = "Generating chargeback report for `#{self.class.name}` with id #{id}" task = MiqTask.create( - :name => "Generating chargeback report with id: #{id}", + :name => msg, :state => MiqTask::STATE_QUEUED, :status => MiqTask::STATUS_OK, - :message => "Queueing Chargeback of #{self.class.name} with id: #{id}" + :message => "Queueing: #{msg}" ) + cb = { + :class_name => task.class.to_s, + :instance_id => task.id, + :method_name => :queue_callback, + :args => ["Finished"] + } + MiqQueue.submit_job( :service => "reporting", :class_name => self.class.name, :instance_id => id, :task_id => task.id, + :miq_task_id => task.id, + :miq_callback => cb, :method_name => "generate_chargeback_report", :args => options ) - _log.info("Added to queue: generate_chargeback_report for service #{name}") + _log.info("Added to queue: #{msg}") task end