bosh_cli 1.3112.0 → 1.3115.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cli/commands/release/upload_release.rb +19 -6
- data/lib/cli/commands/ssh.rb +12 -13
- data/lib/cli/release.rb +0 -3
- data/lib/cli/release_tarball.rb +100 -46
- data/lib/cli/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfd2d53b788b054d99bd8d7708453c81396f7c85
|
4
|
+
data.tar.gz: c3137783a4253dcaa07585072913d86884df6070
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 508628bc1637eb908b4b6b2c0e0150ab4dfaee34d7a5f8ec27a6960a3802b071901caa77339bba42daaca0cb14615e8e36b7f66b177bc56b5a870c102ae6bc23
|
7
|
+
data.tar.gz: a2585a85ad0c31c0f11554d439dd36e0b81557a7eb7414fed3d54ad6ec33e67b5b45344769712d004e2ee04c4ce8b42d7af16ae414279216f06521c6d394c43f
|
@@ -84,14 +84,10 @@ module Bosh::Cli::Command
|
|
84
84
|
repack = upload_options[:repack]
|
85
85
|
rebase = upload_options[:rebase]
|
86
86
|
|
87
|
-
say("\nVerifying
|
88
|
-
tarball.
|
87
|
+
say("\nVerifying manifest...")
|
88
|
+
tarball.validate_manifest
|
89
89
|
nl
|
90
90
|
|
91
|
-
unless tarball.valid?
|
92
|
-
err('Release is invalid, please fix, verify and upload again')
|
93
|
-
end
|
94
|
-
|
95
91
|
if should_convert_to_old_format?(tarball.version)
|
96
92
|
msg = "You are using CLI > 1.2579.0 with a director that doesn't support " +
|
97
93
|
'the new version format you are using. Upgrade your ' +
|
@@ -112,6 +108,16 @@ module Bosh::Cli::Command
|
|
112
108
|
package_matches = match_remote_packages(tarball.manifest)
|
113
109
|
end
|
114
110
|
|
111
|
+
# if the director is an older version that doesn't support optimized unpack we
|
112
|
+
# have to upload everything
|
113
|
+
if tarball.upload_packages?(package_matches) || !director_supports_fast_unpack?
|
114
|
+
tarball.validate(:allow_sparse => true, :validate_manifest => false)
|
115
|
+
err('Release is invalid, please fix, verify and upload again') unless tarball.valid?
|
116
|
+
else
|
117
|
+
tarball.validate_jobs(:allow_sparse => true, :validate_job_packages => false)
|
118
|
+
tarball.print_manifest
|
119
|
+
end
|
120
|
+
|
115
121
|
say('Checking if can repack release for faster upload...')
|
116
122
|
repacked_path = tarball.repack(package_matches)
|
117
123
|
|
@@ -216,6 +222,13 @@ module Bosh::Cli::Command
|
|
216
222
|
Bosh::Common::Version::BoshVersion.parse(director_version) >=
|
217
223
|
Bosh::Common::Version::BoshVersion.parse(new_format_director_version)
|
218
224
|
end
|
225
|
+
|
226
|
+
def director_supports_fast_unpack?
|
227
|
+
director_version = director.get_status['version']
|
228
|
+
new_format_director_version = '1.3100.0'
|
229
|
+
Bosh::Common::Version::BoshVersion.parse(director_version) >
|
230
|
+
Bosh::Common::Version::BoshVersion.parse(new_format_director_version)
|
231
|
+
end
|
219
232
|
end
|
220
233
|
end
|
221
234
|
end
|
data/lib/cli/commands/ssh.rb
CHANGED
@@ -15,6 +15,8 @@ module Bosh::Cli
|
|
15
15
|
'Use default ssh password (NOT RECOMMENDED)'
|
16
16
|
option '--strict_host_key_checking <yes/no>',
|
17
17
|
'Can use this flag to skip host key checking (NOT RECOMMENDED)'
|
18
|
+
option '--no_gateway',
|
19
|
+
'Ignore gateway provided by the director'
|
18
20
|
|
19
21
|
def shell(*args)
|
20
22
|
if args.size > 0
|
@@ -46,6 +48,8 @@ module Bosh::Cli
|
|
46
48
|
option '--gateway_host HOST', 'Gateway host'
|
47
49
|
option '--gateway_user USER', 'Gateway user'
|
48
50
|
option '--gateway_identity_file FILE', 'Gateway identity file'
|
51
|
+
option '--no_gateway',
|
52
|
+
'Ignore gateway provided by the director'
|
49
53
|
|
50
54
|
def scp(*args)
|
51
55
|
job, index, args = JobCommandArgs.new(args).to_a
|
@@ -138,10 +142,11 @@ module Bosh::Cli
|
|
138
142
|
ssh_session.set_host_session(sessions.first)
|
139
143
|
|
140
144
|
begin
|
141
|
-
if options[:gateway_host]
|
145
|
+
if options[:gateway_host] || (!options[:no_gateway] &&
|
146
|
+
sessions.first["gateway_host"])
|
142
147
|
require 'net/ssh/gateway'
|
143
|
-
gw_host = options[:gateway_host]
|
144
|
-
gw_user = options[:gateway_user] || ENV['USER']
|
148
|
+
gw_host = options[:gateway_host] || sessions.first["gateway_host"]
|
149
|
+
gw_user = options[:gateway_user] || sessions.first["gateway_user"] || ENV['USER']
|
145
150
|
gw_options = {}
|
146
151
|
gw_options[:keys] = [options[:gateway_identity_file]] if options[:gateway_identity_file]
|
147
152
|
begin
|
@@ -167,15 +172,7 @@ module Bosh::Cli
|
|
167
172
|
# @param [String] job Job name
|
168
173
|
# @param [Integer] index Job index
|
169
174
|
def setup_interactive_shell(deployment_name, job, index)
|
170
|
-
password = options[:default_password]
|
171
|
-
|
172
|
-
if password.nil?
|
173
|
-
password = ask(
|
174
|
-
'Enter password (use it to ' +
|
175
|
-
'sudo on remote host): ') { |q| q.echo = '*' }
|
176
|
-
|
177
|
-
err('Please provide ssh password') if password.blank?
|
178
|
-
end
|
175
|
+
password = options[:default_password] || ''
|
179
176
|
|
180
177
|
setup_ssh(deployment_name, job, index, password) do |sessions, gateway, ssh_session|
|
181
178
|
session = sessions.first
|
@@ -206,7 +203,9 @@ module Bosh::Cli
|
|
206
203
|
end
|
207
204
|
|
208
205
|
def perform_operation(operation, deployment_name, job, index, args)
|
209
|
-
|
206
|
+
password = options[:default_password] || ''
|
207
|
+
|
208
|
+
setup_ssh(deployment_name, job, index, password) do |sessions, gateway, ssh_session|
|
210
209
|
sessions.each do |session|
|
211
210
|
unless session['status'] == 'success' && session['ip']
|
212
211
|
err("Failed to set up SSH on #{job}/#{index}: #{session.inspect}")
|
data/lib/cli/release.rb
CHANGED
@@ -73,9 +73,6 @@ module Bosh::Cli
|
|
73
73
|
has_legacy_secret? ||
|
74
74
|
has_blobstore_secrets?(bs, "simple", "user", "password") ||
|
75
75
|
has_blobstore_secrets?(bs, "dav", "user", "password") ||
|
76
|
-
has_blobstore_secrets?(bs, "swift", "rackspace") ||
|
77
|
-
has_blobstore_secrets?(bs, "swift", "hp") ||
|
78
|
-
has_blobstore_secrets?(bs, "swift", "openstack") ||
|
79
76
|
has_blobstore_secrets?(bs, "s3", "access_key_id", "secret_access_key")
|
80
77
|
end
|
81
78
|
|
data/lib/cli/release_tarball.rb
CHANGED
@@ -19,6 +19,38 @@ module Bosh::Cli
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def unpack_manifest
|
23
|
+
return @unpacked_manifest unless @unpacked_manifest.nil?
|
24
|
+
exit_success = fast_unpack('./release.MF')
|
25
|
+
@unpacked_manifest = !!exit_success
|
26
|
+
end
|
27
|
+
|
28
|
+
def unpack_jobs
|
29
|
+
return @unpacked_jobs unless @unpacked_jobs.nil?
|
30
|
+
exit_success = fast_unpack('./jobs/')
|
31
|
+
@unpacked_jobs = !!exit_success
|
32
|
+
end
|
33
|
+
|
34
|
+
def unpack_license
|
35
|
+
return @unpacked_license unless @unpacked_license.nil?
|
36
|
+
exit_success = fast_unpack('./license.tgz')
|
37
|
+
@unpacked_license = !!exit_success
|
38
|
+
end
|
39
|
+
|
40
|
+
def fast_unpack(target)
|
41
|
+
if RUBY_PLATFORM =~ /linux/
|
42
|
+
system("tar", "-C", @unpack_dir, "-xzf", @tarball_path, "--occurrence", "#{target}", out: "/dev/null", err: "/dev/null")
|
43
|
+
elsif RUBY_PLATFORM =~ /darwin/
|
44
|
+
if target[-1, 1] == "/"
|
45
|
+
system("tar", "-C", @unpack_dir, "-xzf", @tarball_path, "#{target}", out: "/dev/null", err: "/dev/null")
|
46
|
+
else
|
47
|
+
system("tar", "-C", @unpack_dir, "--fast-read", "-xzf", @tarball_path, "#{target}", out: "/dev/null", err: "/dev/null")
|
48
|
+
end
|
49
|
+
else
|
50
|
+
system("tar", "-C", @unpack_dir, "-xzf", @tarball_path, "#{target}", out: "/dev/null", err: "/dev/null")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
22
54
|
# Unpacks tarball to @unpack_dir, returns true if succeeded, false if failed
|
23
55
|
def unpack
|
24
56
|
return @unpacked unless @unpacked.nil?
|
@@ -38,13 +70,19 @@ module Bosh::Cli
|
|
38
70
|
|
39
71
|
def manifest
|
40
72
|
return nil unless valid?
|
41
|
-
|
73
|
+
unpack_manifest
|
42
74
|
File.read(File.join(@unpack_dir, "release.MF"))
|
43
75
|
end
|
44
76
|
|
77
|
+
def manifest_yaml
|
78
|
+
return @manifest_yaml unless @manifest_yaml.nil?
|
79
|
+
unpack_manifest
|
80
|
+
manifest_file = File.expand_path("release.MF", @unpack_dir)
|
81
|
+
@manifest_yaml = load_yaml_file(manifest_file)
|
82
|
+
end
|
83
|
+
|
45
84
|
def compiled_release?
|
46
|
-
|
47
|
-
File.exists?(File.expand_path("compiled_packages", @unpack_dir))
|
85
|
+
manifest_yaml.has_key?('compiled_packages')
|
48
86
|
end
|
49
87
|
|
50
88
|
def replace_manifest(hash)
|
@@ -91,11 +129,16 @@ module Bosh::Cli
|
|
91
129
|
end
|
92
130
|
end
|
93
131
|
|
132
|
+
def upload_packages?(package_matches = [])
|
133
|
+
return true if package_matches.nil?
|
134
|
+
package_matches.size != manifest_yaml[@packages_folder].size
|
135
|
+
end
|
136
|
+
|
94
137
|
# Repacks tarball according to the structure of remote release
|
95
138
|
# Return path to repackaged tarball or nil if repack has failed
|
96
139
|
def repack(package_matches = [])
|
97
140
|
return nil unless valid?
|
98
|
-
unpack
|
141
|
+
unpack if upload_packages?(package_matches)
|
99
142
|
|
100
143
|
tmpdir = Dir.mktmpdir
|
101
144
|
repacked_path = File.join(tmpdir, "release-repack.tgz")
|
@@ -116,7 +159,7 @@ module Bosh::Cli
|
|
116
159
|
package_matches.include?(package["fingerprint"]))
|
117
160
|
say("SKIP".make_green)
|
118
161
|
@skipped += 1
|
119
|
-
FileUtils.rm_rf(File.join(
|
162
|
+
FileUtils.rm_rf(File.join(@packages_folder, "#{package["name"]}.tgz"))
|
120
163
|
else
|
121
164
|
say("UPLOAD".make_red)
|
122
165
|
end
|
@@ -137,42 +180,50 @@ module Bosh::Cli
|
|
137
180
|
# and packages in place when we do validation. However for jobs and packages
|
138
181
|
# that are present we still need to validate checksums
|
139
182
|
def perform_validation(options = {})
|
140
|
-
|
141
|
-
should_print_release_info = options.fetch(:print_release_info, true)
|
142
|
-
|
143
|
-
step("File exists and readable",
|
144
|
-
"Cannot find release file #{@tarball_path}", :fatal) do
|
183
|
+
step("File exists and readable", "Cannot find release file #{@tarball_path}", :fatal) do
|
145
184
|
exists?
|
146
185
|
end
|
147
186
|
|
148
|
-
|
149
|
-
|
150
|
-
|
187
|
+
validate_manifest if options.fetch(:validate_manifest, true)
|
188
|
+
validate_packages(options)
|
189
|
+
validate_jobs(options)
|
190
|
+
|
191
|
+
print_manifest if options.fetch(:print_release_info, true)
|
192
|
+
end
|
193
|
+
|
194
|
+
def validate_manifest
|
195
|
+
step("Extract manifest",
|
196
|
+
"Cannot extract manifest #{@tarball_path}", :fatal) do
|
197
|
+
unpack_manifest
|
151
198
|
end
|
152
199
|
|
153
200
|
manifest_file = File.expand_path("release.MF", @unpack_dir)
|
154
|
-
|
155
201
|
step("Manifest exists", "Cannot find release manifest", :fatal) do
|
156
202
|
File.exists?(manifest_file)
|
157
203
|
end
|
158
204
|
|
159
|
-
|
205
|
+
@manifest_yaml = nil
|
160
206
|
|
161
207
|
step("Release name/version",
|
162
208
|
"Manifest doesn't contain release name and/or version") do
|
163
|
-
|
164
|
-
|
165
|
-
|
209
|
+
manifest_yaml.is_a?(Hash) &&
|
210
|
+
manifest_yaml.has_key?("name") &&
|
211
|
+
manifest_yaml.has_key?("version")
|
166
212
|
end
|
167
213
|
|
168
|
-
@release_name =
|
169
|
-
@version =
|
214
|
+
@release_name = manifest_yaml["name"]
|
215
|
+
@version = manifest_yaml["version"].to_s
|
216
|
+
@validated = true
|
217
|
+
end
|
170
218
|
|
171
|
-
|
172
|
-
|
173
|
-
|
219
|
+
def validate_packages(options = {})
|
220
|
+
allow_sparse = options.fetch(:allow_sparse, false)
|
221
|
+
unpack
|
222
|
+
|
223
|
+
total_packages = manifest_yaml[@packages_folder].size
|
224
|
+
@available_packages = {}
|
174
225
|
|
175
|
-
|
226
|
+
manifest_yaml[@packages_folder].each_with_index do |package, i|
|
176
227
|
@packages << package
|
177
228
|
name, version = package['name'], package['version']
|
178
229
|
|
@@ -185,7 +236,7 @@ module Bosh::Cli
|
|
185
236
|
end
|
186
237
|
|
187
238
|
if package_exists
|
188
|
-
available_packages[name] = true
|
239
|
+
@available_packages[name] = true
|
189
240
|
step("Package '#{name}' checksum",
|
190
241
|
"Incorrect checksum for package '#{name}'") do
|
191
242
|
Digest::SHA1.file(package_file).hexdigest == package["sha1"]
|
@@ -201,8 +252,8 @@ module Bosh::Cli
|
|
201
252
|
step("Package dependencies",
|
202
253
|
"Package dependencies couldn't be resolved") do
|
203
254
|
begin
|
204
|
-
tsort_packages(
|
205
|
-
|
255
|
+
tsort_packages(manifest_yaml[@packages_folder].inject({}) { |h, p|
|
256
|
+
h[p["name"]] = p["dependencies"] || []; h })
|
206
257
|
true
|
207
258
|
rescue Bosh::Cli::CircularDependency,
|
208
259
|
Bosh::Cli::MissingDependency => e
|
@@ -211,26 +262,30 @@ module Bosh::Cli
|
|
211
262
|
end
|
212
263
|
end
|
213
264
|
end
|
265
|
+
end
|
214
266
|
|
215
|
-
|
216
|
-
|
267
|
+
def validate_jobs(options = {})
|
268
|
+
allow_sparse = options.fetch(:allow_sparse, false)
|
269
|
+
unpack_jobs
|
270
|
+
unpack_license
|
271
|
+
|
272
|
+
total_jobs = manifest_yaml["jobs"].size
|
217
273
|
|
218
274
|
step("Checking jobs format",
|
219
|
-
"Jobs are not versioned, please re-create release "
|
220
|
-
|
221
|
-
total_jobs > 0 && manifest["jobs"][0].is_a?(Hash)
|
275
|
+
"Jobs are not versioned, please re-create release with current CLI version (or any CLI >= 0.4.4)", :fatal) do
|
276
|
+
total_jobs > 0 && manifest_yaml["jobs"][0].is_a?(Hash)
|
222
277
|
end
|
223
278
|
|
224
|
-
|
279
|
+
manifest_yaml["jobs"].each_with_index do |job, i|
|
225
280
|
@jobs << job
|
281
|
+
|
226
282
|
name = job["name"]
|
227
283
|
version = job["version"]
|
228
284
|
|
229
285
|
job_file = File.expand_path(name + ".tgz", @unpack_dir + "/jobs")
|
230
286
|
job_exists = File.exists?(job_file)
|
231
287
|
|
232
|
-
step("Read job '%s' (%d of %d), version %s" % [name, i+1, total_jobs,
|
233
|
-
version],
|
288
|
+
step("Read job '%s' (%d of %d), version %s" % [name, i+1, total_jobs, version],
|
234
289
|
"Job '#{name}' not found") do
|
235
290
|
job_exists || allow_sparse
|
236
291
|
end
|
@@ -265,32 +320,29 @@ module Bosh::Cli
|
|
265
320
|
job_manifest["templates"].each_key do |template|
|
266
321
|
step("Check template '#{template}' for '#{name}'",
|
267
322
|
"No template named '#{template}' for '#{name}'") do
|
268
|
-
File.exists?(File.expand_path(template,
|
269
|
-
job_tmp_dir + "/templates"))
|
323
|
+
File.exists?(File.expand_path(template, job_tmp_dir + "/templates"))
|
270
324
|
end
|
271
325
|
end
|
272
326
|
end
|
273
327
|
|
274
|
-
|
328
|
+
validate_job_packages = options.fetch(:validate_job_packages, true)
|
329
|
+
|
330
|
+
if validate_job_packages && job_manifest_valid && job_manifest["packages"]
|
275
331
|
job_manifest["packages"].each do |package_name|
|
276
332
|
step("Job '#{name}' needs '#{package_name}' package",
|
277
|
-
"Job '#{name}' references missing package "
|
278
|
-
|
279
|
-
available_packages[package_name] || allow_sparse
|
333
|
+
"Job '#{name}' references missing package '#{package_name}'") do
|
334
|
+
@available_packages[package_name] || allow_sparse
|
280
335
|
end
|
281
336
|
end
|
282
337
|
end
|
283
338
|
|
284
339
|
step("Monit file for '#{name}'",
|
285
340
|
"Monit script missing for job '#{name}'") do
|
286
|
-
File.exists?(File.expand_path("monit", job_tmp_dir)) ||
|
287
|
-
Dir.glob("#{job_tmp_dir}/*.monit").size > 0
|
341
|
+
File.exists?(File.expand_path("monit", job_tmp_dir)) || Dir.glob("#{job_tmp_dir}/*.monit").size > 0
|
288
342
|
end
|
289
343
|
end
|
290
344
|
end
|
291
345
|
end
|
292
|
-
|
293
|
-
print_info(manifest) if should_print_release_info
|
294
346
|
end
|
295
347
|
|
296
348
|
class TarballArtifact
|
@@ -330,7 +382,8 @@ module Bosh::Cli
|
|
330
382
|
[]
|
331
383
|
end
|
332
384
|
|
333
|
-
def
|
385
|
+
def print_manifest
|
386
|
+
manifest = manifest_yaml
|
334
387
|
say("\nRelease info")
|
335
388
|
say("------------")
|
336
389
|
|
@@ -363,6 +416,7 @@ module Bosh::Cli
|
|
363
416
|
else
|
364
417
|
say(" - license (#{manifest["license"]["version"]})")
|
365
418
|
end
|
419
|
+
nl
|
366
420
|
end
|
367
421
|
end
|
368
422
|
end
|
data/lib/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3115.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VMware
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bosh_common
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.3115.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.3115.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bosh-template
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.3115.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.3115.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: cf-uaa-lib
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.
|
131
|
+
version: 1.3115.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.
|
138
|
+
version: 1.3115.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: net-ssh
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|