Sha256: 8e84c6c3c148cd111fd7ab34f70d1c6b6ba08a5b74e001c1faaa95d7b3dfb11a

Contents?: true

Size: 1.25 KB

Versions: 34

Compression:

Stored size: 1.25 KB

Contents

module InsightsCloud
  module Generators
    class PlaybookProgressGenerator
      attr_reader :correlation_id
      def initialize(correlation_id)
        @messages = []
        @correlation_id = correlation_id
      end

      def host_progress_message(host_name, output, sequence)
        @messages << {
          "type": "playbook_run_update",
          "version": 3,
          "correlation_id": correlation_id,
          "sequence": sequence,
          "host": host_name,
          "console": output,
        }
      end

      def host_finished_message(host_name, exit_code)
        @messages << {
          "type": "playbook_run_finished",
          "version": 3,
          "correlation_id": correlation_id,
          "host": host_name,
          "status": exit_code == 0 ? 'success' : 'failure',
          "connection_code": 0,
          "execution_code": exit_code,
        }
      end

      def job_finished_message(success)
        @messages << {
          "type": "playbook_run_completed",
          "version": 3,
          "correlation_id": correlation_id,
          "status": success ? 'success' : 'failure',
        }
      end

      def generate
        @messages.map do |message|
          message.to_json
        end.join("\n")
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.59 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-9.0.58 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-9.0.57 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-10.0.1 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-9.0.56 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-9.0.55 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-9.0.54 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-9.0.53 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-9.0.52 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-8.0.52 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-9.0.51 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-8.0.51 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-7.0.48 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-7.0.47 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-8.0.50 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-8.0.49 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-8.0.48 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-8.0.47 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-8.0.46 lib/insights_cloud/generators/playbook_progress_generator.rb
foreman_rh_cloud-6.0.45 lib/insights_cloud/generators/playbook_progress_generator.rb