Class: Bosh::Cli::Client::ErrandsClient
- Defined in:
- lib/cli/client/errands_client.rb
Defined Under Namespace
Classes: ErrandResult
Instance Method Summary collapse
-
#initialize(director) ⇒ ErrandsClient
constructor
A new instance of ErrandsClient.
- #run_errand(deployment_name, errand_name) ⇒ Object
Constructor Details
#initialize(director) ⇒ ErrandsClient
Returns a new instance of ErrandsClient.
24 25 26 |
# File 'lib/cli/client/errands_client.rb', line 24 def initialize(director) @director = director end |
Instance Method Details
#run_errand(deployment_name, errand_name) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cli/client/errands_client.rb', line 28 def run_errand(deployment_name, errand_name) url = "/deployments/#{deployment_name}/errands/#{errand_name}/runs" = { content_type: 'application/json', payload: '{}' } status, task_id = @director.request_and_track(:post, url, ) 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 |