bosh_cli 1.1868.0 → 1.1975.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cli/commands/stemcell.rb +36 -7
- data/lib/cli/task_tracking/event_log_renderer.rb +5 -0
- data/lib/cli/version.rb +1 -1
- metadata +8 -8
@@ -4,6 +4,7 @@ require 'cli/public_stemcells'
|
|
4
4
|
module Bosh::Cli
|
5
5
|
class Command::Stemcell < Command::Base
|
6
6
|
include Bosh::Cli::VersionCalc
|
7
|
+
STEMCELL_EXISTS_ERROR_CODE = 50002
|
7
8
|
|
8
9
|
usage 'verify stemcell'
|
9
10
|
desc 'Verify stemcell'
|
@@ -28,6 +29,7 @@ module Bosh::Cli
|
|
28
29
|
|
29
30
|
usage 'upload stemcell'
|
30
31
|
desc 'Upload stemcell (stemcell_location can be a local file or a remote URI)'
|
32
|
+
option '--skip-if-exists', 'skips upload if stemcell already exists'
|
31
33
|
def upload(stemcell_location)
|
32
34
|
auth_required
|
33
35
|
|
@@ -49,8 +51,12 @@ module Bosh::Cli
|
|
49
51
|
version = stemcell.manifest['version']
|
50
52
|
|
51
53
|
if exists?(name, version)
|
52
|
-
|
53
|
-
|
54
|
+
if options[:skip_if_exists]
|
55
|
+
say("Stemcell `#{name}/#{version}' already exists. Skipping upload.")
|
56
|
+
return
|
57
|
+
else
|
58
|
+
err("Stemcell `#{name}/#{version}' already exists. Increment the version if it has changed.")
|
59
|
+
end
|
54
60
|
else
|
55
61
|
say('No')
|
56
62
|
end
|
@@ -65,13 +71,15 @@ module Bosh::Cli
|
|
65
71
|
say("Using remote stemcell `#{stemcell_location}'")
|
66
72
|
end
|
67
73
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
status, task_id = apply_upload_stemcell_strategy(stemcell_type, stemcell_location)
|
75
|
+
success_message = 'Stemcell uploaded and created.'
|
76
|
+
|
77
|
+
if status == :error && options[:skip_if_exists] && last_event(task_id)['error']['code'] == STEMCELL_EXISTS_ERROR_CODE
|
78
|
+
status = :done
|
79
|
+
success_message = skip_existing_stemcell_message(stemcell_type, stemcell_location)
|
72
80
|
end
|
73
81
|
|
74
|
-
task_report(status, task_id,
|
82
|
+
task_report(status, task_id, success_message)
|
75
83
|
end
|
76
84
|
|
77
85
|
usage 'stemcells'
|
@@ -146,6 +154,27 @@ module Bosh::Cli
|
|
146
154
|
|
147
155
|
private
|
148
156
|
|
157
|
+
def skip_existing_stemcell_message(stemcell_type, stemcell_location)
|
158
|
+
if stemcell_type == 'local'
|
159
|
+
'Stemcell already exists. Skipping upload.'
|
160
|
+
else
|
161
|
+
"Stemcell at #{stemcell_location} already exists."
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def apply_upload_stemcell_strategy(stemcell_type, stemcell_location)
|
166
|
+
if stemcell_type == 'local'
|
167
|
+
director.upload_stemcell(stemcell_location)
|
168
|
+
else
|
169
|
+
director.upload_remote_stemcell(stemcell_location)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def last_event(task_id)
|
174
|
+
event_log, _ = director.get_task_output(task_id, 0, 'event')
|
175
|
+
JSON.parse(event_log.split("\n").last)
|
176
|
+
end
|
177
|
+
|
149
178
|
def exists?(name, version)
|
150
179
|
existing = director.list_stemcells.select do |sc|
|
151
180
|
sc['name'] == name && sc['version'] == version
|
@@ -30,6 +30,11 @@ module Bosh::Cli::TaskTracking
|
|
30
30
|
event = parse_event(event_line)
|
31
31
|
|
32
32
|
@lock.synchronize do
|
33
|
+
if event['type'] == 'deprecation'
|
34
|
+
@buffer.puts("Deprecation: #{event['message']}".make_red)
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
33
38
|
# Handling the special "error" event
|
34
39
|
if event['error']
|
35
40
|
done_with_stage if @current_stage
|
data/lib/cli/version.rb
CHANGED
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.
|
4
|
+
version: 1.1975.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-
|
12
|
+
date: 2014-02-12 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.
|
21
|
+
version: 1.1975.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.
|
29
|
+
version: 1.1975.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.
|
117
|
+
version: 1.1975.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.
|
125
|
+
version: 1.1975.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
|
-
|
272
|
+
9c66c4'
|
273
273
|
email: support@cloudfoundry.com
|
274
274
|
executables:
|
275
275
|
- bosh
|
@@ -376,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
376
376
|
version: '0'
|
377
377
|
segments:
|
378
378
|
- 0
|
379
|
-
hash:
|
379
|
+
hash: 3035706384650308221
|
380
380
|
requirements: []
|
381
381
|
rubyforge_project:
|
382
382
|
rubygems_version: 1.8.23
|