Class: InsightsCloud::Generators::PlaybookProgressGenerator
- Inherits:
-
Object
- Object
- InsightsCloud::Generators::PlaybookProgressGenerator
- Defined in:
- lib/insights_cloud/generators/playbook_progress_generator.rb
Instance Attribute Summary collapse
-
#correlation_id ⇒ Object
readonly
Returns the value of attribute correlation_id.
Instance Method Summary collapse
- #generate ⇒ Object
- #host_finished_message(host_name, exit_code) ⇒ Object
- #host_progress_message(host_name, output, sequence) ⇒ Object
-
#initialize(correlation_id) ⇒ PlaybookProgressGenerator
constructor
A new instance of PlaybookProgressGenerator.
- #job_finished_message(success) ⇒ Object
Constructor Details
#initialize(correlation_id) ⇒ PlaybookProgressGenerator
Returns a new instance of PlaybookProgressGenerator.
6 7 8 9 |
# File 'lib/insights_cloud/generators/playbook_progress_generator.rb', line 6 def initialize(correlation_id) @messages = [] @correlation_id = correlation_id end |
Instance Attribute Details
#correlation_id ⇒ Object (readonly)
Returns the value of attribute correlation_id.
4 5 6 |
# File 'lib/insights_cloud/generators/playbook_progress_generator.rb', line 4 def correlation_id @correlation_id end |
Instance Method Details
#generate ⇒ Object
43 44 45 46 47 |
# File 'lib/insights_cloud/generators/playbook_progress_generator.rb', line 43 def generate @messages.map do || .to_json end.join("\n") end |
#host_finished_message(host_name, exit_code) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/insights_cloud/generators/playbook_progress_generator.rb', line 22 def (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 |
#host_progress_message(host_name, output, sequence) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/insights_cloud/generators/playbook_progress_generator.rb', line 11 def (host_name, output, sequence) @messages << { "type": "playbook_run_update", "version": 3, "correlation_id": correlation_id, "sequence": sequence, "host": host_name, "console": output, } end |
#job_finished_message(success) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/insights_cloud/generators/playbook_progress_generator.rb', line 34 def (success) @messages << { "type": "playbook_run_completed", "version": 3, "correlation_id": correlation_id, "status": success ? 'success' : 'failure', } end |