bosh-director 1.1840.0 → 1.1858.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ Sequel.migration do
2
+ change do
3
+ add_column :director_attributes, :temp_name, String, null: true
4
+ self[:director_attributes].update(temp_name: :name)
5
+
6
+ alter_table :director_attributes do
7
+ drop_column :name
8
+ rename_column :temp_name, :name
9
+ add_index [:name], unique:true, name: 'unique_attribute_name'
10
+ set_column_not_null :name
11
+
12
+ add_primary_key :id
13
+ end
14
+ end
15
+ end
@@ -53,16 +53,16 @@ module Bosh::Director
53
53
  def bind_existing_vm(vm, lock)
54
54
  state = get_state(vm)
55
55
  lock.synchronize do
56
- @logger.debug("Processing network reservations")
56
+ @logger.debug('Processing network reservations')
57
57
  reservations = get_network_reservations(state)
58
58
 
59
59
  instance = vm.instance
60
60
  if instance
61
61
  bind_instance(instance, state, reservations)
62
62
  else
63
- @logger.debug("Binding resource pool VM")
63
+ @logger.debug('Binding resource pool VM')
64
64
  resource_pool = @deployment_plan.resource_pool(
65
- state["resource_pool"]["name"])
65
+ state['resource_pool']['name'])
66
66
  if resource_pool
67
67
  bind_idle_vm(vm, resource_pool, state, reservations)
68
68
  else
@@ -70,7 +70,7 @@ module Bosh::Director
70
70
  @deployment_plan.delete_vm(vm)
71
71
  end
72
72
  end
73
- @logger.debug("Finished binding VM")
73
+ @logger.debug('Finished binding VM')
74
74
  end
75
75
  end
76
76
 
@@ -80,7 +80,7 @@ module Bosh::Director
80
80
  # @param [Hash] state VM state according to its agent
81
81
  # @param [Hash] reservations Network reservations
82
82
  def bind_idle_vm(vm, resource_pool, state, reservations)
83
- @logger.debug("Adding to resource pool")
83
+ @logger.debug('Adding to resource pool')
84
84
  idle_vm = resource_pool.add_idle_vm
85
85
  idle_vm.vm = vm
86
86
  idle_vm.current_state = state
@@ -88,7 +88,7 @@ module Bosh::Director
88
88
  reservation = reservations[resource_pool.network.name]
89
89
  if reservation
90
90
  if reservation.static?
