Class: Actions::ForemanPatch::Cycle::Create
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::ForemanPatch::Cycle::Create
- Defined in:
- app/lib/actions/foreman_patch/cycle/create.rb
Instance Method Summary collapse
- #cycle ⇒ Object
- #finalize ⇒ Object
- #humanized_name ⇒ Object
- #plan(plan) ⇒ Object
- #resource_locks ⇒ Object
- #run ⇒ Object
Instance Method Details
#cycle ⇒ Object
47 48 49 |
# File 'app/lib/actions/foreman_patch/cycle/create.rb', line 47 def cycle @cycle ||= ::ForemanPatch::Cycle.find(input[:cycle][:id]) end |
#finalize ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/lib/actions/foreman_patch/cycle/create.rb', line 39 def finalize plan = ::ForemanPatch::Plan.find(input[:plan][:id]) ::ForemanTasks.delay(Actions::ForemanPatch::Cycle::Initiate, , cycle, plan) plan.iterate end |
#humanized_name ⇒ Object
51 52 53 |
# File 'app/lib/actions/foreman_patch/cycle/create.rb', line 51 def humanized_name _('Create cycle: %s') % input[:plan][:name] end |
#plan(plan) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/lib/actions/foreman_patch/cycle/create.rb', line 10 def plan(plan) action_subject(plan) cycle = ::ForemanPatch::Cycle.create!(plan.to_params) concurrence do plan.window_plans.each do |window_plan| plan_action(Actions::ForemanPatch::Window::Create, window_plan, cycle) end end plan.start_date = plan.next_cycle_start plan.save! plan_self(cycle: cycle.to_action_input) end |
#resource_locks ⇒ Object
6 7 8 |
# File 'app/lib/actions/foreman_patch/cycle/create.rb', line 6 def resource_locks :link end |
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/lib/actions/foreman_patch/cycle/create.rb', line 27 def run output.update(cycle: cycle.to_action_input) users = ::User.select { |user| user.receives?(:patch_cycle_planned) }.compact begin MailNotification[:patch_cycle_planned].deliver(users: users, cycle: cycle) unless users.blank? rescue => error Rails.logger.error(error) end end |