Class: Bosh::Director::ReleaseJob

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/jobs/release/release_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_meta, release_model, release_dir, logger) ⇒ ReleaseJob

Returns a new instance of ReleaseJob.



6
7
8
9
10
11
12
13
14
15
# File 'lib/bosh/director/jobs/release/release_job.rb', line 6

def initialize(job_meta, release_model, release_dir, logger)
  @name = job_meta['name']
  @version = job_meta['version']
  @sha1 = job_meta['sha1']
  @fingerprint = job_meta['fingerprint']

  @release_model = release_model
  @release_dir = release_dir
  @logger = logger
end

Instance Attribute Details

#packagesObject

Returns the value of attribute packages.



4
5
6
# File 'lib/bosh/director/jobs/release/release_job.rb', line 4

def packages
  @packages
end

Instance Method Details

#update(template) ⇒ Object



17
18
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
45
46
47
48
49
50
51
52
53
54
# File 'lib/bosh/director/jobs/release/release_job.rb', line 17

def update(template)
  template.release = @release_model
  template.name = @name
  template.sha1 = @sha1
  template.fingerprint = @fingerprint
  template.version = @version

  unpack

  job_manifest = load_manifest
  validate_templates(job_manifest)
  validate_monit

  if template.blobstore_id
    begin
      @logger.info("Deleting blob for template '#{@name}/#{@version}' with blobstore_id '#{template.blobstore_id}'")
      BlobUtil.delete_blob(template.blobstore_id)
      template.blobstore_id = nil
    rescue Bosh::Blobstore::BlobstoreError => e
      @logger.info("Error deleting blob for template '#{@name}/#{@version}' with blobstore_id '#{template.blobstore_id}': #{e.inspect}")
    end
  end

  template.blobstore_id = BlobUtil.create_blob(job_tgz)
  template.package_names = parse_package_names(job_manifest)

  validate_logs(job_manifest)
  template.logs = job_manifest['logs']

  validate_properties(job_manifest)
  template.properties = job_manifest['properties']

  validate_links(job_manifest)
  template.provides = job_manifest['provides'] if job_manifest['provides']
  template.consumes = job_manifest['consumes'] if job_manifest['consumes']

  template.save
end