bosh_cli_plugin_micro 1.5.0.pre.1113 → 1.5.0.pre.1114
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bosh/cli/commands/micro.rb +73 -73
- data/lib/bosh/deployer/config.rb +5 -0
- data/lib/bosh/deployer/configuration.rb +149 -0
- data/lib/bosh/deployer/director_gateway_error.rb +3 -0
- data/lib/{deployer → bosh/deployer}/helpers.rb +6 -6
- data/lib/{deployer → bosh/deployer}/instance_manager/aws.rb +29 -29
- data/lib/{deployer → bosh/deployer}/instance_manager/openstack.rb +31 -31
- data/lib/{deployer → bosh/deployer}/instance_manager/vcloud.rb +4 -4
- data/lib/bosh/deployer/instance_manager/vsphere.rb +43 -0
- data/lib/{deployer → bosh/deployer}/instance_manager.rb +63 -89
- data/lib/bosh/deployer/logger_renderer.rb +20 -0
- data/lib/{deployer → bosh/deployer}/models/instance.rb +0 -0
- data/lib/{deployer → bosh/deployer}/specification.rb +12 -12
- data/lib/{deployer → bosh/deployer}/version.rb +1 -1
- data/lib/bosh/deployer.rb +23 -0
- metadata +30 -27
- data/lib/deployer/config.rb +0 -157
- data/lib/deployer/instance_manager/vsphere.rb +0 -46
- data/lib/deployer.rb +0 -23
@@ -8,54 +8,54 @@ module Bosh::Deployer
|
|
8
8
|
def update_spec(spec)
|
9
9
|
properties = spec.properties
|
10
10
|
|
11
|
-
properties[
|
12
|
-
Config.spec_properties[
|
13
|
-
Config.cloud_options[
|
11
|
+
properties['openstack'] =
|
12
|
+
Config.spec_properties['openstack'] ||
|
13
|
+
Config.cloud_options['properties']['openstack'].dup
|
14
14
|
|
15
|
-
properties[
|
16
|
-
properties[
|
15
|
+
properties['openstack']['registry'] = Config.cloud_options['properties']['registry']
|
16
|
+
properties['openstack']['stemcell'] = Config.cloud_options['properties']['stemcell']
|
17
17
|
|
18
|
-
spec.delete(
|
18
|
+
spec.delete('networks')
|
19
19
|
end
|
20
20
|
|
21
21
|
def configure
|
22
|
-
properties = Config.cloud_options[
|
23
|
-
@ssh_user = properties[
|
24
|
-
@ssh_port = properties[
|
25
|
-
@ssh_wait = properties[
|
22
|
+
properties = Config.cloud_options['properties']
|
23
|
+
@ssh_user = properties['openstack']['ssh_user']
|
24
|
+
@ssh_port = properties['openstack']['ssh_port'] || 22
|
25
|
+
@ssh_wait = properties['openstack']['ssh_wait'] || 60
|
26
26
|
|
27
|
-
key = properties[
|
28
|
-
err
|
27
|
+
key = properties['openstack']['private_key']
|
28
|
+
err 'Missing properties.openstack.private_key' unless key
|
29
29
|
@ssh_key = File.expand_path(key)
|
30
30
|
unless File.exists?(@ssh_key)
|
31
31
|
err "properties.openstack.private_key '#{key}' does not exist"
|
32
32
|
end
|
33
33
|
|
34
|
-
uri = URI.parse(properties[
|
35
|
-
user, password = uri.userinfo.split(
|
34
|
+
uri = URI.parse(properties['registry']['endpoint'])
|
35
|
+
user, password = uri.userinfo.split(':', 2)
|
36
36
|
@registry_port = uri.port
|
37
37
|
|
38
|
-
@registry_db = Tempfile.new(
|
38
|
+
@registry_db = Tempfile.new('bosh_registry_db')
|
39
39
|
@registry_connection_settings = {
|
40
40
|
'adapter' => 'sqlite',
|
41
41
|
'database' => @registry_db.path
|
42
42
|
}
|
43
43
|
|
44
44
|
registry_config = {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
'logfile' => './bosh-registry.log',
|
46
|
+
'http' => {
|
47
|
+
'port' => uri.port,
|
48
|
+
'user' => user,
|
49
|
+
'password' => password
|
50
50
|
},
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
'db' => @registry_connection_settings,
|
52
|
+
'cloud' => {
|
53
|
+
'plugin' => 'openstack',
|
54
|
+
'openstack' => properties['openstack']
|
55
55
|
}
|
56
56
|
}
|
57
57
|
|
58
|
-
@registry_config = Tempfile.new(
|
58
|
+
@registry_config = Tempfile.new('bosh_registry_yml')
|
59
59
|
@registry_config.write(Psych.dump(registry_config))
|
60
60
|
@registry_config.close
|
61
61
|
end
|
@@ -65,12 +65,12 @@ module Bosh::Deployer
|
|
65
65
|
|
66
66
|
Sequel.connect(@registry_connection_settings) do |db|
|
67
67
|
migrate(db)
|
68
|
-
instances = @deployments[
|
68
|
+
instances = @deployments['registry_instances']
|
69
69
|
db[:registry_instances].insert_multiple(instances) if instances
|
70
70
|
end
|
71
71
|
|
72
72
|
unless has_bosh_registry?
|
73
|
-
err
|
73
|
+
err 'bosh-registry command not found - ' +
|
74
74
|
"run 'gem install bosh-registry'"
|
75
75
|
end
|
76
76
|
|
@@ -105,14 +105,14 @@ module Bosh::Deployer
|
|
105
105
|
|
106
106
|
def stop
|
107
107
|
if @registry_pid && process_exists?(@registry_pid)
|
108
|
-
Process.kill(
|
108
|
+
Process.kill('INT', @registry_pid)
|
109
109
|
Process.waitpid(@registry_pid)
|
110
110
|
end
|
111
111
|
|
112
112
|
return unless @registry_connection_settings
|
113
113
|
|
114
114
|
Sequel.connect(@registry_connection_settings) do |db|
|
115
|
-
@deployments[
|
115
|
+
@deployments['registry_instances'] = db[:registry_instances].map {|row| row}
|
116
116
|
end
|
117
117
|
|
118
118
|
save_state
|
@@ -155,8 +155,8 @@ module Bosh::Deployer
|
|
155
155
|
private
|
156
156
|
|
157
157
|
def has_bosh_registry?(path=ENV['PATH'])
|
158
|
-
path.split(
|
159
|
-
return true if File.exist?(File.join(dir,
|
158
|
+
path.split(':').each do |dir|
|
159
|
+
return true if File.exist?(File.join(dir, 'bosh-registry'))
|
160
160
|
end
|
161
161
|
false
|
162
162
|
end
|
@@ -14,11 +14,11 @@ module Bosh::Deployer
|
|
14
14
|
def update_spec(spec)
|
15
15
|
properties = spec.properties
|
16
16
|
|
17
|
-
properties[
|
18
|
-
Config.spec_properties[
|
19
|
-
Config.cloud_options[
|
17
|
+
properties['vcd'] =
|
18
|
+
Config.spec_properties['vcd'] ||
|
19
|
+
Config.cloud_options['properties']['vcds'].first.dup
|
20
20
|
|
21
|
-
properties[
|
21
|
+
properties['vcd']['address'] ||= properties['vcd']['url']
|
22
22
|
end
|
23
23
|
|
24
24
|
# @return [Integer] size in MiB
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Deployer
|
4
|
+
class InstanceManager
|
5
|
+
class Vsphere < InstanceManager
|
6
|
+
def remote_tunnel(port)
|
7
|
+
end
|
8
|
+
|
9
|
+
def disk_model
|
10
|
+
if @disk_model.nil?
|
11
|
+
require 'cloud/vsphere'
|
12
|
+
@disk_model = VSphereCloud::Models::Disk
|
13
|
+
end
|
14
|
+
@disk_model
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_spec(spec)
|
18
|
+
properties = spec.properties
|
19
|
+
|
20
|
+
properties['vcenter'] =
|
21
|
+
Config.spec_properties['vcenter'] ||
|
22
|
+
Config.cloud_options['properties']['vcenters'].first.dup
|
23
|
+
|
24
|
+
properties['vcenter']['address'] ||= properties['vcenter']['host']
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Integer] size in MiB
|
28
|
+
def disk_size(cid)
|
29
|
+
disk_model.first(uuid: cid).size
|
30
|
+
end
|
31
|
+
|
32
|
+
def persistent_disk_changed?
|
33
|
+
Config.resources['persistent_disk'] != disk_size(state.disk_cid)
|
34
|
+
end
|
35
|
+
|
36
|
+
def check_dependencies
|
37
|
+
if Bosh::Common.which(%w[genisoimage mkisofs]).nil?
|
38
|
+
err("either of 'genisoimage' or 'mkisofs' commands must be present")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,67 +1,41 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
1
|
require 'open3'
|
2
|
+
require 'bosh/deployer/logger_renderer'
|
3
|
+
require 'bosh/deployer/director_gateway_error'
|
4
4
|
|
5
5
|
module Bosh::Deployer
|
6
|
-
|
7
|
-
class DirectorGatewayError < RuntimeError; end
|
8
|
-
|
9
6
|
class InstanceManager
|
10
|
-
|
7
|
+
|
11
8
|
CONNECTION_EXCEPTIONS = [
|
12
9
|
Bosh::Agent::Error,
|
13
10
|
Errno::ECONNREFUSED,
|
14
11
|
Errno::ETIMEDOUT,
|
15
|
-
|
12
|
+
DirectorGatewayError,
|
16
13
|
HTTPClient::ConnectTimeoutError
|
17
14
|
]
|
18
15
|
|
16
|
+
extend Helpers
|
19
17
|
include Helpers
|
20
18
|
|
21
19
|
attr_reader :state
|
22
20
|
attr_accessor :renderer
|
23
21
|
|
24
|
-
|
25
|
-
|
22
|
+
def self.create(config)
|
23
|
+
plugin = cloud_plugin(config)
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
def enter_stage(stage, total)
|
32
|
-
@stage = stage
|
33
|
-
@total = total
|
34
|
-
@index = 0
|
35
|
-
end
|
36
|
-
|
37
|
-
def update(state, task)
|
38
|
-
Config.logger.info("#{@stage} - #{state} #{task}")
|
39
|
-
@index += 1 if state == :finished
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class << self
|
44
|
-
|
45
|
-
include Helpers
|
46
|
-
|
47
|
-
def create(config)
|
48
|
-
plugin = cloud_plugin(config)
|
49
|
-
|
50
|
-
begin
|
51
|
-
require "deployer/instance_manager/#{plugin}"
|
52
|
-
rescue LoadError
|
53
|
-
err "Could not find Provider Plugin: #{plugin}"
|
54
|
-
end
|
55
|
-
Bosh::Deployer::InstanceManager.const_get(plugin.capitalize).new(config)
|
25
|
+
begin
|
26
|
+
require "bosh/deployer/instance_manager/#{plugin}"
|
27
|
+
rescue LoadError
|
28
|
+
err "Could not find Provider Plugin: #{plugin}"
|
56
29
|
end
|
57
30
|
|
31
|
+
InstanceManager.const_get(plugin.capitalize).new(config)
|
58
32
|
end
|
59
33
|
|
60
34
|
def initialize(config)
|
61
35
|
Config.configure(config)
|
62
36
|
|
63
|
-
@state_yml = File.join(config[
|
64
|
-
load_state(config[
|
37
|
+
@state_yml = File.join(config['dir'], DEPLOYMENTS_FILE)
|
38
|
+
load_state(config['name'])
|
65
39
|
|
66
40
|
Config.uuid = state.uuid
|
67
41
|
|
@@ -136,50 +110,50 @@ module Bosh::Deployer
|
|
136
110
|
err "stemcell #{state.stemcell_cid} already exists"
|
137
111
|
end
|
138
112
|
|
139
|
-
renderer.enter_stage(
|
113
|
+
renderer.enter_stage('Deploy Micro BOSH', 11)
|
140
114
|
|
141
115
|
state.stemcell_cid = create_stemcell(stemcell_tgz)
|
142
|
-
state.stemcell_name = File.basename(stemcell_tgz,
|
116
|
+
state.stemcell_name = File.basename(stemcell_tgz, '.tgz')
|
143
117
|
save_state
|
144
118
|
|
145
119
|
step "Creating VM from #{state.stemcell_cid}" do
|
146
120
|
state.vm_cid = create_vm(state.stemcell_cid)
|
147
|
-
update_vm_metadata(state.vm_cid, {
|
121
|
+
update_vm_metadata(state.vm_cid, { 'Name' => state.name })
|
148
122
|
discover_bosh_ip
|
149
123
|
end
|
150
124
|
save_state
|
151
125
|
|
152
|
-
step
|
126
|
+
step 'Waiting for the agent' do
|
153
127
|
begin
|
154
128
|
wait_until_agent_ready
|
155
129
|
rescue *CONNECTION_EXCEPTIONS
|
156
|
-
err
|
130
|
+
err 'Unable to connect to Bosh agent. Check logs for more details.'
|
157
131
|
end
|
158
132
|
end
|
159
133
|
|
160
|
-
step
|
134
|
+
step 'Updating persistent disk' do
|
161
135
|
update_persistent_disk
|
162
136
|
end
|
163
137
|
|
164
138
|
unless @apply_spec
|
165
|
-
step
|
139
|
+
step 'Fetching apply spec' do
|
166
140
|
@apply_spec = Specification.new(agent.release_apply_spec)
|
167
141
|
end
|
168
142
|
end
|
169
143
|
|
170
144
|
apply
|
171
145
|
|
172
|
-
step
|
146
|
+
step 'Waiting for the director' do
|
173
147
|
begin
|
174
148
|
wait_until_director_ready
|
175
149
|
rescue *CONNECTION_EXCEPTIONS
|
176
|
-
err
|
150
|
+
err 'Unable to connect to Bosh Director. Retry manually or check logs for more details.'
|
177
151
|
end
|
178
152
|
end
|
179
153
|
end
|
180
154
|
|
181
155
|
def destroy
|
182
|
-
renderer.enter_stage(
|
156
|
+
renderer.enter_stage('Delete micro BOSH', 7)
|
183
157
|
agent_stop
|
184
158
|
if state.disk_cid
|
185
159
|
step "Deleting persistent disk `#{state.disk_cid}'" do
|
@@ -193,7 +167,7 @@ module Bosh::Deployer
|
|
193
167
|
end
|
194
168
|
|
195
169
|
def update(stemcell_tgz)
|
196
|
-
renderer.enter_stage(
|
170
|
+
renderer.enter_stage('Prepare for update', 5)
|
197
171
|
agent_stop
|
198
172
|
detach_disk(state.disk_cid)
|
199
173
|
delete_vm
|
@@ -207,14 +181,14 @@ module Bosh::Deployer
|
|
207
181
|
|
208
182
|
def create_stemcell(stemcell_tgz)
|
209
183
|
unless is_tgz?(stemcell_tgz)
|
210
|
-
step
|
184
|
+
step 'Using existing stemcell' do
|
211
185
|
end
|
212
186
|
|
213
187
|
return stemcell_tgz
|
214
188
|
end
|
215
189
|
|
216
|
-
Dir.mktmpdir(
|
217
|
-
step
|
190
|
+
Dir.mktmpdir('sc-') do |stemcell|
|
191
|
+
step 'Unpacking stemcell' do
|
218
192
|
run_command("tar -zxf #{stemcell_tgz} -C #{stemcell}")
|
219
193
|
end
|
220
194
|
|
@@ -224,11 +198,11 @@ module Bosh::Deployer
|
|
224
198
|
properties = load_stemcell_manifest(stemcell)
|
225
199
|
|
226
200
|
# override with values from the deployment manifest
|
227
|
-
override = Config.cloud_options[
|
228
|
-
properties[
|
201
|
+
override = Config.cloud_options['properties']['stemcell']
|
202
|
+
properties['cloud_properties'].merge!(override) if override
|
229
203
|
|
230
|
-
step
|
231
|
-
cloud.create_stemcell("#{stemcell}/image", properties[
|
204
|
+
step 'Uploading stemcell' do
|
205
|
+
cloud.create_stemcell("#{stemcell}/image", properties['cloud_properties'])
|
232
206
|
end
|
233
207
|
end
|
234
208
|
rescue => e
|
@@ -240,7 +214,7 @@ module Bosh::Deployer
|
|
240
214
|
|
241
215
|
def create_vm(stemcell_cid)
|
242
216
|
resources = Config.resources['cloud_properties']
|
243
|
-
networks
|
217
|
+
networks = Config.networks
|
244
218
|
env = Config.env
|
245
219
|
cloud.create_vm(state.uuid, stemcell_cid, resources, networks, nil, env)
|
246
220
|
end
|
@@ -252,24 +226,24 @@ module Bosh::Deployer
|
|
252
226
|
end
|
253
227
|
|
254
228
|
def mount_disk(disk_cid)
|
255
|
-
step
|
229
|
+
step 'Mount disk' do
|
256
230
|
agent.run_task(:mount_disk, disk_cid.to_s)
|
257
231
|
end
|
258
232
|
end
|
259
233
|
|
260
234
|
def unmount_disk(disk_cid)
|
261
|
-
step
|
235
|
+
step 'Unmount disk' do
|
262
236
|
if disk_info.include?(disk_cid)
|
263
237
|
agent.run_task(:unmount_disk, disk_cid.to_s)
|
264
238
|
else
|
265
239
|
logger.error("not unmounting %s as it doesn't belong to me: %s" %
|
266
|
-
|
240
|
+
[disk_cid, disk_info])
|
267
241
|
end
|
268
242
|
end
|
269
243
|
end
|
270
244
|
|
271
245
|
def migrate_disk(src_disk_cid, dst_disk_cid)
|
272
|
-
step
|
246
|
+
step 'Migrate disk' do
|
273
247
|
agent.run_task(:migrate_disk, src_disk_cid.to_s, dst_disk_cid.to_s)
|
274
248
|
end
|
275
249
|
end
|
@@ -280,7 +254,7 @@ module Bosh::Deployer
|
|
280
254
|
end
|
281
255
|
|
282
256
|
def create_disk
|
283
|
-
step
|
257
|
+
step 'Create disk' do
|
284
258
|
size = Config.resources['persistent_disk']
|
285
259
|
state.disk_cid = cloud.create_disk(size, state.vm_cid)
|
286
260
|
save_state
|
@@ -292,14 +266,14 @@ module Bosh::Deployer
|
|
292
266
|
unmount_disk(disk_cid)
|
293
267
|
|
294
268
|
begin
|
295
|
-
step
|
269
|
+
step 'Detach disk' do
|
296
270
|
cloud.detach_disk(vm_cid, disk_cid) if vm_cid
|
297
271
|
end
|
298
272
|
rescue Bosh::Clouds::DiskNotAttached
|
299
273
|
end
|
300
274
|
|
301
275
|
begin
|
302
|
-
step
|
276
|
+
step 'Delete disk' do
|
303
277
|
cloud.delete_disk(disk_cid)
|
304
278
|
end
|
305
279
|
rescue Bosh::Clouds::DiskNotFound
|
@@ -316,11 +290,11 @@ module Bosh::Deployer
|
|
316
290
|
|
317
291
|
def detach_disk(disk_cid)
|
318
292
|
unless disk_cid
|
319
|
-
err
|
293
|
+
err 'Error: nil value given for persistent disk id'
|
320
294
|
end
|
321
295
|
|
322
296
|
unmount_disk(disk_cid)
|
323
|
-
step
|
297
|
+
step 'Detach disk' do
|
324
298
|
cloud.detach_disk(state.vm_cid, disk_cid)
|
325
299
|
end
|
326
300
|
end
|
@@ -336,8 +310,8 @@ module Bosh::Deployer
|
|
336
310
|
agent_disk_cid = disk_info.first
|
337
311
|
if agent_disk_cid != state.disk_cid
|
338
312
|
err "instance #{state.vm_cid} has invalid disk: " +
|
339
|
-
|
340
|
-
|
313
|
+
"Agent reports #{agent_disk_cid} while " +
|
314
|
+
"deployer's record shows #{state.disk_cid}"
|
341
315
|
end
|
342
316
|
end
|
343
317
|
|
@@ -376,7 +350,7 @@ module Bosh::Deployer
|
|
376
350
|
|
377
351
|
spec ||= @apply_spec
|
378
352
|
|
379
|
-
step
|
353
|
+
step 'Applying micro BOSH spec' do
|
380
354
|
# first update spec with infrastructure specific stuff
|
381
355
|
update_spec(spec)
|
382
356
|
# then update spec with generic changes
|
@@ -405,7 +379,7 @@ module Bosh::Deployer
|
|
405
379
|
end
|
406
380
|
|
407
381
|
def agent_stop
|
408
|
-
step
|
382
|
+
step 'Stopping agent services' do
|
409
383
|
begin
|
410
384
|
agent.run_task(:stop)
|
411
385
|
rescue
|
@@ -414,7 +388,7 @@ module Bosh::Deployer
|
|
414
388
|
end
|
415
389
|
|
416
390
|
def agent_start
|
417
|
-
step
|
391
|
+
step 'Starting agent services' do
|
418
392
|
agent.run_task(:start)
|
419
393
|
end
|
420
394
|
end
|
@@ -428,7 +402,7 @@ module Bosh::Deployer
|
|
428
402
|
end
|
429
403
|
|
430
404
|
def agent_port
|
431
|
-
uri = URI.parse(Config.cloud_options[
|
405
|
+
uri = URI.parse(Config.cloud_options['properties']['agent']['mbus'])
|
432
406
|
|
433
407
|
uri.port
|
434
408
|
end
|
@@ -436,14 +410,14 @@ module Bosh::Deployer
|
|
436
410
|
def wait_until_agent_ready #XXX >> agent_client
|
437
411
|
remote_tunnel(@registry_port)
|
438
412
|
|
439
|
-
wait_until_ready(
|
413
|
+
wait_until_ready('agent') { agent.ping }
|
440
414
|
end
|
441
415
|
|
442
416
|
def wait_until_director_ready
|
443
417
|
port = @apply_spec.director_port
|
444
418
|
url = "https://#{bosh_ip}:#{port}/info"
|
445
419
|
|
446
|
-
wait_until_ready(
|
420
|
+
wait_until_ready('director', 1, 600) do
|
447
421
|
|
448
422
|
http_client = HTTPClient.new
|
449
423
|
|
@@ -451,21 +425,21 @@ module Bosh::Deployer
|
|
451
425
|
http_client.ssl_config.verify_callback = Proc.new {}
|
452
426
|
|
453
427
|
response = http_client.get(url)
|
454
|
-
message =
|
455
|
-
raise
|
428
|
+
message = 'Nginx has started but the application it is proxying to has not started yet.'
|
429
|
+
raise DirectorGatewayError.new(message) if response.status == 502 || response.status == 503
|
456
430
|
info = Yajl::Parser.parse(response.body)
|
457
431
|
logger.info("Director is ready: #{info.inspect}")
|
458
432
|
end
|
459
433
|
end
|
460
434
|
|
461
435
|
def delete_stemcell
|
462
|
-
err
|
436
|
+
err 'Cannot find existing stemcell' unless state.stemcell_cid
|
463
437
|
|
464
438
|
if state.stemcell_cid == state.stemcell_name
|
465
|
-
step
|
439
|
+
step 'Preserving stemcell' do
|
466
440
|
end
|
467
441
|
else
|
468
|
-
step
|
442
|
+
step 'Delete stemcell' do
|
469
443
|
cloud.delete_stemcell(state.stemcell_cid)
|
470
444
|
end
|
471
445
|
end
|
@@ -476,9 +450,9 @@ module Bosh::Deployer
|
|
476
450
|
end
|
477
451
|
|
478
452
|
def delete_vm
|
479
|
-
err
|
453
|
+
err 'Cannot find existing VM' unless state.vm_cid
|
480
454
|
|
481
|
-
step
|
455
|
+
step 'Delete VM' do
|
482
456
|
cloud.delete_vm(state.vm_cid)
|
483
457
|
end
|
484
458
|
state.vm_cid = nil
|
@@ -491,7 +465,7 @@ module Bosh::Deployer
|
|
491
465
|
Psych.load_file(@state_yml)
|
492
466
|
else
|
493
467
|
logger.info("No existing deployments found (will save to #{@state_yml})")
|
494
|
-
{
|
468
|
+
{ 'instances' => [], 'disks' => [] }
|
495
469
|
end
|
496
470
|
end
|
497
471
|
|
@@ -520,8 +494,8 @@ module Bosh::Deployer
|
|
520
494
|
def load_state(name)
|
521
495
|
@deployments = load_deployments
|
522
496
|
|
523
|
-
disk_model.insert_multiple(@deployments[
|
524
|
-
instance_model.insert_multiple(@deployments[
|
497
|
+
disk_model.insert_multiple(@deployments['disks']) if disk_model
|
498
|
+
instance_model.insert_multiple(@deployments['instances'])
|
525
499
|
|
526
500
|
@state = instance_model.find(:name => name)
|
527
501
|
if @state.nil?
|
@@ -536,10 +510,10 @@ module Bosh::Deployer
|
|
536
510
|
|
537
511
|
def save_state
|
538
512
|
state.save
|
539
|
-
@deployments[
|
540
|
-
@deployments[
|
513
|
+
@deployments['instances'] = instance_model.map { |instance| instance.values }
|
514
|
+
@deployments['disks'] = disk_model.map { |disk| disk.values } if disk_model
|
541
515
|
|
542
|
-
File.open(@state_yml,
|
516
|
+
File.open(@state_yml, 'w') do |file|
|
543
517
|
file.write(Psych.dump(@deployments))
|
544
518
|
end
|
545
519
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Bosh::Deployer
|
2
|
+
class LoggerRenderer
|
3
|
+
attr_accessor :stage, :total, :index
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
enter_stage('Deployer', 0)
|
7
|
+
end
|
8
|
+
|
9
|
+
def enter_stage(stage, total)
|
10
|
+
@stage = stage
|
11
|
+
@total = total
|
12
|
+
@index = 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(state, task)
|
16
|
+
Config.logger.info("#{@stage} - #{state} #{task}")
|
17
|
+
@index += 1 if state == :finished
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
File without changes
|
@@ -7,7 +7,7 @@ module Bosh::Deployer
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.load_apply_spec(dir)
|
10
|
-
file =
|
10
|
+
file = 'apply_spec.yml'
|
11
11
|
apply_spec = File.join(dir, file)
|
12
12
|
unless File.exist?(apply_spec)
|
13
13
|
err "this isn't a micro bosh stemcell - #{file} missing"
|
@@ -20,7 +20,7 @@ module Bosh::Deployer
|
|
20
20
|
|
21
21
|
def initialize(spec)
|
22
22
|
@spec = spec
|
23
|
-
@properties = @spec[
|
23
|
+
@properties = @spec['properties']
|
24
24
|
end
|
25
25
|
|
26
26
|
# Update the spec with the IP of the micro bosh instance.
|
@@ -30,8 +30,8 @@ module Bosh::Deployer
|
|
30
30
|
def update(bosh_ip, service_ip)
|
31
31
|
# set the director name to what is specified in the micro_bosh.yml
|
32
32
|
if Config.name
|
33
|
-
@properties[
|
34
|
-
@properties[
|
33
|
+
@properties['director'] = {} unless @properties['director']
|
34
|
+
@properties['director']['name'] = Config.name
|
35
35
|
end
|
36
36
|
|
37
37
|
# on AWS blobstore and nats need to use an elastic IP (if available),
|
@@ -49,11 +49,11 @@ module Bosh::Deployer
|
|
49
49
|
# health monitor does not listen to any ports, so there is no
|
50
50
|
# need to update the service address, but we still want to
|
51
51
|
# be able to override values in the apply_spec
|
52
|
-
override_property(@properties,
|
52
|
+
override_property(@properties, 'hm', Config.spec_properties['hm'])
|
53
53
|
|
54
|
-
override_property(@properties,
|
55
|
-
set_property(@properties,
|
56
|
-
set_property(@properties,
|
54
|
+
override_property(@properties, 'director', Config.spec_properties['director'])
|
55
|
+
set_property(@properties, 'ntp', Config.spec_properties['ntp'])
|
56
|
+
set_property(@properties, 'compiled_package_cache', Config.spec_properties['compiled_package_cache'])
|
57
57
|
|
58
58
|
@spec
|
59
59
|
end
|
@@ -65,23 +65,23 @@ module Bosh::Deployer
|
|
65
65
|
|
66
66
|
# @return [String] the port the director runs on
|
67
67
|
def director_port
|
68
|
-
@properties[
|
68
|
+
@properties['director']['port']
|
69
69
|
end
|
70
70
|
|
71
71
|
private
|
72
72
|
|
73
73
|
# update the agent service section from the contents of the apply_spec
|
74
74
|
def update_agent_service_address(service, address)
|
75
|
-
agent = @properties[
|
75
|
+
agent = @properties['agent'] ||= {}
|
76
76
|
svc = agent[service] ||= {}
|
77
|
-
svc[
|
77
|
+
svc['address'] = address
|
78
78
|
|
79
79
|
override_property(agent, service, Config.agent_properties[service])
|
80
80
|
end
|
81
81
|
|
82
82
|
def update_service_address(service, address)
|
83
83
|
return unless @properties[service]
|
84
|
-
@properties[service][
|
84
|
+
@properties[service]['address'] = address
|
85
85
|
|
86
86
|
override_property(@properties, service, Config.spec_properties[service])
|
87
87
|
end
|