Skip to content

Commit

Permalink
Merge pull request #17672 from bdunne/service_template_miq_schedules_…
Browse files Browse the repository at this point in the history
…relation

Add ServiceTemplate#miq_schedules relation
  • Loading branch information
gtanzillo authored Jul 9, 2018
2 parents a572b1a + d2a2db1 commit 7f1f7d4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/service_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ def queue_order(user_id, options, request_options)
)
end

def miq_schedules
schedule_ids = Reserve.where(:resource_type => "MiqSchedule").collect { |r| r.resource_id if r.reserved == {:resource_id => id} }.compact
MiqSchedule.where(:towhat => "ServiceTemplate", :id => schedule_ids)
end

def order(user_or_id, options = nil, request_options = nil, schedule_time = nil)
user = user_or_id.kind_of?(User) ? user_or_id : User.find(user_or_id)
workflow = provision_workflow(user, options, request_options)
Expand Down

0 comments on commit 7f1f7d4

Please sign in to comment.