Class: Bosh::Director::JobRenderer
- Defined in:
- lib/bosh/director/job_renderer.rb
Instance Method Summary collapse
-
#initialize(job, blobstore) ⇒ JobRenderer
constructor
A new instance of JobRenderer.
- #render_job_instance(instance) ⇒ Object
- #render_job_instances ⇒ Object
Constructor Details
#initialize(job, blobstore) ⇒ JobRenderer
Returns a new instance of JobRenderer.
7 8 9 10 11 12 13 |
# File 'lib/bosh/director/job_renderer.rb', line 7 def initialize(job, blobstore) @job = job @blobstore = blobstore job_template_loader = Core::Templates::JobTemplateLoader.new(Config.logger) @instance_renderer = Core::Templates::JobInstanceRenderer.new(@job.templates, job_template_loader) end |
Instance Method Details
#render_job_instance(instance) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bosh/director/job_renderer.rb', line 19 def render_job_instance(instance) rendered_job_instance = @instance_renderer.render(instance.spec) configuration_hash = rendered_job_instance.configuration_hash archive_model = instance.model.latest_rendered_templates_archive if archive_model && archive_model.content_sha1 == configuration_hash rendered_templates_archive = Core::Templates::RenderedTemplatesArchive.new( archive_model.blobstore_id, archive_model.sha1, ) else rendered_templates_archive = rendered_job_instance.persist(@blobstore) instance.model.add_rendered_templates_archive( blobstore_id: rendered_templates_archive.blobstore_id, sha1: rendered_templates_archive.sha1, content_sha1: configuration_hash, created_at: Time.now, ) end instance.configuration_hash = configuration_hash instance.template_hashes = rendered_job_instance.template_hashes instance.rendered_templates_archive = rendered_templates_archive end |
#render_job_instances ⇒ Object
15 16 17 |
# File 'lib/bosh/director/job_renderer.rb', line 15 def render_job_instances @job.instances.each { |instance| render_job_instance(instance) } end |