91
- @logger.debug("Releasing static network reservation for " +
91
+ @logger.debug('Releasing static network reservation for ' +
92
92
  "resource pool VM `#{vm.cid}'")
93
93
  resource_pool.network.release(reservation)
94
94
  else
@@ -103,12 +103,12 @@ module Bosh::Director
103
103
  # @param [Hash] state Instance state according to agent
104
104
  # @param [Hash] reservations Instance network reservations
105
105
  def bind_instance(instance_model, state, reservations)
106
- @logger.debug("Binding instance VM")
106
+ @logger.debug('Binding instance VM')
107
107
 
108
108
  # Update instance, if we are renaming a job.
109
109
  if @deployment_plan.rename_in_progress?
110
- old_name = @deployment_plan.job_rename["old_name"]
111
- new_name = @deployment_plan.job_rename["new_name"]
110
+ old_name = @deployment_plan.job_rename['old_name']
111
+ new_name = @deployment_plan.job_rename['new_name']
112
112
 
113
113
  if instance_model.job == old_name
114
114
  @logger.info("Renaming `#{old_name}' to `#{new_name}'")
@@ -120,27 +120,27 @@ module Bosh::Director
120
120
  if (job = @deployment_plan.job(instance_model.job)) &&
121
121
  (instance = job.instance(instance_model.index))
122
122
 
123
- @logger.debug("Found job and instance spec")
123
+ @logger.debug('Found job and instance spec')
124
124
  instance.use_model(instance_model)
125
125
  instance.current_state = state
126
126
 
127
- @logger.debug("Copying network reservations")
127
+ @logger.debug('Copying network reservations')
128
128
  instance.take_network_reservations(reservations)
129
129
 
130
- @logger.debug("Copying resource pool reservation")
130
+ @logger.debug('Copying resource pool reservation')
131
131
  job.resource_pool.mark_active_vm
132
132
  else
133
- @logger.debug("Job/instance not found, marking for deletion")
133
+ @logger.debug('Job/instance not found, marking for deletion')
134
134
  @deployment_plan.delete_instance(instance_model)
135
135
  end
136
136
  end
137
137
 
138
138
  def get_network_reservations(state)
139
139
  reservations = {}
140
- state["networks"].each do |name, network_config|
140
+ state['networks'].each do |name, network_config|
141
141
  network = @deployment_plan.network(name)
142
142
  if network
143
- reservation = NetworkReservation.new(:ip => network_config["ip"])
143
+ reservation = NetworkReservation.new(:ip => network_config['ip'])
144
144
  network.reserve(reservation)
145
145
  reservations[name] = reservation if reservation.reserved?
146
146
  end
@@ -155,9 +155,13 @@ module Bosh::Director
155
155
 
156
156
  @logger.debug("Received VM state: #{state.pretty_inspect}")
157
157
  verify_state(vm, state)
158
- @logger.debug("Verified VM state")
158
+ @logger.debug('Verified VM state')
159
159
 
160
160
  migrate_legacy_state(vm, state)
161
+ state.delete('release')
162
+ if state.include?('job')
163
+ state['job'].delete('release')
164
+ end
161
165
  state
162
166
  end
163
167
 
@@ -179,38 +183,38 @@ module Bosh::Director
179
183
  "expected Hash, got #{state.class}"
180
184
  end
181
185
 
182
- actual_deployment_name = state["deployment"]
186
+ actual_deployment_name = state['deployment']
183
187
  expected_deployment_name = @deployment_plan.name
184
188
 
185
189
  if actual_deployment_name != expected_deployment_name
186
190
  raise AgentWrongDeployment,
187
191
  "VM `#{vm.cid}' is out of sync: " +
188
- "expected to be a part of deployment " +
192
+ 'expected to be a part of deployment ' +
189
193
  "`#{expected_deployment_name}' " +
190
- "but is actually a part of deployment " +
194
+ 'but is actually a part of deployment ' +
191
195
  "`#{actual_deployment_name}'"
192
196
  end
193
197
 
194
- actual_job = state["job"].is_a?(Hash) ? state["job"]["name"] : nil
195
- actual_index = state["index"]
198
+ actual_job = state['job'].is_a?(Hash) ? state['job']['name'] : nil
199
+ actual_index = state['index']
196
200
 
197
201
  if instance.nil? && !actual_job.nil?
198
202
  raise AgentUnexpectedJob,
199
203
  "VM `#{vm.cid}' is out of sync: " +
200
204
  "it reports itself as `#{actual_job}/#{actual_index}' but " +
201
- "there is no instance reference in DB"
205
+ 'there is no instance reference in DB'
202
206
  end
203
207
 
204
208
  if instance &&
205
209
  (instance.job != actual_job || instance.index != actual_index)
206
210
  # Check if we are resuming a previously unfinished rename
207
- if actual_job == @deployment_plan.job_rename["old_name"] &&
208
- instance.job == @deployment_plan.job_rename["new_name"] &&
211
+ if actual_job == @deployment_plan.job_rename['old_name'] &&
212
+ instance.job == @deployment_plan.job_rename['new_name'] &&
209
213
  instance.index == actual_index
210
214
 
211
215
  # Rename already happened in the DB but then something happened
212
216
  # and agent has never been updated.
213
- unless @deployment_plan.job_rename["force"]
217
+ unless @deployment_plan.job_rename['force']
214
218
  raise AgentRenameInProgress,
215
219
  "Found a job `#{actual_job}' that seems to be " +
216
220
  "in the middle of a rename to `#{instance.job}'. " +
@@ -235,7 +239,7 @@ module Bosh::Director
235
239
 
236
240
  instance = vm.instance
237
241
  if instance
238
- disk_size = state["persistent_disk"].to_i
242
+ disk_size = state['persistent_disk'].to_i
239
243
  persistent_disk = instance.persistent_disk
240
244
 
241
245
  # This is to support legacy deployments where we did not have
@@ -331,12 +335,12 @@ module Bosh::Director
331
335
 
332
336
  def bind_dns
333
337
  domain = Models::Dns::Domain.find_or_create(:name => dns_domain_name,
334
- :type => "NATIVE")
338
+ :type => 'NATIVE')
335
339
  @deployment_plan.dns_domain = domain
