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.
- data/bin/bosh +0 -9
- data/lib/cli.rb +69 -64
- data/lib/cli/backup_destination_path.rb +33 -0
- data/lib/cli/base_command.rb +57 -56
- data/lib/cli/blob_manager.rb +12 -12
- data/lib/cli/changeset_helper.rb +6 -7
- data/lib/cli/client/director.rb +724 -0
- data/lib/cli/command_handler.rb +6 -7
- data/lib/cli/commands/backup.rb +39 -0
- data/lib/cli/commands/biff.rb +42 -21
- data/lib/cli/commands/blob_management.rb +1 -1
- data/lib/cli/commands/cloudcheck.rb +11 -13
- data/lib/cli/commands/deployment.rb +53 -37
- data/lib/cli/commands/help.rb +3 -2
- data/lib/cli/commands/job_management.rb +67 -103
- data/lib/cli/commands/job_rename.rb +6 -8
- data/lib/cli/commands/log_management.rb +78 -55
- data/lib/cli/commands/maintenance.rb +36 -30
- data/lib/cli/commands/misc.rb +72 -51
- data/lib/cli/commands/package.rb +2 -2
- data/lib/cli/commands/property_management.rb +10 -12
- data/lib/cli/commands/release.rb +236 -133
- data/lib/cli/commands/snapshot.rb +93 -0
- data/lib/cli/commands/ssh.rb +216 -213
- data/lib/cli/commands/stemcell.rb +46 -34
- data/lib/cli/commands/task.rb +2 -2
- data/lib/cli/commands/user.rb +27 -3
- data/lib/cli/commands/vm.rb +28 -0
- data/lib/cli/commands/vms.rb +81 -23
- data/lib/cli/config.rb +6 -2
- data/lib/cli/core_ext.rb +31 -30
- data/lib/cli/deployment_helper.rb +134 -159
- data/lib/cli/deployment_manifest.rb +66 -0
- data/lib/cli/deployment_manifest_compiler.rb +0 -3
- data/lib/cli/event_log_renderer.rb +10 -10
- data/lib/cli/file_with_progress_bar.rb +52 -0
- data/lib/cli/job_builder.rb +1 -1
- data/lib/cli/job_command_args.rb +23 -0
- data/lib/cli/job_property_collection.rb +4 -7
- data/lib/cli/job_property_validator.rb +22 -12
- data/lib/cli/job_state.rb +54 -0
- data/lib/cli/line_wrap.rb +54 -0
- data/lib/cli/packaging_helper.rb +10 -10
- data/lib/cli/release.rb +18 -15
- data/lib/cli/release_builder.rb +9 -4
- data/lib/cli/release_compiler.rb +9 -9
- data/lib/cli/release_tarball.rb +3 -6
- data/lib/cli/resurrection.rb +31 -0
- data/lib/cli/runner.rb +56 -30
- data/lib/cli/stemcell.rb +25 -10
- data/lib/cli/task_log_renderer.rb +1 -1
- data/lib/cli/task_tracker.rb +10 -9
- data/lib/cli/validation.rb +3 -1
- data/lib/cli/version.rb +1 -1
- data/lib/cli/version_calc.rb +5 -18
- data/lib/cli/versions_index.rb +1 -1
- data/lib/cli/vm_state.rb +43 -0
- data/lib/cli/yaml_helper.rb +26 -35
- metadata +75 -208
- data/Rakefile +0 -56
- data/lib/cli/director.rb +0 -628
- data/spec/assets/biff/bad_gateway_config.yml +0 -28
- data/spec/assets/biff/good_simple_config.yml +0 -63
- data/spec/assets/biff/good_simple_golden_config.yml +0 -63
- data/spec/assets/biff/good_simple_template.erb +0 -69
- data/spec/assets/biff/ip_out_of_range.yml +0 -63
- data/spec/assets/biff/multiple_subnets_config.yml +0 -40
- data/spec/assets/biff/network_only_template.erb +0 -34
- data/spec/assets/biff/no_cc_config.yml +0 -27
- data/spec/assets/biff/no_range_config.yml +0 -27
- data/spec/assets/biff/no_subnet_config.yml +0 -16
- data/spec/assets/biff/ok_network_config.yml +0 -30
- data/spec/assets/biff/properties_template.erb +0 -6
- data/spec/assets/config/atmos/config/final.yml +0 -6
- data/spec/assets/config/atmos/config/private.yml +0 -4
- data/spec/assets/config/bad-providers/config/final.yml +0 -5
- data/spec/assets/config/bad-providers/config/private.yml +0 -4
- data/spec/assets/config/deprecation/config/final.yml +0 -5
- data/spec/assets/config/deprecation/config/private.yml +0 -2
- data/spec/assets/config/local/config/final.yml +0 -5
- data/spec/assets/config/local/config/private.yml +0 -1
- data/spec/assets/config/s3/config/final.yml +0 -5
- data/spec/assets/config/s3/config/private.yml +0 -5
- data/spec/assets/config/swift-hp/config/final.yml +0 -6
- data/spec/assets/config/swift-hp/config/private.yml +0 -7
- data/spec/assets/config/swift-rackspace/config/final.yml +0 -6
- data/spec/assets/config/swift-rackspace/config/private.yml +0 -6
- data/spec/assets/deployment.MF +0 -0
- data/spec/assets/plugins/bosh/cli/commands/echo.rb +0 -43
- data/spec/assets/plugins/bosh/cli/commands/ruby.rb +0 -24
- data/spec/assets/release/jobs/cacher.tgz +0 -0
- data/spec/assets/release/jobs/cacher/config/file1.conf +0 -0
- data/spec/assets/release/jobs/cacher/config/file2.conf +0 -0
- data/spec/assets/release/jobs/cacher/job.MF +0 -6
- data/spec/assets/release/jobs/cacher/monit +0 -1
- data/spec/assets/release/jobs/cleaner.tgz +0 -0
- data/spec/assets/release/jobs/cleaner/job.MF +0 -4
- data/spec/assets/release/jobs/cleaner/monit +0 -1
- data/spec/assets/release/jobs/sweeper.tgz +0 -0
- data/spec/assets/release/jobs/sweeper/config/test.conf +0 -1
- data/spec/assets/release/jobs/sweeper/job.MF +0 -5
- data/spec/assets/release/jobs/sweeper/monit +0 -1
- data/spec/assets/release/packages/mutator.tar.gz +0 -0
- data/spec/assets/release/packages/stuff.tgz +0 -0
- data/spec/assets/release/release.MF +0 -17
- data/spec/assets/release_invalid_checksum.tgz +0 -0
- data/spec/assets/release_invalid_jobs.tgz +0 -0
- data/spec/assets/release_no_name.tgz +0 -0
- data/spec/assets/release_no_version.tgz +0 -0
- data/spec/assets/stemcell/image +0 -1
- data/spec/assets/stemcell/stemcell.MF +0 -6
- data/spec/assets/stemcell_invalid_mf.tgz +0 -0
- data/spec/assets/stemcell_no_image.tgz +0 -0
- data/spec/assets/valid_release.tgz +0 -0
- data/spec/assets/valid_stemcell.tgz +0 -0
- data/spec/spec_helper.rb +0 -28
- data/spec/unit/base_command_spec.rb +0 -87
- data/spec/unit/biff_spec.rb +0 -172
- data/spec/unit/blob_manager_spec.rb +0 -288
- data/spec/unit/cache_spec.rb +0 -36
- data/spec/unit/cli_commands_spec.rb +0 -356
- data/spec/unit/config_spec.rb +0 -125
- data/spec/unit/core_ext_spec.rb +0 -81
- data/spec/unit/dependency_helper_spec.rb +0 -52
- data/spec/unit/deployment_manifest_compiler_spec.rb +0 -63
- data/spec/unit/deployment_manifest_spec.rb +0 -153
- data/spec/unit/director_spec.rb +0 -471
- data/spec/unit/director_task_spec.rb +0 -48
- data/spec/unit/event_log_renderer_spec.rb +0 -171
- data/spec/unit/hash_changeset_spec.rb +0 -73
- data/spec/unit/job_builder_spec.rb +0 -455
- data/spec/unit/job_property_collection_spec.rb +0 -111
- data/spec/unit/job_property_validator_spec.rb +0 -7
- data/spec/unit/job_rename_spec.rb +0 -200
- data/spec/unit/package_builder_spec.rb +0 -593
- data/spec/unit/release_builder_spec.rb +0 -120
- data/spec/unit/release_spec.rb +0 -173
- data/spec/unit/release_tarball_spec.rb +0 -29
- data/spec/unit/runner_spec.rb +0 -7
- data/spec/unit/ssh_spec.rb +0 -84
- data/spec/unit/stemcell_spec.rb +0 -17
- data/spec/unit/task_tracker_spec.rb +0 -131
- data/spec/unit/version_calc_spec.rb +0 -27
- data/spec/unit/versions_index_spec.rb +0 -144
data/lib/cli/release_builder.rb
CHANGED
|
@@ -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.
|
|
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.
|
|
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 =
|
|
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|
|
data/lib/cli/release_compiler.rb
CHANGED
|
@@ -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.
|
|
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".
|
|
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".
|
|
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.
|
|
91
|
-
say("Release size: #{pretty_size(tarball_path).
|
|
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".
|
|
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".
|
|
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".
|
|
148
|
-
say("Downloading #{blobstore_id.to_s.
|
|
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
|
data/lib/cli/release_tarball.rb
CHANGED
|
@@ -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".
|
|
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".
|
|
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".
|
|
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
|
data/lib/cli/runner.rb
CHANGED
|
@@ -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
|
-
|
|
65
|
-
|
|
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
|
-
|
|
73
|
-
|
|
70
|
+
say_err e.message
|
|
71
|
+
say_err @option_parser.to_s
|
|
74
72
|
exit(1)
|
|
75
73
|
rescue Bosh::Cli::CliError => e
|
|
76
|
-
|
|
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
|
-
|
|
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
|
-
|
|
158
|
+
load_local_plugins
|
|
159
|
+
load_gem_plugins
|
|
160
|
+
end
|
|
152
161
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
say("
|
|
156
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
174
|
+
next unless require_plugin plugin_path
|
|
171
175
|
rescue Exception => e
|
|
172
|
-
|
|
176
|
+
err("Failed to load plugin #{plugin_path}: #{e.message}".make_red)
|
|
173
177
|
end
|
|
174
|
-
|
|
175
|
-
|
|
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).
|
|
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
|
data/lib/cli/stemcell.rb
CHANGED
|
@@ -28,29 +28,44 @@ module Bosh::Cli
|
|
|
28
28
|
else
|
|
29
29
|
say("Manifest not found in cache, verifying tarball...")
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
53
|
+
manifest
|
|
41
54
|
end
|
|
42
55
|
|
|
43
56
|
step("Stemcell image file",
|
|
44
57
|
"Stemcell image file is missing", :fatal) do
|
|
45
|
-
|
|
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 =
|
|
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".
|
|
79
|
-
say("Version: %s" % [manifest["version"] || "missing".
|
|
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
|
data/lib/cli/task_tracker.rb
CHANGED
|
@@ -6,13 +6,13 @@ module Bosh
|
|
|
6
6
|
class TaskTracker
|
|
7
7
|
|
|
8
8
|
MAX_POLLS = nil # not limited
|
|
9
|
-
|
|
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.
|
|
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(
|
|
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 ".
|
|
102
|
-
"to see the debug log".
|
|
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.
|
|
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).
|
|
134
|
+
say("Duration\t#{format_time(@renderer.duration).make_yellow}")
|
|
134
135
|
end
|
|
135
136
|
end
|
|
136
137
|
|