bosh_deployer 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -91,7 +91,7 @@ module Bosh::Cli::Command
91
91
  err("Invalid manifest format")
92
92
  end
93
93
 
94
- stemcell = dig_hash(manifest, "cloud", "properties", "stemcell", "image_id")
94
+ stemcell = dig_hash(manifest, "resources", "cloud_properties", "image_id")
95
95
 
96
96
  if stemcell.nil?
97
97
  err "No stemcell provided"
@@ -102,6 +102,8 @@ module Bosh::Cli::Command
102
102
 
103
103
  desc = "`#{rel_path.green}' to `#{target_name.green}'"
104
104
 
105
+ deployer.check_dependencies
106
+
105
107
  if update
106
108
  unless deployer.exists?
107
109
  err "No existing instance to update"
@@ -1,12 +1,12 @@
1
1
  # Copyright (c) 2009-2012 VMware, Inc.
2
2
 
3
- require 'net/ssh'
4
-
5
3
  module Bosh::Deployer
6
4
  class InstanceManager
7
5
 
8
6
  class Aws < InstanceManager
9
7
 
8
+ include InstanceManagerHelpers
9
+
10
10
  def update_spec(spec)
11
11
  spec = super(spec)
12
12
  properties = spec["properties"]
@@ -184,74 +184,6 @@ module Bosh::Deployer
184
184
  end
185
185
  end
186
186
 
187
- def process_exists?(pid)
188
- begin
189
- Process.kill(0, pid)
190
- rescue Errno::ESRCH
191
- false
192
- end
193
- end
194
-
195
- def socket_readable?(ip, port)
196
- socket = TCPSocket.new(ip, port)
197
- if IO.select([socket], nil, nil, 5)
198
- logger.debug("tcp socket #{ip}:#{port} is readable")
199
- yield
200
- true
201
- else
202
- false
203
- end
204
- rescue SocketError => e
205
- logger.debug("tcp socket #{ip}:#{port} SocketError: #{e.inspect}")
206
- sleep 1
207
- false
208
- rescue SystemCallError => e
209
- logger.debug("tcp socket #{ip}:#{port} SystemCallError: #{e.inspect}")
210
- sleep 1
211
- false
212
- ensure
213
- socket.close if socket
214
- end
215
-
216
- def tunnel(port)
217
- return if @session
218
-
219
- ip = discover_bosh_ip
220
-
221
- loop until socket_readable?(ip, @ssh_port) do
222
- #sshd is up, sleep while host keys are generated
223
- sleep @ssh_wait
224
- end
225
-
226
- lo = "127.0.0.1"
227
- cmd = "ssh -R #{port}:#{lo}:#{port} #{@ssh_user}@#{ip}"
228
-
229
- logger.info("Preparing for ssh tunnel: #{cmd}")
230
- loop do
231
- begin
232
- @session = Net::SSH.start(ip, @ssh_user, :keys => [@ssh_key],
233
- :paranoid => false)
234
- logger.debug("ssh #{@ssh_user}@#{ip}: ESTABLISHED")
235
- break
236
- rescue => e
237
- logger.debug("ssh start #{@ssh_user}@#{ip} failed: #{e.inspect}")
238
- sleep 1
239
- end
240
- end
241
-
242
- @session.forward.remote(port, lo, port)
243
- logger.info("`#{cmd}` started: OK")
244
-
245
- Thread.new do
246
- begin
247
- @session.loop { true }
248
- rescue IOError => e
249
- logger.debug("`#{cmd}` terminated: #{e.inspect}")
250
- @session = nil
251
- end
252
- end
253
- end
254
-
255
187
  end
256
188
  end
257
189
  end
@@ -1,12 +1,12 @@
1
1
  # Copyright (c) 2009-2012 VMware, Inc.
2
2
 
3
- require 'net/ssh'
4
-
5
3
  module Bosh::Deployer
6
4
  class InstanceManager
7
5
 
8
6
  class Openstack < InstanceManager
9
7
 
8
+ include InstanceManagerHelpers
9
+
10
10
  def update_spec(spec)
11
11
  spec = super(spec)
12
12
  properties = spec["properties"]
@@ -183,74 +183,6 @@ module Bosh::Deployer
183
183
  end
184
184
  end
185
185
 
