class Bosh::Cli::Client::ErrandsClient
Public Class Methods
new(director)
click to toggle source
# File lib/cli/client/errands_client.rb, line 26 def initialize(director) @director = director end
Public Instance Methods
run_errand(deployment_name, errand_name, keep_alive, when_changed)
click to toggle source
# File lib/cli/client/errands_client.rb, line 30 def run_errand(deployment_name, errand_name, keep_alive, when_changed) url = "/deployments/#{deployment_name}/errands/#{errand_name}/runs" payload = MultiJson.encode({'keep-alive' => (keep_alive || FALSE), 'when-changed' => (when_changed || FALSE)}) options = { content_type: 'application/json', payload: payload } status, task_id = @director.request_and_track(:post, url, options) unless [:done, :cancelled].include?(status) return [status, task_id, nil] end errand_result_output = @director.get_task_result_log(task_id) errand_result = nil if errand_result_output task_result = JSON.parse(errand_result_output) errand_result = ErrandResult.new( *task_result.values_at('exit_code', 'stdout', 'stderr'), task_result.fetch('logs', {})['blobstore_id'], ) end [status, task_id, errand_result] end