Sha256: 8fff9e1a27a23ed5f98fc32e8fd0d316148a7363e1fd9d879a3800b913358eb9
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
module Choria class Orchestrator class Task class Error < Orchestrator::Error; end attr_reader :name, :input, :environment, :rpc_results attr_accessor :rpc_responses def initialize(name, orchestrator:, input: {}, environment: 'production') @name = name @input = input @environment = environment @orchestrator = orchestrator validate_inputs end def metadata @metadata ||= _metadata end def files metadata['files'].to_json end def wait task_ids = rpc_responses.map { |res| res[:body][:data][:task_id] }.uniq raise NotImplementedError, "Multiple task IDs: #{task_ids}" unless task_ids.count == 1 @rpc_results = @orchestrator.wait_results task_id: task_ids.first end def results @rpc_results.map do |res| raise NotImplementedError, 'What to do when res[:data][:stderr] contains something?' unless res[:data][:stderr].empty? res[:result] = JSON.parse res[:data][:stdout] res[:data].delete :stderr res[:data].delete :stdout res end end private def _metadata # puts 'Retrieving task metadata for task %s from the Puppet Server' % task if verbose @orchestrator.tasks_support.task_metadata(@name, @environment) rescue RuntimeError => e raise Error, e.message end def validate_inputs ok, reason = @orchestrator.tasks_support.validate_task_inputs(@input, metadata) raise Error, reason.sub(/^\n/, '') unless ok end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
choria-colt-0.2.0 | lib/choria/orchestrator/task.rb |
choria-colt-0.1.1 | lib/choria/orchestrator/task.rb |
choria-colt-0.1.0 | lib/choria/orchestrator/task.rb |