336
340
 
337
341
  soa_record = Models::Dns::Record.find_or_create(:domain_id => domain.id,
338
342
  :name => dns_domain_name,
339
- :type => "SOA")
343
+ :type => 'SOA')
340
344
  soa_record.content = SOA
341
345
  soa_record.ttl = 300
342
346
  soa_record.save
@@ -350,7 +354,7 @@ module Bosh::Director
350
354
  Models::Dns::Record.find_or_create(:domain_id => domain.id,
351
355
  :name => dns_ns_record,
352
356
  :type =>'A', :ttl => TTL_4H,
353
- :content => Config.dns["address"])
357
+ :content => Config.dns['address'])
354
358
  end
355
359
 
356
360
  def bind_instance_vms
@@ -359,7 +363,7 @@ module Bosh::Director
359
363
  @deployment_plan.jobs.each do |job|
360
364
  job.instances.each do |instance|
361
365
  # Don't allocate resource pool VMs to instances in detached state
362
- next if instance.state == "detached"
366
+ next if instance.state == 'detached'
363
367
  # Skip bound instances
364
368
  next if instance.model.vm
365
369
  unbound_instances << instance
@@ -368,7 +372,7 @@ module Bosh::Director
368
372
 
369
373
  return if unbound_instances.empty?
370
374
 
371
- @event_log.begin_stage("Binding instance VMs", unbound_instances.size)
375
+ @event_log.begin_stage('Binding instance VMs', unbound_instances.size)
372
376
 
373
377
  ThreadPool.new(:max_threads => Config.max_threads).wrap do |pool|
374
378
  unbound_instances.each do |instance|
@@ -407,11 +411,11 @@ module Bosh::Director
407
411
  def delete_unneeded_vms
408
412
  unneeded_vms = @deployment_plan.unneeded_vms
409
413
  if unneeded_vms.empty?
410
- @logger.info("No unneeded vms to delete")
414
+ @logger.info('No unneeded vms to delete')
411
415
  return
412
416
  end
413
417
 
414
- @event_log.begin_stage("Deleting unneeded VMs", unneeded_vms.size)
418
+ @event_log.begin_stage('Deleting unneeded VMs', unneeded_vms.size)
415
419
  ThreadPool.new(:max_threads => Config.max_threads).wrap do |pool|
416
420
  unneeded_vms.each do |vm|
417
421
  pool.process do
@@ -428,14 +432,14 @@ module Bosh::Director
428
432
  def delete_unneeded_instances
429
433
  unneeded_instances = @deployment_plan.unneeded_instances
430
434
  if unneeded_instances.empty?
431
- @logger.info("No unneeded instances to delete")
435
+ @logger.info('No unneeded instances to delete')
432
436
  return
433
437
  end
434
438
 
435
- event_log_stage = @event_log.begin_stage("Deleting unneeded instances", unneeded_instances.size)
439
+ event_log_stage = @event_log.begin_stage('Deleting unneeded instances', unneeded_instances.size)
436
440
  instance_deleter = InstanceDeleter.new(@deployment_plan)
437
441
  instance_deleter.delete_instances(unneeded_instances, event_log_stage)
438
- @logger.info("Deleted no longer needed instances")
442
+ @logger.info('Deleted no longer needed instances')
439
443
  end
440
444
  end
441
445
  end
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Director
4
2
  module DeploymentPlan
5
3
  ##
@@ -27,7 +25,7 @@ module Bosh::Director
27
25
 
28
26
  def current_state
29
27
  if @current_state
30
- @current_state.delete("release")
28
+ @current_state.delete('release')
31
29
  end
32
30
  @current_state
33
31
  end
@@ -76,7 +74,7 @@ module Bosh::Director
76
74
  else
77
75
  unless @network_reservation
78
76
  raise NetworkReservationMissing,
79
- "Missing network reservation for resource pool VM"
77
+ 'Missing network reservation for resource pool VM'
80
78
  end
81
79
 
82
80
  network_settings = {}
