bosh_cli 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cli.rb +0 -3
- data/lib/cli/base_command.rb +14 -3
- data/lib/cli/commands/cloudcheck.rb +5 -4
- data/lib/cli/commands/deployment.rb +17 -6
- data/lib/cli/commands/help.rb +6 -2
- data/lib/cli/commands/job_management.rb +2 -2
- data/lib/cli/commands/job_rename.rb +2 -2
- data/lib/cli/commands/log_management.rb +1 -0
- data/lib/cli/commands/misc.rb +26 -0
- data/lib/cli/commands/release.rb +6 -6
- data/lib/cli/commands/ssh.rb +3 -0
- data/lib/cli/commands/stemcell.rb +6 -4
- data/lib/cli/commands/vms.rb +1 -0
- data/lib/cli/core_ext.rb +1 -1
- data/lib/cli/release_compiler.rb +5 -4
- data/lib/cli/runner.rb +9 -8
- data/lib/cli/task_tracker.rb +5 -1
- data/lib/cli/version.rb +1 -1
- data/spec/unit/job_property_validator_spec.rb +1 -1
- data/spec/unit/task_tracker_spec.rb +4 -0
- metadata +4 -4
data/lib/cli.rb
CHANGED
data/lib/cli/base_command.rb
CHANGED
@@ -48,7 +48,8 @@ module Bosh::Cli
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def director
|
51
|
-
@director ||= Bosh::Cli::Director.new(
|
51
|
+
@director ||= Bosh::Cli::Director.new(
|
52
|
+
target, username, password, @options.select {|k,v| k == :no_track})
|
52
53
|
end
|
53
54
|
|
54
55
|
def release
|
@@ -132,12 +133,15 @@ module Bosh::Cli
|
|
132
133
|
# contains pretty detailed error report and other UI niceties, so most
|
133
134
|
# of the time this could just do nothing
|
134
135
|
# @param [Symbol] status Task status
|
135
|
-
|
136
|
+
# @param [#to_s] task_id Task ID
|
137
|
+
def task_report(status, task_id, success_msg = nil, error_msg = nil)
|
136
138
|
case status
|
137
139
|
when :non_trackable
|
138
140
|
report = "Can't track director task".red
|
139
141
|
when :track_timeout
|
140
142
|
report = "Task tracking timeout".red
|
143
|
+
when :running
|
144
|
+
report = "Director task #{task_id.yellow} is running"
|
141
145
|
when :error
|
142
146
|
report = error_msg
|
143
147
|
when :done
|
@@ -168,6 +172,12 @@ module Bosh::Cli
|
|
168
172
|
err("Please choose deployment first") if deployment.nil?
|
169
173
|
end
|
170
174
|
|
175
|
+
def no_track_unsupported
|
176
|
+
if @options.delete(:no_track)
|
177
|
+
say("Ignoring `" + "--no-track".yellow + "' option")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
171
181
|
def check_if_release_dir
|
172
182
|
unless in_release_dir?
|
173
183
|
err("Sorry, your current directory doesn't look " +
|
@@ -179,7 +189,8 @@ module Bosh::Cli
|
|
179
189
|
if dirty_state?
|
180
190
|
say("\n%s\n" % [`git status`])
|
181
191
|
err("Your current directory has some local modifications, " +
|
182
|
-
"please discard or commit them first"
|
192
|
+
"please discard or commit them first.\n\n" +
|
193
|
+
"Use the --force option to skip this check.")
|
183
194
|
end
|
184
195
|
end
|
185
196
|
|
@@ -15,6 +15,7 @@ module Bosh::Cli::Command
|
|
15
15
|
"don't attempt to resolve problems"
|
16
16
|
def perform(deployment_name = nil)
|
17
17
|
auth_required
|
18
|
+
no_track_unsupported
|
18
19
|
@auto_mode = options[:auto]
|
19
20
|
@report_mode = options[:report]
|
20
21
|
|
@@ -30,10 +31,10 @@ module Bosh::Cli::Command
|
|
30
31
|
say("Performing cloud check...")
|
31
32
|
deployment_name ||= prepare_deployment_manifest["name"]
|
32
33
|
|
33
|
-
status,
|
34
|
+
status, task_id = director.perform_cloud_scan(deployment_name)
|
34
35
|
|
35
36
|
if status != :done
|
36
|
-
task_report(status)
|
37
|
+
task_report(status, task_id)
|
37
38
|
exit(1)
|
38
39
|
end
|
39
40
|
|
@@ -75,10 +76,10 @@ module Bosh::Cli::Command
|
|
75
76
|
hash
|
76
77
|
end
|
77
78
|
|
78
|
-
status,
|
79
|
+
status, task_id = director.apply_resolutions(deployment_name, action_map)
|
79
80
|
|
80
81
|
if status != :done
|
81
|
-
task_report(status)
|
82
|
+
task_report(status, task_id)
|
82
83
|
exit(1)
|
83
84
|
end
|
84
85
|
|
@@ -101,9 +101,9 @@ module Bosh::Cli::Command
|
|
101
101
|
cancel_deployment
|
102
102
|
end
|
103
103
|
|
104
|
-
status,
|
104
|
+
status, task_id = director.deploy(manifest_yaml, :recreate => recreate)
|
105
105
|
|
106
|
-
task_report(status, "Deployed #{desc}")
|
106
|
+
task_report(status, task_id, "Deployed #{desc}")
|
107
107
|
end
|
108
108
|
|
109
109
|
# bosh delete deployment
|
@@ -123,9 +123,9 @@ module Bosh::Cli::Command
|
|
123
123
|
return
|
124
124
|
end
|
125
125
|
|
126
|
-
status,
|
126
|
+
status, task_id = director.delete_deployment(name, :force => force)
|
127
127
|
|
128
|
-
task_report(status, "Deleted deployment `#{name}'")
|
128
|
+
task_report(status, task_id, "Deleted deployment `#{name}'")
|
129
129
|
end
|
130
130
|
|
131
131
|
# bosh validate jobs
|
@@ -136,8 +136,19 @@ module Bosh::Cli::Command
|
|
136
136
|
check_if_release_dir
|
137
137
|
manifest = prepare_deployment_manifest(:resolve_properties => true)
|
138
138
|
|
139
|
-
|
140
|
-
|
139
|
+
if manifest["release"]
|
140
|
+
release_name = manifest["release"]["name"]
|
141
|
+
elsif manifest["releases"].count > 1
|
142
|
+
err("Cannot validate a deployment manifest with more than 1 release")
|
143
|
+
else
|
144
|
+
release_name = manifest["releases"].first["name"]
|
145
|
+
end
|
146
|
+
if release_name == release.dev_name || release_name == release.final_name
|
147
|
+
nl
|
148
|
+
say("Analyzing release directory...".yellow)
|
149
|
+
else
|
150
|
+
err("This release was not found in deployment manifest")
|
151
|
+
end
|
141
152
|
|
142
153
|
say(" - discovering packages")
|
143
154
|
packages = Bosh::Cli::PackageBuilder.discover(
|
data/lib/cli/commands/help.rb
CHANGED
@@ -78,10 +78,14 @@ module Bosh::Cli::Command
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
self.class.list_commands(good_matches)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.list_commands(commands)
|
81
85
|
help_column_width = terminal_width - 5
|
82
86
|
help_indent = 4
|
83
87
|
|
84
|
-
|
88
|
+
commands.each_with_index do |command, i|
|
85
89
|
nl if i > 0
|
86
90
|
margin = command.usage.size + 1
|
87
91
|
say("#{command.usage_with_params.columnize(70, margin).green}")
|
@@ -93,4 +97,4 @@ module Bosh::Cli::Command
|
|
93
97
|
end
|
94
98
|
|
95
99
|
end
|
96
|
-
end
|
100
|
+
end
|
@@ -115,10 +115,10 @@ module Bosh::Cli::Command
|
|
115
115
|
nl
|
116
116
|
say("Performing `#{op_desc}'...")
|
117
117
|
|
118
|
-
status,
|
118
|
+
status, task_id = director.change_job_state(
|
119
119
|
manifest["name"], manifest_yaml, job, index, new_state)
|
120
120
|
|
121
|
-
task_report(status, completion_desc)
|
121
|
+
task_report(status, task_id, completion_desc)
|
122
122
|
end
|
123
123
|
|
124
124
|
end
|
@@ -25,10 +25,10 @@ module Bosh::Cli::Command
|
|
25
25
|
|
26
26
|
sanity_check_job_rename(manifest_yaml, old_name, new_name)
|
27
27
|
|
28
|
-
status,
|
28
|
+
status, task_id = director.rename_job(
|
29
29
|
manifest["name"], manifest_yaml, old_name, new_name, force)
|
30
30
|
|
31
|
-
task_report(status, "Rename successful")
|
31
|
+
task_report(status, task_id, "Rename successful")
|
32
32
|
end
|
33
33
|
|
34
34
|
def sanity_check_job_rename(manifest_yaml, old_name, new_name)
|
data/lib/cli/commands/misc.rb
CHANGED
@@ -15,6 +15,9 @@ module Bosh::Cli::Command
|
|
15
15
|
usage "status"
|
16
16
|
desc "Show current status (current target, user, deployment info etc)"
|
17
17
|
def status
|
18
|
+
cpi = nil
|
19
|
+
features = nil
|
20
|
+
|
18
21
|
if config.target
|
19
22
|
say("Updating director data...", " ")
|
20
23
|
|
@@ -26,6 +29,8 @@ module Bosh::Cli::Command
|
|
26
29
|
config.target_name = status["name"]
|
27
30
|
config.target_version = status["version"]
|
28
31
|
config.target_uuid = status["uuid"]
|
32
|
+
cpi = status["cpi"]
|
33
|
+
features = status["features"]
|
29
34
|
config.save
|
30
35
|
say("done".green)
|
31
36
|
end
|
@@ -46,6 +51,8 @@ module Bosh::Cli::Command
|
|
46
51
|
print_value("Version", config.target_version)
|
47
52
|
print_value("User", username, "not logged in")
|
48
53
|
print_value("UUID", config.target_uuid)
|
54
|
+
print_value("CPI", cpi, "n/a (update director)")
|
55
|
+
print_feature_list(features) if features
|
49
56
|
end
|
50
57
|
|
51
58
|
nl
|
@@ -313,5 +320,24 @@ module Bosh::Cli::Command
|
|
313
320
|
say(t) unless t.rows.empty?
|
314
321
|
end
|
315
322
|
|
323
|
+
def print_feature_list(features)
|
324
|
+
if features.respond_to?(:each)
|
325
|
+
features.each do |feature, status|
|
326
|
+
print_value(feature, format_feature_status(status))
|
327
|
+
end
|
328
|
+
else
|
329
|
+
say("Unknown feature list: #{features.inspect}".red)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
def format_feature_status(status)
|
334
|
+
if status.nil?
|
335
|
+
"n/a"
|
336
|
+
elsif status
|
337
|
+
"enabled"
|
338
|
+
else
|
339
|
+
"disabled"
|
340
|
+
end
|
341
|
+
end
|
316
342
|
end
|
317
343
|
end
|
data/lib/cli/commands/release.rb
CHANGED
@@ -184,9 +184,9 @@ module Bosh::Cli::Command
|
|
184
184
|
end
|
185
185
|
|
186
186
|
if confirmed?
|
187
|
-
status,
|
187
|
+
status, task_id = director.delete_release(
|
188
188
|
name, :force => force, :version => version)
|
189
|
-
task_report(status, "Deleted `#{desc}'")
|
189
|
+
task_report(status, task_id, "Deleted `#{desc}'")
|
190
190
|
else
|
191
191
|
say("Canceled deleting release".green)
|
192
192
|
end
|
@@ -258,12 +258,12 @@ module Bosh::Cli::Command
|
|
258
258
|
|
259
259
|
if rebase
|
260
260
|
say("Uploading release (#{"will be rebased".yellow})")
|
261
|
-
status,
|
262
|
-
task_report(status, "Release rebased")
|
261
|
+
status, task_id = director.rebase_release(tarball_path)
|
262
|
+
task_report(status, task_id, "Release rebased")
|
263
263
|
else
|
264
264
|
say("\nUploading release\n")
|
265
|
-
status,
|
266
|
-
task_report(status, "Release uploaded")
|
265
|
+
status, task_id = director.upload_release(tarball_path)
|
266
|
+
task_report(status, task_id, "Release uploaded")
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
data/lib/cli/commands/ssh.rb
CHANGED
@@ -121,6 +121,7 @@ module Bosh::Cli::Command
|
|
121
121
|
end
|
122
122
|
|
123
123
|
if options[:gateway_host]
|
124
|
+
require "net/ssh/gateway"
|
124
125
|
gw_host = options[:gateway_host]
|
125
126
|
gw_user = options[:gateway_user] || ENV["USER"]
|
126
127
|
gateway = Net::SSH::Gateway.new(gw_host, gw_user)
|
@@ -255,6 +256,8 @@ module Bosh::Cli::Command
|
|
255
256
|
if gateway
|
256
257
|
gateway.ssh(ip, user) { |ssh| yield ssh }
|
257
258
|
else
|
259
|
+
require "net/ssh"
|
260
|
+
require "net/scp"
|
258
261
|
Net::SSH.start(ip, user) { |ssh| yield ssh }
|
259
262
|
end
|
260
263
|
end
|
@@ -69,9 +69,9 @@ module Bosh::Cli::Command
|
|
69
69
|
say("Uploading stemcell...")
|
70
70
|
nl
|
71
71
|
|
72
|
-
status,
|
72
|
+
status, task_id = director.upload_stemcell(stemcell.stemcell_file)
|
73
73
|
|
74
|
-
task_report(status, "Stemcell uploaded and created")
|
74
|
+
task_report(status, task_id, "Stemcell uploaded and created")
|
75
75
|
end
|
76
76
|
|
77
77
|
# bosh stemcells
|
@@ -105,9 +105,11 @@ module Bosh::Cli::Command
|
|
105
105
|
desc "Show the list of publicly available stemcells for download."
|
106
106
|
option "--full", "show the full download url"
|
107
107
|
option "--tags tag1,tag2...", Array, "filter by tag"
|
108
|
+
option "--all", "show all stemcells"
|
108
109
|
def list_public
|
109
110
|
full = !!options[:full]
|
110
111
|
tags = options[:tags] || [DEFAULT_PUB_STEMCELL_TAG]
|
112
|
+
tags = [ALL_STEMCELLS_TAG] if options[:all]
|
111
113
|
|
112
114
|
yaml = get_public_stemcell_list
|
113
115
|
stemcells_table = table do |t|
|
@@ -191,9 +193,9 @@ module Bosh::Cli::Command
|
|
191
193
|
return
|
192
194
|
end
|
193
195
|
|
194
|
-
status,
|
196
|
+
status, task_id = director.delete_stemcell(name, version)
|
195
197
|
|
196
|
-
task_report(status, "Deleted stemcell `#{name}/#{version}'")
|
198
|
+
task_report(status, task_id, "Deleted stemcell `#{name}/#{version}'")
|
197
199
|
end
|
198
200
|
|
199
201
|
private
|
data/lib/cli/commands/vms.rb
CHANGED
data/lib/cli/core_ext.rb
CHANGED
data/lib/cli/release_compiler.rb
CHANGED
@@ -146,11 +146,12 @@ module Bosh::Cli
|
|
146
146
|
elsif blobstore_id
|
147
147
|
say("FOUND REMOTE".yellow)
|
148
148
|
say("Downloading #{blobstore_id.to_s.green}...")
|
149
|
+
tmp_file = Tempfile.new("")
|
150
|
+
@blobstore.get(blobstore_id, tmp_file)
|
151
|
+
tmp_file.close
|
149
152
|
|
150
|
-
|
151
|
-
|
152
|
-
if Digest::SHA1.hexdigest(payload) == sha1
|
153
|
-
File.open(filename, "w") { |f| f.write(payload) }
|
153
|
+
if Digest::SHA1.file(tmp_file.path).hexdigest == sha1
|
154
|
+
FileUtils.mv(tmp_file.path, filename)
|
154
155
|
else
|
155
156
|
err("#{desc} is corrupted in blobstore (id=#{blobstore_id})")
|
156
157
|
end
|
data/lib/cli/runner.rb
CHANGED
@@ -126,6 +126,9 @@ module Bosh::Cli
|
|
126
126
|
@options[:non_interactive] = true
|
127
127
|
Config.colorize = false
|
128
128
|
end
|
129
|
+
opts.on("-N", "--no-track", "Return Task ID and don't track") do
|
130
|
+
@options[:no_track] = true
|
131
|
+
end
|
129
132
|
opts.on("-t", "--target URL", "Override target") do |target|
|
130
133
|
@options[:target] = target
|
131
134
|
end
|
@@ -147,19 +150,17 @@ module Bosh::Cli
|
|
147
150
|
def load_plugins
|
148
151
|
plugins_glob = "bosh/cli/commands/*.rb"
|
149
152
|
|
150
|
-
unless Gem.respond_to?(:
|
153
|
+
unless Gem::Specification.respond_to?(:latest_specs) &&
|
154
|
+
Gem::Specification.instance_methods.include?(:matches_for_glob)
|
151
155
|
say("Cannot load plugins, ".yellow +
|
152
156
|
"please run `gem update --system' to ".yellow +
|
153
157
|
"update your RubyGems".yellow)
|
154
158
|
return
|
155
159
|
end
|
156
160
|
|
157
|
-
plugins =
|
158
|
-
|
159
|
-
|
160
|
-
# Handling rubygems compatibility issue
|
161
|
-
Gem.find_files(plugins_glob)
|
162
|
-
end
|
161
|
+
plugins = Gem::Specification.latest_specs(true).map { |spec|
|
162
|
+
spec.matches_for_glob(plugins_glob)
|
163
|
+
}.flatten
|
163
164
|
|
164
165
|
plugins.each do |plugin|
|
165
166
|
n_commands = Config.commands.size
|
@@ -252,4 +253,4 @@ module Bosh::Cli
|
|
252
253
|
search_parse_tree(@parse_tree)
|
253
254
|
end
|
254
255
|
end
|
255
|
-
end
|
256
|
+
end
|
data/lib/cli/task_tracker.rb
CHANGED
@@ -10,6 +10,8 @@ module Bosh
|
|
10
10
|
|
11
11
|
attr_reader :output
|
12
12
|
|
13
|
+
attr_reader :renderer
|
14
|
+
|
13
15
|
# @param [Bosh::Cli::Director] director
|
14
16
|
# @param [Integer] task_id
|
15
17
|
# @param [Hash] options
|
@@ -28,7 +30,9 @@ module Bosh
|
|
28
30
|
@cache = Config.cache
|
29
31
|
@task = Bosh::Cli::DirectorTask.new(@director, @task_id, @log_type)
|
30
32
|
|
31
|
-
if options[:
|
33
|
+
if options[:renderer]
|
34
|
+
@renderer = options[:renderer]
|
35
|
+
elsif options[:raw_output]
|
32
36
|
@renderer = Bosh::Cli::TaskLogRenderer.new
|
33
37
|
else
|
34
38
|
@renderer = Bosh::Cli::TaskLogRenderer.create_for_log_type(@log_type)
|
data/lib/cli/version.rb
CHANGED
@@ -124,4 +124,8 @@ describe Bosh::Cli::TaskTracker do
|
|
124
124
|
tracker.track.should == :cancelled
|
125
125
|
end
|
126
126
|
|
127
|
+
it "accepts alternate :renderer option" do
|
128
|
+
tracker = make_tracker("42", {:renderer => "I'm a renderer"})
|
129
|
+
tracker.renderer.should == "I'm a renderer"
|
130
|
+
end
|
127
131
|
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.0.
|
4
|
+
version: 1.0.2
|
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: 2012-11-
|
12
|
+
date: 2012-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bosh_common
|
@@ -355,7 +355,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
355
355
|
version: '0'
|
356
356
|
segments:
|
357
357
|
- 0
|
358
|
-
hash:
|
358
|
+
hash: 1768623608399422134
|
359
359
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
360
360
|
none: false
|
361
361
|
requirements:
|
@@ -364,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
364
364
|
version: '0'
|
365
365
|
segments:
|
366
366
|
- 0
|
367
|
-
hash:
|
367
|
+
hash: 1768623608399422134
|
368
368
|
requirements: []
|
369
369
|
rubyforge_project:
|
370
370
|
rubygems_version: 1.8.24
|