Class: Actions::RemoteExecution::RunHostsJob
- Inherits:
-
ActionWithSubPlans
- Object
- ActionWithSubPlans
- Actions::RemoteExecution::RunHostsJob
- Includes:
- Dynflow::Action::WithBulkSubPlans, Dynflow::Action::WithPollingSubPlans
- Defined in:
- app/lib/actions/remote_execution/run_hosts_job.rb
Instance Method Summary collapse
- #batch(from, size) ⇒ Object
- #create_sub_plans ⇒ Object
- #delay(delay_options, job_invocation) ⇒ Object
- #hosts ⇒ Object
- #humanized_input ⇒ Object
- #humanized_name ⇒ Object
- #plan(job_invocation) ⇒ Object
- #rescue_strategy ⇒ Object
- #run(event = nil) ⇒ Object
- #set_up_concurrency_control(invocation) ⇒ Object
- #total_count ⇒ Object
Instance Method Details
#batch(from, size) ⇒ Object
41 42 43 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 41 def batch(from, size) hosts.offset(from).limit(size) end |
#create_sub_plans ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 28 def create_sub_plans job_invocation = JobInvocation.find(input[:job_invocation_id]) proxy_selector = RemoteExecutionProxySelector.new current_batch.map do |host| # composer creates just "pattern" for template_invocations because target is evaluated # during actual run (here) so we build template invocations from these patterns template_invocation = job_invocation.pattern_template_invocation_for_host(host).deep_clone template_invocation.host_id = host.id trigger(RunHostJob, job_invocation, host, template_invocation, proxy_selector) end end |
#delay(delay_options, job_invocation) ⇒ Object
11 12 13 14 15 16 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 11 def delay(, job_invocation) task.add_missing_task_groups(job_invocation.task_group) job_invocation.targeting.resolve_hosts! if job_invocation.targeting.static? && !job_invocation.targeting.resolved? input.update :job_invocation => job_invocation.to_action_input super , job_invocation end |
#hosts ⇒ Object
49 50 51 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 49 def hosts JobInvocation.find(input[:job_invocation_id]).targeting.hosts.order(:name, :id) end |
#humanized_input ⇒ Object
69 70 71 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 69 def humanized_input input.fetch(:job_invocation, {}).fetch(:description, '') end |
#humanized_name ⇒ Object
73 74 75 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 73 def humanized_name '%s:' % _(super) end |
#plan(job_invocation) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 18 def plan(job_invocation) job_invocation.task_group.save! if job_invocation.task_group.try(:new_record?) task.add_missing_task_groups(job_invocation.task_group) if job_invocation.task_group action_subject(job_invocation) job_invocation.targeting.resolve_hosts! if job_invocation.targeting.dynamic? || !job_invocation.targeting.resolved? set_up_concurrency_control job_invocation input.update(:job_category => job_invocation.job_category) plan_self(:job_invocation_id => job_invocation.id) end |
#rescue_strategy ⇒ Object
61 62 63 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 61 def rescue_strategy ::Dynflow::Action::Rescue::Skip end |
#run(event = nil) ⇒ Object
65 66 67 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 65 def run(event = nil) super unless event == Dynflow::Action::Skip end |
#set_up_concurrency_control(invocation) ⇒ Object
53 54 55 56 57 58 59 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 53 def set_up_concurrency_control(invocation) limit_concurrency_level invocation.concurrency_level unless invocation.concurrency_level.nil? unless invocation.time_span.nil? distribute_over_time(invocation.time_span, invocation.targeting.hosts.count) end end |
#total_count ⇒ Object
45 46 47 |
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 45 def total_count hosts.count end |