@@ -91,14 +89,14 @@ module Bosh::Director
91
89
  # @return [Boolean] returns true if the expected network configuration
92
90
  # differs from the one provided by the VM
93
91
  def networks_changed?
94
- network_settings != @current_state["networks"]
92
+ network_settings != @current_state['networks']
95
93
  end
96
94
 
97
95
  ##
98
96
  # @return [Boolean] returns true if the expected resource pool
99
97
  # specification differs from the one provided by the VM
100
98
  def resource_pool_changed?
101
- return true if resource_pool.spec != @current_state["resource_pool"]
99
+ return true if resource_pool.spec != @current_state['resource_pool']
102
100
  return true if resource_pool.deployment_plan.recreate
103
101
  return true if @vm && @vm.env != resource_pool.env
104
102
 
@@ -1,3 +1,5 @@
1
+ require 'bosh/director/rendered_job_instance'
2
+
1
3
  module Bosh::Director
2
4
  class JobInstanceRenderer
3
5
  def initialize(job, job_template_loader)
@@ -6,10 +8,12 @@ module Bosh::Director
6
8
  end
7
9
 
8
10
  def render(instance)
9
- job.templates.map do |template|
11
+ rendered_templates = job.templates.map do |template|
10
12
  job_template_renderer = job_template_renderers[template.name]
11
13
  job_template_renderer.render(job.name, instance)
12
14
  end
15
+
16
+ RenderedJobInstance.new(rendered_templates)
13
17
  end
14
18
 
15
19
  private
@@ -1,27 +1,37 @@
1
1
  require 'bosh/director/job_template_loader'
2
2
  require 'bosh/director/job_instance_renderer'
3
- require 'bosh/director/rendered_job_instance_hasher'
4
- require 'bosh/director/rendered_job_templates_persister'
5
3
 
6
4
  module Bosh::Director
7
5
  class JobRenderer
8
6
  # @param [DeploymentPlan::Job]
9
7
  def initialize(job)
10
8
  @job = job
11
- job_template_loader = JobTemplateLoader.new
9
+ job_template_loader = JobTemplateLoader.new(Config.logger)
12
10
  @instance_renderer = JobInstanceRenderer.new(@job, job_template_loader)
13
11
  end
14
12
 
15
13
  def render_job_instances(blobstore)
16
14
  @job.instances.each do |instance|
17
- rendered_templates = @instance_renderer.render(instance)
15
+ rendered_job_instance = @instance_renderer.render(instance)
18
16
 
19
- hasher = RenderedJobInstanceHasher.new(rendered_templates)
20
- instance.configuration_hash = hasher.configuration_hash
21
- instance.template_hashes = hasher.template_hashes
17
+ configuration_hash = rendered_job_instance.configuration_hash
22
18
 
23
- persister = RenderedJobTemplatesPersister.new(blobstore)
24
- persister.persist(instance, rendered_templates)
19
+ archive_model = instance.model.latest_rendered_templates_archive
20
+ if archive_model && archive_model.content_sha1 == configuration_hash
21
+ rendered_templates_archive = DeploymentPlan::RenderedTemplatesArchive.new(archive_model.blobstore_id, archive_model.sha1)
22
+ else
23
+ rendered_templates_archive = rendered_job_instance.persist(blobstore)
24
+ instance.model.add_rendered_templates_archive(
25
+ blobstore_id: rendered_templates_archive.blobstore_id,
26
+ sha1: rendered_templates_archive.sha1,
27
+ content_sha1: configuration_hash,
28
+ created_at: Time.now,
29
+ )
30
+ end
31
+
32
+ instance.configuration_hash = configuration_hash
33
+ instance.template_hashes = rendered_job_instance.template_hashes
34
+ instance.rendered_templates_archive = rendered_templates_archive
25
35
  end
26
36
  end
27
37
  end
@@ -4,6 +4,10 @@ module Bosh::Director
4
4
  SrcFileTemplate = Struct.new(:src_name, :dest_name, :erb_file)
5
5
 
6
6
  class JobTemplateLoader
7
+ def initialize(logger)
8
+ @logger = logger
9
+ end
10
+
7
11
  def process(job_template)
8
12
  template_dir = extract_template(job_template)
