bosh_cli 1.2063.0 → 1.2068.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,5 @@ module Bosh::Cli::Client
24
24
 
25
25
  @director.upload_and_track(:post, path, exported_tar_path, {content_type: 'application/x-compressed'})
26
26
  end
27
-
28
27
  end
29
28
  end
@@ -0,0 +1,40 @@
1
+ module Bosh::Cli::Client
2
+ class ErrandsClient
3
+ class ErrandResult
4
+ attr_reader :exit_code, :stdout, :stderr
5
+
6
+ def initialize(exit_code, stdout, stderr)
7
+ @exit_code = exit_code
8
+ @stdout = stdout
9
+ @stderr = stderr
10
+ end
11
+
12
+ def ==(other)
13
+ unless other.is_a?(self.class)
14
+ raise ArgumentError, "Must be #{self.class} to compare"
15
+ end
16
+ [exit_code, stdout, stderr] == [other.exit_code, other.stdout, other.stderr]
17
+ end
18
+ end
19
+
20
+ def initialize(director)
21
+ @director = director
22
+ end
23
+
24
+ def run_errand(deployment_name, errand_name)
25
+ url = "/deployments/#{deployment_name}/errands/#{errand_name}/runs"
26
+ options = { content_type: 'application/json', payload: '{}' }
27
+
28
+ status, task_id = @director.request_and_track(:post, url, options)
29
+
30
+ if status != :done
31
+ return [status, task_id, nil]
32
+ end
33
+
34
+ task_result = JSON.parse(@director.get_task_result_log(task_id))
35
+ errand_result = ErrandResult.new(*task_result.values_at('exit_code', 'stdout', 'stderr'))
36
+
37
+ [status, task_id, errand_result]
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,41 @@
1
+ require 'cli/client/errands_client'
2
+
3
+ module Bosh::Cli::Command
4
+ class Errand < Base
5
+ usage 'run errand'
6
+ desc 'Run specified errand'
7
+ def run_errand(errand_name)
8
+ auth_required
9
+ deployment_required
10
+
11
+ deployment_name = prepare_deployment_manifest['name']
12
+
13
+ errands_client = Bosh::Cli::Client::ErrandsClient.new(director)
14
+ status, task_id, errand_result = errands_client.run_errand(deployment_name, errand_name)
15
+
16
+ unless errand_result
17
+ task_report(status, task_id, nil, "Errand `#{errand_name}' did not complete")
18
+ return
19
+ end
20
+
21
+ nl
22
+
23
+ say('[stdout]')
24
+ say(errand_result.stdout.empty?? 'None' : errand_result.stdout)
25
+ nl
26
+
27
+ say('[stderr]')
28
+ say(errand_result.stderr.empty?? 'None' : errand_result.stderr)
29
+ nl
30
+
31
+ title_prefix = "Errand `#{errand_name}' completed"
32
+ exit_code_suffix = "(exit code #{errand_result.exit_code})"
33
+
34
+ if errand_result.exit_code == 0
35
+ say("#{title_prefix} successfully #{exit_code_suffix}".make_green)
36
+ else
37
+ err("#{title_prefix} with error #{exit_code_suffix}")
38
+ end
39
+ end
40
+ end
41
+ end
@@ -4,13 +4,13 @@ module Bosh::Cli::Command
4
4
  class ImportCompiledPackages < Base
5
5
  usage 'import compiled_packages'
6
6
  desc 'Import compiled packages for a specific release and stemcell combination'
7
-
8
7
  def perform(exported_tar_path)
9
8
  auth_required
10
9
 
11
10
  unless File.exist?(exported_tar_path)
12
11
  raise Bosh::Cli::CliError, 'Archive does not exist'
13
12
  end
13
+
14
14
  client = Bosh::Cli::Client::CompiledPackagesClient.new(director)
15
15
  status, task_id = client.import(exported_tar_path)
16
16
  task_report(status, task_id)
data/lib/cli/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Cli
3
- VERSION = '1.2063.0'
3
+ VERSION = '1.2068.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2063.0
4
+ version: 1.2068.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-25 00:00:00.000000000 Z
12
+ date: 2014-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bosh_common
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.2063.0
21
+ version: 1.2068.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 1.2063.0
29
+ version: 1.2068.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: json_pure
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2063.0
117
+ version: 1.2068.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.2063.0
125
+ version: 1.2068.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: net-ssh
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -269,7 +269,7 @@ dependencies:
269
269
  version: '0'
270
270
  description: ! 'BOSH CLI
271
271
 
272
- 941741'
272
+ 5f63a5'
273
273
  email: support@cloudfoundry.com
274
274
  executables:
275
275
  - bosh
@@ -284,6 +284,7 @@ files:
284
284
  - lib/cli/changeset_helper.rb
285
285
  - lib/cli/client/compiled_packages_client.rb
286
286
  - lib/cli/client/director.rb
287
+ - lib/cli/client/errands_client.rb
287
288
  - lib/cli/command_discovery.rb
288
289
  - lib/cli/command_handler.rb
289
290
  - lib/cli/commands/backup.rb
@@ -292,6 +293,7 @@ files:
292
293
  - lib/cli/commands/cloudcheck.rb
293
294
  - lib/cli/commands/complete.rb
294
295
  - lib/cli/commands/deployment.rb
296
+ - lib/cli/commands/errand.rb
295
297
  - lib/cli/commands/export_compiled_packages.rb
296
298
  - lib/cli/commands/help.rb
297
299
  - lib/cli/commands/import_compiled_packages.rb
@@ -376,7 +378,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
376
378
  version: '0'
377
379
  segments:
378
380
  - 0
379
- hash: -4174074309811955679
381
+ hash: -2465170715055136714
380
382
  requirements: []
381
383
  rubyforge_project:
382
384
  rubygems_version: 1.8.23