Class: Actions::RemoteExecution::RunHostsJob

Inherits:
ActionWithSubPlans
  • Object
show all
Defined in:
app/lib/actions/remote_execution/run_hosts_job.rb

Instance Method Summary collapse

Instance Method Details

#create_sub_plansObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 24

def create_sub_plans
  job_invocation = JobInvocation.find(input[:job_invocation_id])
  load_balancer = ProxyLoadBalancer.new

  # composer creates just "pattern" for template_invocations because target is evaluated
  # during actual run (here) so we build template invocations from these patterns
  job_invocation.targeting.hosts.map do |host|
    template_invocation = job_invocation.pattern_template_invocation_for_host(host).deep_clone
    template_invocation.host_id = host.id
    proxy = determine_proxy(template_invocation, host, load_balancer)
    trigger(RunHostJob, job_invocation, host, template_invocation, proxy,
            :offline_proxies => load_balancer.offline)
  end
end

#delay(delay_options, job_invocation, locked = false) ⇒ Object



8
9
10
11
12
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 8

def delay(delay_options, job_invocation, locked = false)
  task.add_missing_task_groups(job_invocation.task_group)
  job_invocation.targeting.resolve_hosts! if job_invocation.targeting.static?
  super delay_options, job_invocation, locked
end

#humanized_inputObject



52
53
54
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 52

def humanized_input
  input[:job_invocation][:description]
end

#humanized_nameObject



56
57
58
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 56

def humanized_name
  '%s:' % _(super)
end

#plan(job_invocation, locked = false) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 14

def plan(job_invocation, locked = false)
  set_up_concurrency_control 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) unless locked
  job_invocation.targeting.resolve_hosts! if job_invocation.targeting.dynamic? || !locked
  input.update(:job_category => job_invocation.job_category)
  plan_self(:job_invocation_id => job_invocation.id)
end

#rescue_strategyObject



44
45
46
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 44

def rescue_strategy
  ::Dynflow::Action::Rescue::Skip
end

#run(event = nil) ⇒ Object



48
49
50
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 48

def run(event = nil)
  super unless event == Dynflow::Action::Skip
end

#set_up_concurrency_control(invocation) ⇒ Object



39
40
41
42
# File 'app/lib/actions/remote_execution/run_hosts_job.rb', line 39

def set_up_concurrency_control(invocation)
  limit_concurrency_level invocation.concurrency_level unless invocation.concurrency_level.nil?
  distribute_over_time invocation.time_span unless invocation.time_span.nil?
end