Skip to content

Commit

Permalink
pass miq_task_id and miq_callback when submitting job for generating …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
yrudman committed Mar 11, 2019
1 parent 5307629 commit e9e9138
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e9e9138

Please sign in to comment.