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