186
- def process_exists?(pid)
187
- begin
188
- Process.kill(0, pid)
189
- rescue Errno::ESRCH
190
- false
191
- end
192
- end
193
-
194
- def socket_readable?(ip, port)
195
- socket = TCPSocket.new(ip, port)
196
- if IO.select([socket], nil, nil, 5)
197
- logger.debug("tcp socket #{ip}:#{port} is readable")
198
- yield
199
- true
200
- else
201
- false
202
- end
203
- rescue SocketError => e
204
- logger.debug("tcp socket #{ip}:#{port} SocketError: #{e.inspect}")
205
- sleep 1
206
- false
207
- rescue SystemCallError => e
208
- logger.debug("tcp socket #{ip}:#{port} SystemCallError: #{e.inspect}")
209
- sleep 1
210
- false
211
- ensure
212
- socket.close if socket
213
- end
214
-
215
- def tunnel(port)
216
- return if @session
217
-
218
- ip = discover_bosh_ip
219
-
220
- loop until socket_readable?(ip, @ssh_port) do
221
- #sshd is up, sleep while host keys are generated
222
- sleep @ssh_wait
223
- end
224
-
225
- lo = "127.0.0.1"
226
- cmd = "ssh -R #{port}:#{lo}:#{port} #{@ssh_user}@#{ip}"
227
-
228
- logger.info("Preparing for ssh tunnel: #{cmd}")
229
- loop do
230
- begin
231
- @session = Net::SSH.start(ip, @ssh_user, :keys => [@ssh_key],
232
- :paranoid => false)
233
- logger.debug("ssh #{@ssh_user}@#{ip}: ESTABLISHED")
234
- break
235
- rescue => e
236
- logger.debug("ssh start #{@ssh_user}@#{ip} failed: #{e.inspect}")
237
- sleep 1
238
- end
239
- end
240
-
241
- @session.forward.remote(port, lo, port)
242
- logger.info("`#{cmd}` started: OK")
243
-
244
- Thread.new do
245
- begin
246
- @session.loop { true }
247
- rescue IOError => e
248
- logger.debug("`#{cmd}` terminated: #{e.inspect}")
249
- @session = nil
250
- end
251
- end
252
- end
253
-
254
186
  end
255
187
  end
256
188
  end
@@ -35,5 +35,12 @@ module Bosh::Deployer
35
35
  def persistent_disk_changed?
36
36
  Config.resources['persistent_disk'] != disk_size(state.disk_cid)
37
37
  end
38
+
39
+ def check_dependencies
40
+ if Bosh::Common.which(%w[genisoimage mkisofs]).nil?
41
+ err("either of 'genisoimage' or 'mkisofs' commands must be present")
42
+ end
43
+ end
44
+
38
45
  end
39
46
  end
@@ -138,7 +138,8 @@ module Bosh::Deployer
138
138
  end
139
139
  save_state
140
140
  rescue => e
141
- delete_stemcell
141
+ # only delete the stemcell if we were trying to upload it
142
+ delete_stemcell if is_tgz?(stemcell_tgz)
142
143
  raise e
143
144
  end
144
145
 
@@ -208,7 +209,7 @@ module Bosh::Deployer
208
209
 
209
210
  # override with values from the deployment manifest
210
211
  override = Config.cloud_options["properties"]["stemcell"]
211
- properties["cloud_properties"].merge!(override) if override
212
+ override_property(properties, "cloud_properties", override)
212
213
 
213
214
  step "Uploading stemcell" do
214
215
  cloud.create_stemcell("#{stemcell}/image", properties["cloud_properties"])
@@ -300,7 +301,6 @@ module Bosh::Deployer
300
301
  def attach_missing_disk
301
302
  if state.disk_cid
302
303
  attach_disk(state.disk_cid, true)
303
- save_state
304
304
  end
305
305
  end
306
306
 
@@ -338,6 +338,7 @@ module Bosh::Deployer
338
338
  # delete the old disk
339
339
  delete_disk(old_disk_cid, state.vm_cid)
340
340
  end
341
+ ensure
341
342
  save_state
342
343
  end
343
344
 
@@ -363,6 +364,11 @@ module Bosh::Deployer
363
364
  update_service_address(properties, service, service_ip)
364
365
  end
365
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
+
366
372
  spec
367
373
  end
368
374
 
@@ -384,6 +390,10 @@ module Bosh::Deployer
384
390
  bosh_ip
385
391
  end
386
392
 
393
+ def check_dependencies
394
+ # nothing to check, move on...
395
+ end
396
+
387
397
  private
388
398
 
389
399
  # update the agent service section from the contents of the apply_spec
@@ -393,9 +403,7 @@ module Bosh::Deployer
393
403
  svc = agent[service] ||= {}
394
404
  svc["address"] = address
395
405
 
396
- if override = Config.agent_properties[service]
397
- svc.merge!(override)
398
- end
406
+ override_property(agent, service, Config.agent_properties[service])
399
407
  end
400
408
  end
401
409
 
@@ -403,9 +411,11 @@ module Bosh::Deployer
403
411
  return unless properties[service]
404
412
  properties[service]["address"] = address
405
413
 
406
- if override = Config.spec_properties[service]
407
- properties[service].merge!(override)
408
- end
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
409
419
  end
410
420
 
411
421
  def bosh_ip