9
13
  manifest = Psych.load_file(File.join(template_dir, 'job.MF'))
@@ -19,13 +23,15 @@ module Bosh::Director
19
23
  templates << SrcFileTemplate.new(src_name, dest_name, erb_file)
20
24
  end
21
25
 
22
- JobTemplateRenderer.new(job_template.name, monit_template, templates)
26
+ JobTemplateRenderer.new(job_template.name, monit_template, templates, logger)
23
27
  ensure
24
28
  FileUtils.rm_rf(template_dir) if template_dir
25
29
  end
26
30
 
27
31
  private
28
32
 
33
+ attr_reader :logger
34
+
29
35
  def extract_template(job_template)
30
36
  temp_path = job_template.download_blob
31
37
  template_dir = Dir.mktmpdir('template_dir')
@@ -6,11 +6,11 @@ module Bosh::Director
6
6
 
7
7
  attr_reader :monit_template, :templates
8
8
 
9
- def initialize(name, monit_template, templates)
9
+ def initialize(name, monit_template, templates, logger)
10
10
  @name = name
11
11
  @monit_template = monit_template
12
12
  @templates = templates
13
- @logger = Config.logger
13
+ @logger = logger
14
14
  end
15
15
 
16
16
  def render(job_name, instance)
@@ -28,14 +28,12 @@ module Bosh::Director
28
28
 
29
29
  private
30
30
 
31
- private
32
-
33
- attr_reader :name
31
+ attr_reader :name, :logger
34
32
 
35
33
  def render_erb(job_name, template, template_context, index)
36
34
  template.result(template_context.get_binding)
37
35
  rescue Exception => e
38
- @logger.debug(e.inspect)
36
+ logger.debug(e.inspect)
39
37
  job_desc = "#{job_name}/#{index}"
40
38
  line_index = e.backtrace.index { |l| l.include?(template.filename) }
41
39
  line = line_index ? e.backtrace[line_index] : '(unknown):(unknown)'
@@ -44,7 +42,7 @@ module Bosh::Director
44
42
  message = "Error filling in template `#{File.basename(template_name)}' " +
45
43
  "for `#{job_desc}' (line #{line}: #{e})"
46
44
 
47
- @logger.debug("#{message}\n#{e.backtrace.join("\n")}")
45
+ logger.debug("#{message}\n#{e.backtrace.join("\n")}")
48
46
 
49
47
  raise JobTemplateBindingFailed, "#{message}"
50
48
  end
@@ -1,5 +1,10 @@
1
+ require 'bosh/director/deployment_plan/rendered_templates_archive'
2
+ require 'bosh/director/compressed_rendered_job_templates'
3
+ require 'digest/sha1'
4
+ require 'tempfile'
5
+
1
6
  module Bosh::Director
2
- class RenderedJobInstanceHasher
7
+ class RenderedJobInstance
3
8
  def initialize(job_templates)
4
9
  @job_templates = job_templates
5
10
  end
@@ -25,6 +30,18 @@ module Bosh::Director
25
30
  end
26
31
  end
27
32
 
33
+ def persist(blobstore)
34
+ file = Tempfile.new('compressed-rendered-job-templates')
35
+
36
+ compressed_archive = CompressedRenderedJobTemplates.new(file.path)
37
+ compressed_archive.write(job_templates)
38
+
39
+ blobstore_id = blobstore.create(compressed_archive.contents)
40
+ DeploymentPlan::RenderedTemplatesArchive.new(blobstore_id, compressed_archive.sha1)
41
+ ensure
42
+ file.close!
43
+ end
44
+
28
45
  private
29
46
  attr_reader :job_templates
30
47
  end
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Director
3
- VERSION = '1.1840.0'
3
+ VERSION = '1.1858.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-director
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1840.0
4
+ version: 1.1858.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-01-24 00:00:00.000000000 Z
12
+ date: 2014-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bcrypt-ruby
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 1.1840.0
37
+ version: 1.1858.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 1.1840.0
45
+ version: 1.1858.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: bosh-core
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: 1.1840.0
53
+ version: 1.1858.0
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: 1.1840.0
61
+ version: 1.1858.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: bosh_common
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 1.1840.0
69
+ version: 1.1858.0
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 1.1840.0
77
+ version: 1.1858.0
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: bosh_cpi
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 1.1840.0
85
+ version: 1.1858.0
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 1.1840.0
93
+ version: 1.1858.0
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: bosh_openstack_cpi
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 1.1840.0
101
+ version: 1.1858.0
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 1.1840.0
109
+ version: 1.1858.0
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: bosh_aws_cpi
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.1840.0
117
+ version: 1.1858.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.1840.0
125
+ version: 1.1858.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: bosh_vsphere_cpi
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: 1.1840.0
133
+ version: 1.1858.0
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: 1.1840.0
141
+ version: 1.1858.0
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: eventmachine
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -461,7 +461,7 @@ dependencies:
461
461
  version: '1.0'
462
462
  description: ! 'BOSH Director
463
463
 
464
- a98c30'
464
+ 570d8c'
465
465
  email: support@cloudfoundry.com
466
466
  executables:
467
467
  - bosh-director
@@ -502,6 +502,7 @@ files:
502
502
  - db/migrations/director/20131121182231_add_rendered_templates_archives.rb
503
503
  - db/migrations/director/20131125232201_rename_rendered_templates_archives_blob_id_and_checksum_columns.rb
504
504
  - db/migrations/director/20140116002324_pivot_director_attributes.rb
505
+ - db/migrations/director/20140124225348_proper_pk_for_attributes.rb
505
506
  - db/migrations/dns/20120123234908_initial.rb
506
507
  - lib/bosh/director.rb
507
508
  - lib/bosh/director/agent_client.rb
@@ -668,10 +669,9 @@ files:
668
669
  - lib/bosh/director/problem_handlers/unresponsive_agent.rb
669
670
  - lib/bosh/director/problem_resolver.rb
670
671
  - lib/bosh/director/problem_scanner.rb
671
- - lib/bosh/director/rendered_job_instance_hasher.rb
672
+ - lib/bosh/director/rendered_job_instance.rb
672
673
  - lib/bosh/director/rendered_job_template.rb
673
674
  - lib/bosh/director/rendered_job_templates_cleaner.rb
674
- - lib/bosh/director/rendered_job_templates_persister.rb
675
675
  - lib/bosh/director/rendered_templates_writer.rb
676
676
  - lib/bosh/director/resource_pool_updater.rb
677
677
  - lib/bosh/director/scheduler.rb
@@ -715,7 +715,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
715
715
  version: '0'
716
716
  segments:
717
717
  - 0
718
- hash: 1800556756686427460
718
+ hash: 1775214425609302363
719
719
  requirements: []
720
720
  rubyforge_project:
721
721
  rubygems_version: 1.8.23
@@ -1,41 +0,0 @@
1
- require 'tempfile'
2
- require 'bosh/director/compressed_rendered_job_templates'
3
- require 'bosh/director/deployment_plan/rendered_templates_archive'
4
-
5
- module Bosh::Director
6
- class RenderedJobTemplatesPersister
7
- def initialize(blobstore)
8
- @blobstore = blobstore
9
- end
10
-
11
- def persist(instance, rendered_job_templates)
12
- archive_model = instance.model.latest_rendered_templates_archive
13
-
14
- if !archive_model || archive_model.content_sha1 != instance.configuration_hash
15
- archive_model = persist_without_checking(instance, rendered_job_templates)
16
- end
17
-
18
- instance.rendered_templates_archive =
19
- DeploymentPlan::RenderedTemplatesArchive.new(
20
- archive_model.blobstore_id, archive_model.sha1)
21
- end
22
-
23
- def persist_without_checking(instance, rendered_job_templates)
24
- file = Tempfile.new('compressed-rendered-job-templates')
25
-
26
- compressed_archive = CompressedRenderedJobTemplates.new(file.path)
27
- compressed_archive.write(rendered_job_templates)
28
-
29
- blobstore_id = @blobstore.create(compressed_archive.contents)
30
-
31
- instance.model.add_rendered_templates_archive(
32
- blobstore_id: blobstore_id,
33
- sha1: compressed_archive.sha1,
34
- content_sha1: instance.configuration_hash,
35
- created_at: Time.now,
36
- )
37
- ensure
38
- file.close!
39
- end
40
- end
41
- end