Sha256: 5d4d6b9577588481750a909fc048f9d7a336f4084c6c14e1dde4142296e60e83

Contents?: true

Size: 1000 Bytes

Versions: 6

Compression:

Stored size: 1000 Bytes

Contents

module Actions
  module RemoteExecution
    class RunHostsJob < Actions::ActionWithSubPlans
      def plan(job_invocation)
        action_subject(job_invocation)

        job_invocation.targeting.resolve_hosts!
        job_invocation.update_attribute :last_task_id, task.id
        input.update(:job_name => job_invocation.job_name)
        plan_self(job_invocation_id: job_invocation.id)
      end

      def create_sub_plans
        job_invocation = JobInvocation.find(input[:job_invocation_id])
        job_invocation.targeting.hosts.map do |host|
          trigger(RunHostJob, job_invocation, host)
        end
      end

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

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

      def output
        result = super
        result[:pending_count] = (result[:total_count] || 0) - (result[:failed_count] || 0) - (result[:success_count] || 0)
        result
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_remote_execution-0.0.6 app/lib/actions/remote_execution/run_hosts_job.rb
foreman_remote_execution-0.0.5 app/lib/actions/remote_execution/run_hosts_job.rb
foreman_remote_execution-0.0.4 app/lib/actions/remote_execution/run_hosts_job.rb
foreman_remote_execution-0.0.3 app/lib/actions/remote_execution/run_hosts_job.rb
foreman_remote_execution-0.0.2 app/lib/actions/remote_execution/run_hosts_job.rb
foreman_remote_execution-0.0.1 app/lib/actions/remote_execution/run_hosts_job.rb