Sha256: f05bd3e1141881357cc4b4ef6dbb56047f599f2ecda824ca6ba21885f73f5877
Contents?: true
Size: 1.89 KB
Versions: 5
Compression:
Stored size: 1.89 KB
Contents
module Actions module RemoteExecution class RunHostsJob < Actions::ActionWithSubPlans middleware.use Actions::Middleware::BindJobInvocation def delay(delay_options, job_invocation) job_invocation.targeting.resolve_hosts! if job_invocation.targeting.static? action_subject(job_invocation) super(delay_options, job_invocation, true) end def plan(job_invocation, locked = false, connection_options = {}) action_subject(job_invocation) unless locked job_invocation.targeting.resolve_hosts! if job_invocation.targeting.dynamic? || !locked input.update(:job_name => job_invocation.job_name) plan_self(:job_invocation_id => job_invocation.id, :connection_options => connection_options) end def create_sub_plans job_invocation = JobInvocation.find(input[:job_invocation_id]) load_balancer = ProxyLoadBalancer.new job_invocation.targeting.hosts.map do |host| template_invocation = job_invocation.template_invocation_for_host(host) proxy = determine_proxy(template_invocation, host, load_balancer) trigger(RunHostJob, job_invocation, host, template_invocation, proxy, input[:connection_options]) end end def rescue_strategy ::Dynflow::Action::Rescue::Skip end def run(event = nil) super unless event == Dynflow::Action::Skip end private def determine_proxy(template_invocation, host, load_balancer) provider = template_invocation.template.provider_type.to_s host_proxies = host.remote_execution_proxies(provider) strategies = [:subnet, :fallback, :global] proxy = nil strategies.each do |strategy| proxy = load_balancer.next(host_proxies[strategy]) if host_proxies[strategy].present? break if proxy end proxy end end end end
Version data entries
5 entries across 5 versions & 1 rubygems