Class: Bosh::Director::Jobs::Helpers::StemcellDeleter
- Includes:
- LockHelper
- Defined in:
- lib/bosh/director/jobs/helpers/stemcell_deleter.rb
Instance Method Summary collapse
- #delete(stemcell, options = {}) ⇒ Object
-
#initialize(cloud, compiled_package_deleter, logger) ⇒ StemcellDeleter
constructor
A new instance of StemcellDeleter.
Methods included from LockHelper
#with_compile_lock, #with_deployment_lock, #with_release_lock, #with_release_locks, #with_stemcell_lock
Constructor Details
#initialize(cloud, compiled_package_deleter, logger) ⇒ StemcellDeleter
Returns a new instance of StemcellDeleter.
6 7 8 9 10 |
# File 'lib/bosh/director/jobs/helpers/stemcell_deleter.rb', line 6 def initialize(cloud, compiled_package_deleter, logger) @cloud = cloud @compiled_package_deleter = compiled_package_deleter @logger = logger end |
Instance Method Details
#delete(stemcell, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bosh/director/jobs/helpers/stemcell_deleter.rb', line 12 def delete(stemcell, = {}) with_stemcell_lock(stemcell.name, stemcell.version) do @logger.info('Checking for any deployments still using the stemcell') deployments = stemcell.deployments unless deployments.empty? names = deployments.map { |d| d.name }.join(', ') raise Bosh::Director::StemcellInUse, "Stemcell '#{stemcell.name}/#{stemcell.version}' is still in use by: #{names}" end begin @cloud.delete_stemcell(stemcell.cid) rescue => e raise unless ['force'] @logger.warn(e.backtrace.join("\n")) @logger.info("Force deleting is set, ignoring exception: #{e.}") end stemcell.destroy end end |