bosh_deployer 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ module Bosh::Cli::Command
9
9
 
10
10
  MICRO_DIRECTOR_PORT = 25555
11
11
  DEFAULT_CONFIG_PATH = File.expand_path("~/.bosh_deployer_config")
12
+ MICRO_BOSH_YAML = "micro_bosh.yml"
12
13
 
13
14
  def initialize(runner)
14
15
  super(runner)
@@ -118,12 +119,12 @@ module Bosh::Cli::Command
118
119
  end
119
120
  end
120
121
 
122
+ deployer.check_dependencies
123
+
121
124
  rel_path = deployment[/#{Regexp.escape File.join(work_dir, '')}(.*)/, 1]
122
125
 
123
126
  desc = "`#{rel_path.green}' to `#{target_name.green}'"
124
127
 
125
- deployer.check_dependencies
126
-
127
128
  if update
128
129
  unless deployer.exists?
129
130
  err "No existing instance to update"
@@ -139,7 +140,7 @@ module Bosh::Cli::Command
139
140
 
140
141
  # make sure the user knows a persistent disk is required
141
142
  unless dig_hash(manifest, "resources", "persistent_disk")
142
- quit("No persistent disk configured!".red)
143
+ quit("No persistent disk configured in #{MICRO_BOSH_YAML}".red)
143
144
  end
144
145
 
145
146
  confirmation = "Deploying new"
@@ -296,16 +297,20 @@ module Bosh::Cli::Command
296
297
 
297
298
  def find_deployment(name)
298
299
  check_if_deployments_dir
299
- File.expand_path(File.join(work_dir, "#{name}", "micro_bosh.yml"))
300
+ File.expand_path(File.join(work_dir, "#{name}", MICRO_BOSH_YAML))
300
301
  end
301
302
 
302
303
  def deployment_name
303
304
  File.basename(File.dirname(deployment))
304
305
  end
305
306
 
307
+ # set new target and clear out cached values
308
+ # does not persist the new values (set_current() does this)
306
309
  def set_target(ip)
307
310
  config.target = "http://#{ip}:#{MICRO_DIRECTOR_PORT}"
308
- config.save
311
+ config.target_name = nil
312
+ config.target_version = nil
313
+ config.target_uuid = nil
309
314
  end
310
315
 
311
316
  def update_target
data/lib/deployer.rb CHANGED
@@ -19,5 +19,6 @@ require "common/thread_formatter"
19
19
  require "deployer/version"
20
20
  require "deployer/helpers"
21
21
  require "deployer/config"
22
+ require "deployer/specification"
22
23
  require "deployer/instance_manager"
23
24
  require "deployer/instance_manager_helpers"
@@ -106,6 +106,13 @@ module Bosh::Deployer
106
106
  @networks
107
107
  end
108
108
 
109
+ def task_checkpoint
110
+ # Bosh::Clouds::Config (bosh_cli >= 0.5.1) delegates task_checkpoint
111
+ # method to periodically check if director task is cancelled,
112
+ # so we need to define a void method in Bosh::Deployer::Config to avoid
113
+ # NoMethodError exceptions.
114
+ end
115
+
109
116
  private
110
117
 
111
118
  def migrate_cpi
@@ -151,11 +151,11 @@ module Bosh::Deployer
151
151
 
152
152
  unless @apply_spec
153
153
  step "Fetching apply spec" do
154
- @apply_spec = agent.release_apply_spec
154
+ @apply_spec = Specification.new(agent.release_apply_spec)
155
155
  end
156
156
  end
157
157
 
158
- apply(@apply_spec)
158
+ apply
159
159
 
160
160
  step "Waiting for the director" do
161
161
  wait_until_director_ready
@@ -163,12 +163,14 @@ module Bosh::Deployer
163
163
  end
164
164
 
165
165
  def destroy
166
- renderer.enter_stage("Delete micro BOSH", 6)
166
+ renderer.enter_stage("Delete micro BOSH", 7)
167
167
  agent_stop
168
168
  if state.disk_cid
169
- delete_disk(state.disk_cid, state.vm_cid)
170
- state.disk_cid = nil
171
- save_state
169
+ step "Deleting persistent disk `#{state.disk_cid}'" do
170
+ delete_disk(state.disk_cid, state.vm_cid)
171
+ state.disk_cid = nil
172
+ save_state
173
+ end
172
174
  end
173
175
  delete_vm
174
176
  delete_stemcell
@@ -200,14 +202,14 @@ module Bosh::Deployer
200
202
  run_command("tar -zxf #{stemcell_tgz} -C #{stemcell}")
201
203
  end
202
204
 
203
- @apply_spec = load_apply_spec(stemcell)
205
+ @apply_spec = Specification.load_from_stemcell(stemcell)
204
206
 
205
207
  # load properties from stemcell manifest
206
208
  properties = load_stemcell_manifest(stemcell)
207
209
 
208
210
  # override with values from the deployment manifest
209
211
  override = Config.cloud_options["properties"]["stemcell"]
210
- override_property(properties, "cloud_properties", override)
212
+ properties["cloud_properties"].merge!(override) if override
211
213
 
212
214
  step "Uploading stemcell" do
213
215
  cloud.create_stemcell("#{stemcell}/image", properties["cloud_properties"])
@@ -287,7 +289,7 @@ module Bosh::Deployer
287
289
 
288
290
  def detach_disk(disk_cid)
289
291
  unless disk_cid
290
- err "Error while detaching disk: unknown disk attached to instance"
292
+ err "Error: nil value given for persistent disk id"
291
293
  end
292
294
 
293
295
  unmount_disk(disk_cid)
@@ -342,41 +344,12 @@ module Bosh::Deployer
342
344
  save_state
343
345
  end
344
346
 
345
- def update_spec(spec)
346
- properties = spec["properties"]
347
-
348
- # set the director name to what is specified in the micro_bosh.yml
349
- if Config.name
350
- properties["director"] = {} unless properties["director"]
351
- properties["director"]["name"] = Config.name
352
- end
353
-
354
- # blobstore and nats need to use an elastic IP (if available),
355
- # as when the micro bosh instance is re-created during a
356
- # deployment, it might get a new private IP
357
- %w{blobstore nats}.each do |service|
358
- update_agent_service_address(properties, service, bosh_ip)
359
- end
360
-
361
- services = %w{postgres director redis blobstore nats aws_registry
362
- openstack_registry powerdns}
363
- services.each do |service|
364
- update_service_address(properties, service, service_ip)
365
- end
366
-
367
- # health monitor does not listen to any ports, so there is no
368
- # need to update the service address, but we still want to
369
- # be able to override values in the apply_spec
370
- override_property(properties, "hm", Config.spec_properties["hm"])
371
-
372
- spec
373
- end
374
-
375
- def apply(spec)
347
+ def apply
376
348
  agent_stop
377
349
 
378
350
  step "Applying micro BOSH spec" do
379
- agent.run_task(:apply, update_spec(spec.dup))
351
+ update_spec(@apply_spec)
352
+ agent.run_task(:apply, @apply_spec.update(bosh_ip, service_ip))
380
353
  end
381
354
 
382
355
  agent_start
@@ -396,28 +369,6 @@ module Bosh::Deployer
396
369
 
397
370
  private
398
371
 
399
- # update the agent service section from the contents of the apply_spec
400
- def update_agent_service_address(properties, service, address)
401
- if Config.agent_properties
402
- agent = properties["agent"] ||= {}
403
- svc = agent[service] ||= {}
404
- svc["address"] = address
405
-
406
- override_property(agent, service, Config.agent_properties[service])
407
- end
408
- end
409
-
410
- def update_service_address(properties, service, address)
411
- return unless properties[service]
412
- properties[service]["address"] = address
413
-
414
- override_property(properties, service, Config.spec_properties[service])
415
- end
416
-
417
- def override_property(properties, service, override)
418
- properties[service].merge!(override) if override
419
- end
420
-
421
372
  def bosh_ip
422
373
  Config.bosh_ip
423
374
  end
@@ -456,7 +407,7 @@ module Bosh::Deployer
456
407
  end
457
408
 
458
409
  def wait_until_director_ready
459
- port = @apply_spec["properties"]["director"]["port"]
410
+ port = @apply_spec.director_port
460
411
  url = "http://#{bosh_ip}:#{port}/info"
461
412
  wait_until_ready do
462
413
  info = Yajl::Parser.parse(HTTPClient.new.get(url).body)
@@ -501,6 +452,7 @@ module Bosh::Deployer
501
452
  end
502
453
  end
503
454
 
455
+ # TODO remove
504
456
  def load_apply_spec(dir)
505
457
  load_spec("#{dir}/apply_spec.yml") do
506
458
  err "this isn't a micro bosh stemcell - apply_spec.yml missing"
@@ -7,9 +7,9 @@ module Bosh::Deployer
7
7
 
8
8
  include InstanceManagerHelpers
9
9
 
10
+ # TODO extract
10
11
  def update_spec(spec)
11
- spec = super(spec)
12
- properties = spec["properties"]
12
+ properties = spec.properties
13
13
 
14
14
  properties["aws"] =
15
15
  Config.spec_properties["aws"] ||
@@ -19,8 +19,6 @@ module Bosh::Deployer
19
19
  properties["aws"]["stemcell"] = Config.cloud_options["properties"]["stemcell"]
20
20
 
21
21
  spec.delete("networks")
22
-
23
- spec
24
22
  end
25
23
 
26
24
  def configure
@@ -7,9 +7,9 @@ module Bosh::Deployer
7
7
 
8
8
  include InstanceManagerHelpers
9
9
 
10
+ # TODO extract
10
11
  def update_spec(spec)
11
- spec = super(spec)
12
- properties = spec["properties"]
12
+ properties = spec.properties
13
13
 
14
14
  properties["openstack"] =
15
15
  Config.spec_properties["openstack"] ||
@@ -19,8 +19,6 @@ module Bosh::Deployer
19
19
  properties["openstack"]["stemcell"] = Config.cloud_options["properties"]["stemcell"]
20
20
 
21
21
  spec.delete("networks")
22
-
23
- spec
24
22
  end
25
23
 
26
24
  def configure
@@ -5,17 +5,15 @@ module Bosh::Deployer
5
5
 
6
6
  class Vcloud < InstanceManager
7
7
 
8
+ # TODO extract
8
9
  def update_spec(spec)
9
- spec = super(spec)
10
- properties = spec["properties"]
10
+ properties = spec.properties
11
11
 
12
12
  properties["vcd"] =
13
13
  Config.spec_properties["vcd"] ||
14
14
  Config.cloud_options["properties"]["vcds"].first.dup
15
15
 
16
16
  properties["vcd"]["address"] ||= properties["vcd"]["url"]
17
-
18
- spec
19
17
  end
20
18
 
21
19
  # @return [Integer] size in MiB
@@ -13,17 +13,15 @@ module Bosh::Deployer
13
13
  @disk_model
14
14
  end
15
15
 
16
+ # TODO extract
16
17
  def update_spec(spec)
17
- spec = super(spec)
18
- properties = spec["properties"]
18
+ properties = spec.properties
19
19
 
20
20
  properties["vcenter"] =
21
21
  Config.spec_properties["vcenter"] ||
22
22
  Config.cloud_options["properties"]["vcenters"].first.dup
23
23
 
24
24
  properties["vcenter"]["address"] ||= properties["vcenter"]["host"]
25
-
26
- spec
27
25
  end
28
26
  end
29
27
 
@@ -0,0 +1,103 @@
1
+ module Bosh::Deployer
2
+ class Specification
3
+
4
+ def self.load_from_stemcell(dir)
5
+ spec = load_apply_spec(dir)
6
+ Specification.new(spec)
7
+ end
8
+
9
+ def self.load_apply_spec(dir)
10
+ file = "apply_spec.yml"
11
+ apply_spec = File.join(dir, file)
12
+ unless File.exist?(apply_spec)
13
+ err "this isn't a micro bosh stemcell - #{file} missing"
14
+ end
15
+ YAML.load_file(apply_spec)
16
+ end
17
+
18
+ attr_accessor :spec
19
+ attr_accessor :properties
20
+
21
+ def initialize(spec)
22
+ @spec = spec
23
+ @properties = @spec["properties"]
24
+ end
25
+
26
+ # Update the spec with the IP of the micro bosh instance.
27
+ # @param [String] bosh_ip IP address of the micro bosh VM
28
+ # @param [String] service_ip private IP of the micro bosh VM on AWS/OS,
29
+ # or the same as the bosh_ip if vSphere/vCloud
30
+ def update(bosh_ip, service_ip)
31
+ # set the director name to what is specified in the micro_bosh.yml
32
+ if Config.name
33
+ @properties["director"] = {} unless @properties["director"]
34
+ @properties["director"]["name"] = Config.name
35
+ end
36
+
37
+ # on AWS blobstore and nats need to use an elastic IP (if available),
38
+ # as when the micro bosh instance is re-created during a deployment,
39
+ # it might get a new private IP
40
+ %w{blobstore nats}.each do |service|
41
+ update_agent_service_address(service, bosh_ip)
42
+ end
43
+
44
+ services = %w{postgres director redis blobstore nats aws_registry
45
+ openstack_registry powerdns}
46
+ services.each do |service|
47
+ update_service_address(service, service_ip)
48
+ end
49
+
50
+ # health monitor does not listen to any ports, so there is no
51
+ # need to update the service address, but we still want to
52
+ # be able to override values in the apply_spec
53
+ override_property(@properties, "hm", Config.spec_properties["hm"])
54
+
55
+ # TODO this override should be made more generic
56
+ if Config.spec_properties.has_key?("ntp")
57
+ @properties["agent"] ||= {}
58
+ @properties["agent"]["ntp"] = Config.spec_properties["ntp"]
59
+ end
60
+
61
+ # TODO: this override is ugly (aws-specific) but needed for aws_registry
62
+ if Config.spec_properties["aws"] ||
63
+ Config.cloud_options["properties"]["aws"]
64
+ @properties["aws"] = Config.spec_properties["aws"] ||
65
+ Config.cloud_options["properties"]["aws"]
66
+ end
67
+
68
+ @spec
69
+ end
70
+
71
+ # @param [String] name property name to delete from the spec
72
+ def delete(name)
73
+ @spec.delete(name)
74
+ end
75
+
76
+ # @return [String] the port the director runs on
77
+ def director_port
78
+ @properties["director"]["port"]
79
+ end
80
+
81
+ private
82
+
83
+ # update the agent service section from the contents of the apply_spec
84
+ def update_agent_service_address(service, address)
85
+ agent = @properties["agent"] ||= {}
86
+ svc = agent[service] ||= {}
87
+ svc["address"] = address
88
+
89
+ override_property(agent, service, Config.agent_properties[service])
90
+ end
91
+
92
+ def update_service_address(service, address)
93
+ return unless @properties[service]
94
+ @properties[service]["address"] = address
95
+
96
+ override_property(@properties, service, Config.spec_properties[service])
97
+ end
98
+
99
+ def override_property(properties, service, override)
100
+ properties[service].merge!(override) if override
101
+ end
102
+ end
103
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bosh
4
4
  module Deployer
5
- VERSION = "1.3.0"
5
+ VERSION = "1.4.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.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: 2012-12-05 00:00:00.000000000 Z
12
+ date: 2013-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bosh_cli
@@ -32,17 +32,17 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 0.5.0
37
+ version: 0.5.1
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 0.5.0
45
+ version: 0.5.1
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: bosh_vcloud_cpi
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 0.4.8
53
+ version: 0.4.9
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 0.4.8
61
+ version: 0.4.9
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: bosh_vsphere_cpi
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -80,17 +80,17 @@ dependencies:
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ~>
83
+ - - ! '>='
84
84
  - !ruby/object:Gem::Version
85
- version: 0.6.2
85
+ version: 0.7.0
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ~>
91
+ - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
- version: 0.6.2
93
+ version: 0.7.0
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: bosh_aws_registry
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 0.0.3
117
+ version: 0.0.6
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: 0.0.3
125
+ version: 0.0.6
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: bosh_openstack_registry
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 0.0.2
133
+ version: 0.0.5
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: 0.0.2
141
+ version: 0.0.5
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: agent_client
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +192,7 @@ files:
192
192
  - lib/deployer/instance_manager/vsphere.rb
193
193
  - lib/deployer/instance_manager_helpers.rb
194
194
  - lib/deployer/models/instance.rb
195
+ - lib/deployer/specification.rb
195
196
  - lib/deployer/version.rb
196
197
  - README.rdoc
197
198
  - Rakefile
@@ -208,17 +209,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
209
  - - ! '>='
209
210
  - !ruby/object:Gem::Version
210
211
  version: '0'
212
+ segments:
213
+ - 0
214
+ hash: -132721875164071695
211
215
  required_rubygems_version: !ruby/object:Gem::Requirement
212
216
  none: false
213
217
  requirements:
214
218
  - - ! '>='
215
219
  - !ruby/object:Gem::Version
216
220
  version: '0'
221
+ segments:
222
+ - 0
223
+ hash: -132721875164071695
217
224
  requirements: []
218
225
  rubyforge_project:
219
- rubygems_version: 1.8.23
226
+ rubygems_version: 1.8.24
220
227
  signing_key:
221
228
  specification_version: 3
222
229
  summary: Micro BOSH Deployer
223
230
  test_files: []
224
- has_rdoc: