bosh_cli 1.0.3 → 1.5.0.pre.1113

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.
Files changed (144) hide show
  1. data/bin/bosh +0 -9
  2. data/lib/cli.rb +69 -64
  3. data/lib/cli/backup_destination_path.rb +33 -0
  4. data/lib/cli/base_command.rb +57 -56
  5. data/lib/cli/blob_manager.rb +12 -12
  6. data/lib/cli/changeset_helper.rb +6 -7
  7. data/lib/cli/client/director.rb +724 -0
  8. data/lib/cli/command_handler.rb +6 -7
  9. data/lib/cli/commands/backup.rb +39 -0
  10. data/lib/cli/commands/biff.rb +42 -21
  11. data/lib/cli/commands/blob_management.rb +1 -1
  12. data/lib/cli/commands/cloudcheck.rb +11 -13
  13. data/lib/cli/commands/deployment.rb +53 -37
  14. data/lib/cli/commands/help.rb +3 -2
  15. data/lib/cli/commands/job_management.rb +67 -103
  16. data/lib/cli/commands/job_rename.rb +6 -8
  17. data/lib/cli/commands/log_management.rb +78 -55
  18. data/lib/cli/commands/maintenance.rb +36 -30
  19. data/lib/cli/commands/misc.rb +72 -51
  20. data/lib/cli/commands/package.rb +2 -2
  21. data/lib/cli/commands/property_management.rb +10 -12
  22. data/lib/cli/commands/release.rb +236 -133
  23. data/lib/cli/commands/snapshot.rb +93 -0
  24. data/lib/cli/commands/ssh.rb +216 -213
  25. data/lib/cli/commands/stemcell.rb +46 -34
  26. data/lib/cli/commands/task.rb +2 -2
  27. data/lib/cli/commands/user.rb +27 -3
  28. data/lib/cli/commands/vm.rb +28 -0
  29. data/lib/cli/commands/vms.rb +81 -23
  30. data/lib/cli/config.rb +6 -2
  31. data/lib/cli/core_ext.rb +31 -30
  32. data/lib/cli/deployment_helper.rb +134 -159
  33. data/lib/cli/deployment_manifest.rb +66 -0
  34. data/lib/cli/deployment_manifest_compiler.rb +0 -3
  35. data/lib/cli/event_log_renderer.rb +10 -10
  36. data/lib/cli/file_with_progress_bar.rb +52 -0
  37. data/lib/cli/job_builder.rb +1 -1
  38. data/lib/cli/job_command_args.rb +23 -0
  39. data/lib/cli/job_property_collection.rb +4 -7
  40. data/lib/cli/job_property_validator.rb +22 -12
  41. data/lib/cli/job_state.rb +54 -0
  42. data/lib/cli/line_wrap.rb +54 -0
  43. data/lib/cli/packaging_helper.rb +10 -10
  44. data/lib/cli/release.rb +18 -15
  45. data/lib/cli/release_builder.rb +9 -4
  46. data/lib/cli/release_compiler.rb +9 -9
  47. data/lib/cli/release_tarball.rb +3 -6
  48. data/lib/cli/resurrection.rb +31 -0
  49. data/lib/cli/runner.rb +56 -30
  50. data/lib/cli/stemcell.rb +25 -10
  51. data/lib/cli/task_log_renderer.rb +1 -1
  52. data/lib/cli/task_tracker.rb +10 -9
  53. data/lib/cli/validation.rb +3 -1
  54. data/lib/cli/version.rb +1 -1
  55. data/lib/cli/version_calc.rb +5 -18
  56. data/lib/cli/versions_index.rb +1 -1
  57. data/lib/cli/vm_state.rb +43 -0
  58. data/lib/cli/yaml_helper.rb +26 -35
  59. metadata +75 -208
  60. data/Rakefile +0 -56
  61. data/lib/cli/director.rb +0 -628
  62. data/spec/assets/biff/bad_gateway_config.yml +0 -28
  63. data/spec/assets/biff/good_simple_config.yml +0 -63
  64. data/spec/assets/biff/good_simple_golden_config.yml +0 -63
  65. data/spec/assets/biff/good_simple_template.erb +0 -69
  66. data/spec/assets/biff/ip_out_of_range.yml +0 -63
  67. data/spec/assets/biff/multiple_subnets_config.yml +0 -40
  68. data/spec/assets/biff/network_only_template.erb +0 -34
  69. data/spec/assets/biff/no_cc_config.yml +0 -27
  70. data/spec/assets/biff/no_range_config.yml +0 -27
  71. data/spec/assets/biff/no_subnet_config.yml +0 -16
  72. data/spec/assets/biff/ok_network_config.yml +0 -30
  73. data/spec/assets/biff/properties_template.erb +0 -6
  74. data/spec/assets/config/atmos/config/final.yml +0 -6
  75. data/spec/assets/config/atmos/config/private.yml +0 -4
  76. data/spec/assets/config/bad-providers/config/final.yml +0 -5
  77. data/spec/assets/config/bad-providers/config/private.yml +0 -4
  78. data/spec/assets/config/deprecation/config/final.yml +0 -5
  79. data/spec/assets/config/deprecation/config/private.yml +0 -2
  80. data/spec/assets/config/local/config/final.yml +0 -5
  81. data/spec/assets/config/local/config/private.yml +0 -1
  82. data/spec/assets/config/s3/config/final.yml +0 -5
  83. data/spec/assets/config/s3/config/private.yml +0 -5
  84. data/spec/assets/config/swift-hp/config/final.yml +0 -6
  85. data/spec/assets/config/swift-hp/config/private.yml +0 -7
  86. data/spec/assets/config/swift-rackspace/config/final.yml +0 -6
  87. data/spec/assets/config/swift-rackspace/config/private.yml +0 -6
  88. data/spec/assets/deployment.MF +0 -0
  89. data/spec/assets/plugins/bosh/cli/commands/echo.rb +0 -43
  90. data/spec/assets/plugins/bosh/cli/commands/ruby.rb +0 -24
  91. data/spec/assets/release/jobs/cacher.tgz +0 -0
  92. data/spec/assets/release/jobs/cacher/config/file1.conf +0 -0
  93. data/spec/assets/release/jobs/cacher/config/file2.conf +0 -0
  94. data/spec/assets/release/jobs/cacher/job.MF +0 -6
  95. data/spec/assets/release/jobs/cacher/monit +0 -1
  96. data/spec/assets/release/jobs/cleaner.tgz +0 -0
  97. data/spec/assets/release/jobs/cleaner/job.MF +0 -4
  98. data/spec/assets/release/jobs/cleaner/monit +0 -1
  99. data/spec/assets/release/jobs/sweeper.tgz +0 -0
  100. data/spec/assets/release/jobs/sweeper/config/test.conf +0 -1
  101. data/spec/assets/release/jobs/sweeper/job.MF +0 -5
  102. data/spec/assets/release/jobs/sweeper/monit +0 -1
  103. data/spec/assets/release/packages/mutator.tar.gz +0 -0
  104. data/spec/assets/release/packages/stuff.tgz +0 -0
  105. data/spec/assets/release/release.MF +0 -17
  106. data/spec/assets/release_invalid_checksum.tgz +0 -0
  107. data/spec/assets/release_invalid_jobs.tgz +0 -0
  108. data/spec/assets/release_no_name.tgz +0 -0
  109. data/spec/assets/release_no_version.tgz +0 -0
  110. data/spec/assets/stemcell/image +0 -1
  111. data/spec/assets/stemcell/stemcell.MF +0 -6
  112. data/spec/assets/stemcell_invalid_mf.tgz +0 -0
  113. data/spec/assets/stemcell_no_image.tgz +0 -0
  114. data/spec/assets/valid_release.tgz +0 -0
  115. data/spec/assets/valid_stemcell.tgz +0 -0
  116. data/spec/spec_helper.rb +0 -28
  117. data/spec/unit/base_command_spec.rb +0 -87
  118. data/spec/unit/biff_spec.rb +0 -172
  119. data/spec/unit/blob_manager_spec.rb +0 -288
  120. data/spec/unit/cache_spec.rb +0 -36
  121. data/spec/unit/cli_commands_spec.rb +0 -356
  122. data/spec/unit/config_spec.rb +0 -125
  123. data/spec/unit/core_ext_spec.rb +0 -81
  124. data/spec/unit/dependency_helper_spec.rb +0 -52
  125. data/spec/unit/deployment_manifest_compiler_spec.rb +0 -63
  126. data/spec/unit/deployment_manifest_spec.rb +0 -153
  127. data/spec/unit/director_spec.rb +0 -471
  128. data/spec/unit/director_task_spec.rb +0 -48
  129. data/spec/unit/event_log_renderer_spec.rb +0 -171
  130. data/spec/unit/hash_changeset_spec.rb +0 -73
  131. data/spec/unit/job_builder_spec.rb +0 -455
  132. data/spec/unit/job_property_collection_spec.rb +0 -111
  133. data/spec/unit/job_property_validator_spec.rb +0 -7
  134. data/spec/unit/job_rename_spec.rb +0 -200
  135. data/spec/unit/package_builder_spec.rb +0 -593
  136. data/spec/unit/release_builder_spec.rb +0 -120
  137. data/spec/unit/release_spec.rb +0 -173
  138. data/spec/unit/release_tarball_spec.rb +0 -29
  139. data/spec/unit/runner_spec.rb +0 -7
  140. data/spec/unit/ssh_spec.rb +0 -84
  141. data/spec/unit/stemcell_spec.rb +0 -17
  142. data/spec/unit/task_tracker_spec.rb +0 -131
  143. data/spec/unit/version_calc_spec.rb +0 -27
  144. data/spec/unit/versions_index_spec.rb +0 -144