@@ -0,0 +1,78 @@
1
+ # Copyright (c) 2009-2012 VMware, Inc.
2
+
3
+ require 'net/ssh'
4
+
5
+ module Bosh::Deployer
6
+
7
+ module InstanceManagerHelpers
8
+
9
+ def process_exists?(pid)
10
+ begin
11
+ Process.kill(0, pid)
12
+ rescue Errno::ESRCH
13
+ false
14
+ end
15
+ end
16
+
17
+ def socket_readable?(ip, port)
18
+ socket = TCPSocket.new(ip, port)
19
+ if IO.select([socket], nil, nil, 5)
20
+ logger.debug("tcp socket #{ip}:#{port} is readable")
21
+ yield
22
+ true
23
+ else
24
+ false
25
+ end
26
+ rescue SocketError => e
27
+ logger.debug("tcp socket #{ip}:#{port} SocketError: #{e.inspect}")
28
+ sleep 1
29
+ false
30
+ rescue SystemCallError => e
31
+ logger.debug("tcp socket #{ip}:#{port} SystemCallError: #{e.inspect}")
32
+ sleep 1
33
+ false
34
+ ensure
35
+ socket.close if socket
36
+ end
37
+
38
+ def tunnel(port)
39
+ return if @session
40
+
41
+ ip = discover_bosh_ip
42
+
43
+ loop until socket_readable?(ip, @ssh_port) do
44
+ #sshd is up, sleep while host keys are generated
45
+ sleep @ssh_wait
46
+ end
47
+
48
+ lo = "127.0.0.1"
49
+ cmd = "ssh -R #{port}:#{lo}:#{port} #{@ssh_user}@#{ip}"
50
+
51
+ logger.info("Preparing for ssh tunnel: #{cmd}")
52
+ loop do
53
+ begin
54
+ @session = Net::SSH.start(ip, @ssh_user, :keys => [@ssh_key],
55
+ :paranoid => false)
56
+ logger.debug("ssh #{@ssh_user}@#{ip}: ESTABLISHED")
57
+ break
58
+ rescue => e
59
+ logger.debug("ssh start #{@ssh_user}@#{ip} failed: #{e.inspect}")
60
+ sleep 1
61
+ end
62
+ end
63
+
64
+ @session.forward.remote(port, lo, port)
65
+ logger.info("`#{cmd}` started: OK")
66
+
67
+ Thread.new do
68
+ begin
69
+ @session.loop { true }
70
+ rescue IOError => e
71
+ logger.debug("`#{cmd}` terminated: #{e.inspect}")
72
+ @session = nil
73
+ end
74
+ end
75
+ end
76
+
77
+ end
78
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bosh
4
4
  module Deployer
5
- VERSION = "0.5.1"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
data/lib/deployer.rb CHANGED
@@ -13,6 +13,7 @@ require "tmpdir"
13
13
  require "uuidtools"
14
14
  require "yaml"
15
15
  require "yajl"
16
+ require "common/common"
16
17
  require "common/thread_formatter"
17
18
 
18
19
  require "deployer/version"
@@ -20,3 +21,4 @@ require "deployer/errors"
20
21
  require "deployer/helpers"
21
22
  require "deployer/config"
22
23
  require "deployer/instance_manager"
24
+ require "deployer/instance_manager_helpers"
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: 0.5.1
4
+ version: 0.6.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-08-13 00:00:00.000000000 Z
12
+ date: 2012-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bosh_cli
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.19.5
30
- - !ruby/object:Gem::Dependency
31
- name: bosh_common
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 0.5.0
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 0.5.0
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: bosh_cpi
48
32
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +98,7 @@ dependencies:
114
98
  requirements:
115
99
  - - ~>
116
100
  - !ruby/object:Gem::Version
117
- version: 0.0.2
101
+ version: 0.0.3
118
102
  type: :runtime
119
103
  prerelease: false
120
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +106,7 @@ dependencies:
122
106
  requirements:
123
107
  - - ~>
124
108
  - !ruby/object:Gem::Version
125
- version: 0.0.2
109
+ version: 0.0.3
126
110
  - !ruby/object:Gem::Dependency
127
111
  name: bosh_openstack_registry
128
112
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +114,7 @@ dependencies:
130
114
  requirements:
131
115
  - - ~>
132
116
  - !ruby/object:Gem::Version
133
- version: 0.0.1
117
+ version: 0.0.2
134
118
  type: :runtime
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +122,7 @@ dependencies:
138
122
  requirements:
139
123
  - - ~>
140
124
  - !ruby/object:Gem::Version
141
- version: 0.0.1
125
+ version: 0.0.2
142
126
  - !ruby/object:Gem::Dependency
143
127
  name: agent_client
144
128
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +173,7 @@ files:
189
173
  - lib/deployer/instance_manager/aws.rb
190
174
  - lib/deployer/instance_manager/openstack.rb
191
175
  - lib/deployer/instance_manager/vsphere.rb
176
+ - lib/deployer/instance_manager_helpers.rb
192
177
  - lib/deployer/models/instance.rb
193
178
  - lib/deployer/version.rb
194
179
  - README.rdoc
@@ -208,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
193
  version: '0'
209
194
  segments:
210
195
  - 0
211
- hash: -1238635242857856415
196
+ hash: -914290662432326556
212
197
  required_rubygems_version: !ruby/object:Gem::Requirement
213
198
  none: false
214
199
  requirements:
@@ -217,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
202
  version: '0'
218
203
  segments:
219
204
  - 0
220
- hash: -1238635242857856415
205
+ hash: -914290662432326556
221
206
  requirements: []
222
207
  rubyforge_project:
223
208
  rubygems_version: 1.8.24