Class: Bosh::Director::Jobs::DeleteStemcell

Inherits:
BaseJob show all
Defined in:
lib/bosh/director/jobs/delete_stemcell.rb

Instance Attribute Summary

Attributes inherited from BaseJob

#task_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseJob

#begin_stage, #dns_manager, #event_manager, #logger, perform, #result_file, schedule_message, #single_step_stage, #task_cancelled?, #task_checkpoint, #track_and_log, #username

Constructor Details

#initialize(name, version, options = {}) ⇒ DeleteStemcell

Returns a new instance of DeleteStemcell.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bosh/director/jobs/delete_stemcell.rb', line 10

def initialize(name, version, options = {})
  @name = name
  @version = version
  @options = options
  @cloud = Config.cloud
  @stemcell_manager = Api::StemcellManager.new

  blobstore = options.fetch(:blobstore) { App.instance.blobstores.blobstore }
  blob_deleter = Helpers::BlobDeleter.new(blobstore, logger)
  compiled_package_deleter = Helpers::CompiledPackageDeleter.new(blob_deleter, logger)
  @stemcell_deleter = Helpers::StemcellDeleter.new(@cloud, compiled_package_deleter, logger)
end

Class Method Details

.job_typeObject



6
7
8
# File 'lib/bosh/director/jobs/delete_stemcell.rb', line 6

def self.job_type
  :delete_stemcell
end

Instance Method Details

#performObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bosh/director/jobs/delete_stemcell.rb', line 23

def perform
  logger.info("Processing delete stemcell")

  logger.info("Looking up stemcell: #{@name}/#{@version}")
  stemcell = @stemcell_manager.find_by_name_and_version(@name, @version)
  logger.info("Found: #{stemcell.pretty_inspect}")

  @stemcell_deleter.delete(stemcell, @options)

  "/stemcells/#{@name}/#{@version}"
end