Class: Bosh::Director::Core::Templates::RenderedJobInstance
- Inherits:
-
Object
- Object
- Bosh::Director::Core::Templates::RenderedJobInstance
- Defined in:
- lib/bosh/director/core/templates/rendered_job_instance.rb
Instance Method Summary collapse
- #configuration_hash ⇒ Object
-
#initialize(job_templates) ⇒ RenderedJobInstance
constructor
A new instance of RenderedJobInstance.
- #persist(blobstore) ⇒ Object
- #template_hashes ⇒ Object
Constructor Details
#initialize(job_templates) ⇒ RenderedJobInstance
Returns a new instance of RenderedJobInstance.
9 10 11 |
# File 'lib/bosh/director/core/templates/rendered_job_instance.rb', line 9 def initialize(job_templates) @job_templates = job_templates end |
Instance Method Details
#configuration_hash ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bosh/director/core/templates/rendered_job_instance.rb', line 13 def configuration_hash instance_digest = Digest::SHA1.new @job_templates.sort { |x, y| x.name <=> y.name }.each do |rendered_job_template| bound_templates = '' bound_templates << rendered_job_template.monit bound_templates << rendered_job_template.name rendered_job_template.templates.sort { |x, y| x.src_name <=> y.src_name }.each do |template_file| bound_templates << template_file.contents bound_templates << template_file.dest_name end instance_digest << bound_templates end instance_digest.hexdigest end |
#persist(blobstore) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bosh/director/core/templates/rendered_job_instance.rb', line 38 def persist(blobstore) file = Tempfile.new('compressed-rendered-job-templates') compressed_archive = CompressedRenderedJobTemplates.new(file.path) compressed_archive.write(@job_templates) blobstore_id = blobstore.create(compressed_archive.contents) RenderedTemplatesArchive.new(blobstore_id, compressed_archive.sha1) ensure file.close! end |
#template_hashes ⇒ Object
32 33 34 35 36 |
# File 'lib/bosh/director/core/templates/rendered_job_instance.rb', line 32 def template_hashes @job_templates.reduce({}) do |h, rendered_job_template| h.merge(rendered_job_template.name => rendered_job_template.template_hash) end end |