@@ -7,7 +7,7 @@ module Bosh::Cli
7
7
 
8
8
  DEFAULT_RELEASE_NAME = "bosh_release"
9
9
 
10
- attr_reader :release, :packages, :jobs, :version, :build_dir
10
+ attr_reader :release, :packages, :jobs, :version, :build_dir, :commit_hash, :uncommitted_changes
11
11
 
12
12
  # @param [Bosh::Cli::Release] release Current release
13
13
  # @param [Array<Bosh::Cli::PackageBuilder>] packages Built packages
@@ -16,6 +16,8 @@ module Bosh::Cli
16
16
  def initialize(release, packages, jobs, options = { })
17
17
  @release = release
18
18
  @final = options.has_key?(:final) ? !!options[:final] : false
19
+ @commit_hash = options.fetch(:commit_hash, '00000000')
20
+ @uncommitted_changes = options.fetch(:uncommitted_changes, true)
19
21
  @packages = packages
20
22
  @jobs = jobs
21
23
 
@@ -82,7 +84,7 @@ module Bosh::Cli
82
84
  # Copies packages into release
83
85
  def copy_packages
84
86
  packages.each do |package|
85
- say("%-40s %s" % [package.name.green,
87
+ say("%-40s %s" % [package.name.make_green,
86
88
  pretty_size(package.tarball_path)])
87
89
  FileUtils.cp(package.tarball_path,
88
90
  File.join(build_dir, "packages", "#{package.name}.tgz"),
@@ -94,7 +96,7 @@ module Bosh::Cli
94
96
  # Copies jobs into release
95
97
  def copy_jobs
96
98
  jobs.each do |job|
97
- say("%-40s %s" % [job.name.green, pretty_size(job.tarball_path)])
99
+ say("%-40s %s" % [job.name.make_green, pretty_size(job.tarball_path)])
98
100
  FileUtils.cp(job.tarball_path,
99
101
  File.join(build_dir, "jobs", "#{job.name}.tgz"),
100
102
  :preserve => true)
@@ -126,6 +128,9 @@ module Bosh::Cli
126
128
  }
127
129
  end
128
130
 
131
+ manifest["commit_hash"] = commit_hash
132
+ manifest["uncommitted_changes"] = uncommitted_changes
133
+
129
134
  manifest["name"] = release_name
130
135
 
131
136
  unless manifest["name"].bosh_valid_id?
@@ -145,7 +150,7 @@ module Bosh::Cli
145
150
  end
146
151
 
147
152
  manifest["version"] = @version
148
- manifest_yaml = YAML.dump(manifest)
153
+ manifest_yaml = Psych.dump(manifest)
149
154
 
150
155
  say("Writing manifest...")
151
156
  File.open(File.join(build_dir, "release.MF"), "w") do |f|
@@ -42,7 +42,7 @@ module Bosh::Cli
42
42
 
43
43
  def compile
44
44
  if exists?
45
- quit("You already have this version in `#{tarball_path.green}'")
45
+ quit("You already have this version in `#{tarball_path.make_green}'")
46
46
  end
47
47
 
48
48
  FileUtils.cp(@manifest_file,
@@ -53,7 +53,7 @@ module Bosh::Cli
53
53
  @packages.each do |package|
54
54
  say("#{package.name} (#{package.version})".ljust(30), " ")
55
55
  if remote_package_exists?(package)
56
- say("SKIP".yellow)
56
+ say("SKIP".make_yellow)
57
57
  next
58
58
  end
59
59
  package_filename = find_package(package)
@@ -69,7 +69,7 @@ module Bosh::Cli
69
69
  @jobs.each do |job|
70
70
  say("#{job.name} (#{job.version})".ljust(30), " ")
71
71
  if remote_job_exists?(job)
72
- say("SKIP".yellow)
72
+ say("SKIP".make_yellow)
73
73
  next
74
74
  end
75
75
  job_filename = find_job(job)
@@ -87,8 +87,8 @@ module Bosh::Cli
87
87
  unless $?.exitstatus == 0
88
88
  raise InvalidRelease, "Cannot create release tarball: #{tar_out}"
89
89
  end
90
- say("Generated #{tarball_path.green}")
91
- say("Release size: #{pretty_size(tarball_path).green}")
90
+ say("Generated #{tarball_path.make_green}")
91
+ say("Release size: #{pretty_size(tarball_path).make_green}")
92
92
  end
93
93
  end
94
94
 
@@ -129,7 +129,7 @@ module Bosh::Cli
129
129
  end
130
130
 
131
131
  if build_data.nil?
132
- say("MISSING".red)
132
+ say("MISSING".make_red)
133
133
  err("Cannot find object with given checksum")
134
134
  end
135
135
 
@@ -139,13 +139,13 @@ module Bosh::Cli
139
139
  filename = index.filename(version)
140
140
 
141
141
  if File.exists?(filename)
142
- say("FOUND LOCAL".green)
142
+ say("FOUND LOCAL".make_green)
143
143
  if Digest::SHA1.file(filename) != sha1
144
144
  err("#{desc} is corrupted locally")
145
145
  end
146
146
  elsif blobstore_id
147
- say("FOUND REMOTE".yellow)
148
- say("Downloading #{blobstore_id.to_s.green}...")
147
+ say("FOUND REMOTE".make_yellow)
148
+ say("Downloading #{blobstore_id.to_s.make_green}...")
149
149
  tmp_file = Tempfile.new("")
150
150
  @blobstore.get(blobstore_id, tmp_file)
151
151
  tmp_file.close
@@ -47,25 +47,22 @@ module Bosh::Cli
47
47
  @skipped = 0
48
48
 
49
49
  Dir.chdir(@unpack_dir) do
50
- # TODO: this code can be dried up a little bit (as it is somewhat
51
- # similar to what's going on in ReleaseCompiler)
52
-
53
50
  local_packages.each do |package|
54
51
  say("#{package["name"]} (#{package["version"]})".ljust(30), " ")
55
52
  if package_matches.include?(package["sha1"]) ||
56
53
  (package["fingerprint"] &&
57
54
  package_matches.include?(package["fingerprint"]))
58
- say("SKIP".green)
55
+ say("SKIP".make_green)
59
56
  @skipped += 1
60
57
  FileUtils.rm_rf(File.join("packages", "#{package["name"]}.tgz"))
61
58
  else
62
- say("UPLOAD".red)
59
+ say("UPLOAD".make_red)
63
60
  end
64
61
  end
65
62
 
66
63
  local_jobs.each do |job|
67
64
  say("#{job["name"]} (#{job["version"]})".ljust(30), " ")
68
- say("UPLOAD".red)
65
+ say("UPLOAD".make_red)
69
66
  end
70
67
 
71
68
  return nil if @skipped == 0
@@ -0,0 +1,31 @@
1
+ module Bosh::Cli
2
+ class Resurrection
3
+ def initialize(state)
4
+ @state = state
5
+
6
+ validate_state!
7
+ end
8
+
9
+ def paused?
10
+ !enabled?
11
+ end
12
+
13
+ def enabled?
14
+ %w[true yes on enable].include?(state)
15
+ end
16
+
17
+ def disabled?
18
+ %w[false no off disable].include?(state)
19
+ end
20
+
21
+ def validate_state!
22
+ unless enabled? || disabled?
23
+ err("Resurrection paused state should be on/off, true/false, yes/no or enable/disable received #{state.inspect}")
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :state
30
+ end
31
+ end
@@ -37,15 +37,13 @@ module Bosh::Cli
37
37
 
38
38
  Config.interactive = !@options[:non_interactive]
39
39
  Config.cache = Bosh::Cli::Cache.new(@options[:cache_dir])
40
+ Config.poll_interval = @options[:poll_interval]
40
41
 
41
42
  load_plugins
42
43
  build_parse_tree
43
44
  add_shortcuts
44
45
 
45
- if @args.empty?
46
- say(usage)
47
- exit(0)
48
- end
46
+ @args = %w(help) if @args.empty?
49
47
 
50
48
  command = search_parse_tree(@parse_tree)
51
49
  if command.nil? && Config.interactive
@@ -61,19 +59,20 @@ module Bosh::Cli
61
59
  exit_code = command.run(@args, @options)
62
60
  exit(exit_code)
63
61
  rescue OptionParser::ParseError => e
64
- say(e.message.red)
65
- say("Usage: bosh #{command.usage_with_params.columnize(60, 7)}")
62
+ say_err e.message
63
+ say_err "Usage: bosh #{command.usage_with_params.columnize(60, 7)}"
66
64
  if command.has_options?
67
65
  say(command.options_summary.indent(7))
68
66
  end
69
67
  end
70
68
 
71
69
  rescue OptionParser::ParseError => e
72
- say(e.message.red)
73
- say(@option_parser.to_s)
70
+ say_err e.message
71
+ say_err @option_parser.to_s
74
72
  exit(1)
75
73
  rescue Bosh::Cli::CliError => e
76
- say(e.message.red)
74
+ say_err e.message
75
+ puts ""
77
76
  exit(e.exit_code)
78
77
  end
79
78
 
@@ -106,7 +105,11 @@ module Bosh::Cli
106
105
  end
107
106
 
108
107
  opts = @option_parser
109
- opts.on("-c", "--config FILE", "Override configuration file") do |file|
108
+ config_desc = "Override configuration file. Also can be overridden " +
109
+ "by BOSH_CONFIG environment variable. Defaults to " +
110
+ "$HOME/.bosh_config. Override precedence is command-" +
111
+ "line option, then environment variable, then home directory."
112
+ opts.on("-c", "--config FILE", config_desc) do |file|
110
113
  @options[:config] = file
111
114
  end
112
115
  opts.on("-C", "--cache-dir DIR", "Override cache directory") do |dir|
@@ -124,11 +127,13 @@ module Bosh::Cli
124
127
  end
125
128
  opts.on("-n", "--non-interactive", "Don't ask for user input") do
126
129
  @options[:non_interactive] = true
127
- Config.colorize = false
128
130
  end
129
131
  opts.on("-N", "--no-track", "Return Task ID and don't track") do
130
132
  @options[:no_track] = true
131
133
  end
134
+ opts.on("-P", "--poll INTERVAL", "Director task polling interval") do |interval|
135
+ @options[:poll_interval] = Integer(interval)
136
+ end
132
137
  opts.on("-t", "--target URL", "Override target") do |target|
133
138
  @options[:target] = target
134
139
  end
@@ -145,40 +150,54 @@ module Bosh::Cli
145
150
  @args = @option_parser.order!(@args)
146
151
  end
147
152
 
153
+ def plugins_glob; "bosh/cli/commands/*.rb"; end
154
+
148
155
  # Discover and load CLI plugins from all available gems
149
156
  # @return [void]
150
157
  def load_plugins
151
- plugins_glob = "bosh/cli/commands/*.rb"
158
+ load_local_plugins
159
+ load_gem_plugins
160
+ end
152
161
 
153
- unless Gem::Specification.respond_to?(:latest_specs) &&
154
- Gem::Specification.instance_methods.include?(:matches_for_glob)
155
- say("Cannot load plugins, ".yellow +
156
- "please run `gem update --system' to ".yellow +
157
- "update your RubyGems".yellow)
158
- return
162
+ def load_local_plugins
163
+ Dir.glob(File.join("lib", plugins_glob)).each do |file|
164
+ say("WARNING: loading local plugin: #{file}")
165
+ require_plugin(file)
159
166
  end
167
+ end
160
168
 
161
- plugins = Gem::Specification.latest_specs(true).map { |spec|
162
- spec.matches_for_glob(plugins_glob)
163
- }.flatten
169
+ def load_gem_plugins
170
+ get_gem_plugins.each do |plugin_path|
171
+ original_commands = Config.commands.size
164
172
 
165
- plugins.each do |plugin|
166
- n_commands = Config.commands.size
167
- gem_dir = Pathname.new(Gem.dir)
168
- plugin_name = Pathname.new(plugin).relative_path_from(gem_dir)
169
173
  begin
170
- require plugin
174
+ next unless require_plugin plugin_path
171
175
  rescue Exception => e
172
- say("Failed to load plugin #{plugin_name}: #{e.message}".red)
176
+ err("Failed to load plugin #{plugin_path}: #{e.message}".make_red)
173
177
  end
174
- if Config.commands.size == n_commands
175
- say(("File #{plugin_name} has been loaded as plugin but it didn't " +
178
+
179
+ if Config.commands =~ original_commands
180
+ say(("File #{plugin_path} has been loaded as plugin but it didn't " +
176
181
  "contain any commands.\nMake sure this plugin is updated to be " +
177
- "compatible with BOSH CLI 1.0.").columnize(80).yellow)
182
+ "compatible with BOSH CLI 1.0.").columnize(80).make_yellow)
178
183
  end
179
184
  end
180
185
  end
181
186
 
187
+ def get_gem_plugins
188
+ Gem::Specification.latest_specs(true).map { |spec|
189
+ spec.matches_for_glob(plugins_glob)
190
+ }.flatten.uniq
191
+ rescue
192
+ err("Cannot load plugins, ".make_yellow +
193
+ "please run `gem update --system' to ".make_yellow +
194
+ "update your RubyGems".make_yellow)
195
+ end
196
+
197
+ def require_plugin(file)
198
+ require File.absolute_path(file)
199
+ end
200
+
182
201
  def build_parse_tree
183
202
  @parse_tree = ParseTreeNode.new
184
203
 
@@ -252,5 +271,12 @@ module Bosh::Cli
252
271
 
253
272
  search_parse_tree(@parse_tree)
254
273
  end
274
+
275
+ private
276
+
277
+ def say_err(message)
278
+ $stderr << message.make_red
279
+ end
255
280
  end
281
+
256
282
  end
@@ -28,29 +28,44 @@ module Bosh::Cli
28
28
  else
29
29
  say("Manifest not found in cache, verifying tarball...")
30
30
 
31
- step("Extract tarball",
32
- "Cannot extract tarball #{@stemcell_file}", :fatal) do
33
- `tar -C #{tmp_dir} -xzf #{@stemcell_file} 2>&1`
34
- $?.exitstatus == 0
31
+ stemcell_mf = "stemcell.MF"
32
+
33
+ tar = nil
34
+ step("Read tarball",
35
+ "Cannot read tarball #{@stemcell_file}", :fatal) do
36
+ tgz = Zlib::GzipReader.new(File.open(@stemcell_file))
37
+ tar = Minitar.open(tgz)
38
+ !!tar
35
39
  end
36
40
 
37
- manifest_file = File.expand_path("stemcell.MF", tmp_dir)
41
+ manifest = false
42
+ image = false
43
+ tar.each do |entry|
44
+ if entry.full_name == stemcell_mf
45
+ tar.extract_entry(tmp_dir, entry)
46
+ manifest = true
47
+ elsif entry.full_name == "image"
48
+ image = true
49
+ end
50
+ end
38
51
 
39
52
  step("Manifest exists", "Cannot find stemcell manifest", :fatal) do
40
- File.exists?(manifest_file)
53
+ manifest
41
54
  end
42
55
 
43
56
  step("Stemcell image file",
44
57
  "Stemcell image file is missing", :fatal) do
45
- File.exists?(File.expand_path("image", tmp_dir))
58
+ image
46
59
  end
47
60
 
61
+ manifest_file = File.expand_path(stemcell_mf, tmp_dir)
62
+
48
63
  say("Writing manifest to cache...")
49
64
  manifest_yaml = File.read(manifest_file)
50
65
  @cache.write(cache_key, manifest_yaml)
51
66
  end
52
67
 
53
- manifest = YAML.load(manifest_yaml)
68
+ manifest = Psych.load(manifest_yaml)
54
69
 
55
70
  step("Stemcell properties",
56
71
  "Manifest should contain valid name, " +
@@ -75,8 +90,8 @@ module Bosh::Cli
75
90
  say("\nStemcell info")
76
91
  say("-------------")
77
92
 
78
- say("Name: %s" % [manifest["name"] || "missing".red])
79
- say("Version: %s" % [manifest["version"] || "missing".red])
93
+ say("Name: %s" % [manifest["name"] || "missing".make_red])
94
+ say("Version: %s" % [manifest["version"] || "missing".make_red])
80
95
  end
81
96
  end
82
97
  end
@@ -28,7 +28,7 @@ module Bosh::Cli
28
28
  end
29
29
 
30
30
  def duration_known?
31
- false # TODO: make it available for basic renderer
31
+ false
32
32
  end
33
33
 
34
34
  def add_output(output)
@@ -6,13 +6,13 @@ module Bosh
6
6
  class TaskTracker
7
7
 
8
8
  MAX_POLLS = nil # not limited
9
- POLL_INTERVAL = 1 # second
9
+ DEFAULT_POLL_INTERVAL = 1 # second
10
10
 
11
11
  attr_reader :output
12
12
 
13
13
  attr_reader :renderer
14
14
 
15
- # @param [Bosh::Cli::Director] director
15
+ # @param [Bosh::Cli::Client::Director] director
16
16
  # @param [Integer] task_id
17
17
  # @param [Hash] options
18
18
  def initialize(director, task_id, options = {})
@@ -37,6 +37,8 @@ module Bosh
37
37
  else
38
38
  @renderer = Bosh::Cli::TaskLogRenderer.create_for_log_type(@log_type)
39
39
  end
40
+
41
+ @poll_interval = Config.poll_interval || DEFAULT_POLL_INTERVAL
40
42
  end
41
43
 
42
44
  # Tracks director task. Blocks until task is in one of the 'finished'
@@ -46,10 +48,9 @@ module Bosh
46
48
  def track
47
49
  nl
48
50
  @renderer.time_adjustment = @director.get_time_difference
49
- say("Director task #{@task_id.to_s.yellow}")
51
+ say("Director task #{@task_id.to_s.make_yellow}")
50
52
 
51
53
  cached_output = get_cached_task_output
52
-
53
54
  if cached_output
54
55
  task_status = @task.state.to_sym
55
56
  output_received(cached_output)
@@ -81,7 +82,7 @@ module Bosh
81
82
  return :track_timeout
82
83
  end
83
84
 
84
- sleep(POLL_INTERVAL)
85
+ sleep(@poll_interval)
85
86
  end
86
87
 
87
88
  :unknown
@@ -98,8 +99,8 @@ module Bosh
98
99
  self.class.new(@director, @task_id,
99
100
  @options.merge(:log_type => "debug")).track
100
101
  else
101
- say("Please use 'bosh task #{@task_id}' command ".red +
102
- "to see the debug log".red)
102
+ say("Please use 'bosh task #{@task_id}' command ".make_red +
103
+ "to see the debug log".make_red)
103
104
  end
104
105
  end
105
106
 
@@ -125,12 +126,12 @@ module Bosh
125
126
  @renderer.finish(task_status)
126
127
 
127
128
  nl
128
- say("Task #{@task_id} #{task_status.to_s.yellow}")
129
+ say("Task #{@task_id} #{task_status.to_s.make_yellow}")
129
130
 
130
131
  if task_status == :done && @renderer.duration_known?
131
132
  say("Started\t\t#{@renderer.started_at.utc.to_s}")
132
133
  say("Finished\t#{@renderer.finished_at.utc.to_s}")
133
- say("Duration\t#{format_time(@renderer.duration).yellow}")
134
+ say("Duration\t#{format_time(@renderer.duration).make_yellow}")
134
135
  end
135
136
  end
136
137