Skip to content

Commit

Permalink
Merge pull request #17135 from jntullo/return_task
Browse files Browse the repository at this point in the history
Return a task when queueing chargeback report generation for services
  • Loading branch information
gtanzillo authored Mar 12, 2018
2 parents 22652d9 + 5c698e2 commit eb5ae24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,23 @@ def chargeback_yaml
end

def queue_chargeback_report_generation(options = {})
task = MiqTask.create(
:name => "Generating chargeback report with id: #{id}",
:state => MiqTask::STATE_QUEUED,
:status => MiqTask::STATUS_OK,
:message => "Queueing Chargeback of #{self.class.name} with id: #{id}"
)

MiqQueue.submit_job(
:service => "reporting",
:class_name => self.class.name,
:instance_id => id,
:task_id => task.id,
:method_name => "generate_chargeback_report",
:args => options
)
_log.info("Added to queue: generate_chargeback_report for service #{name}")
task
end

#
Expand Down
2 changes: 1 addition & 1 deletion spec/models/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
:method_name => "generate_chargeback_report",
:args => {:report_source => "Test Run"})
end
@service.queue_chargeback_report_generation(:report_source => "Test Run")
expect(@service.queue_chargeback_report_generation(:report_source => "Test Run")).to be_kind_of(MiqTask)
end
end

Expand Down

0 comments on commit eb5ae24

Please sign in to comment.