Class: Bosh::Director::Jobs::DeleteDeployment

Inherits:
BaseJob show all
Includes:
LockHelper
Defined in:
lib/bosh/director/jobs/delete_deployment.rb

Instance Attribute Summary

Attributes inherited from BaseJob

#task_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LockHelper

#with_compile_lock, #with_deployment_lock, #with_release_lock, #with_release_locks, #with_stemcell_lock

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(deployment_name, options = {}) ⇒ DeleteDeployment

Returns a new instance of DeleteDeployment.



12
13
14
15
16
17
18
# File 'lib/bosh/director/jobs/delete_deployment.rb', line 12

def initialize(deployment_name, options = {})
  @deployment_name = deployment_name
  @force = options['force']
  @keep_snapshots = options['keep_snapshots']
  @cloud = Config.cloud
  @deployment_manager = Api::DeploymentManager.new
end

Class Method Details

.job_typeObject



8
9
10
# File 'lib/bosh/director/jobs/delete_deployment.rb', line 8

def self.job_type
  :delete_deployment
end

Instance Method Details

#performObject



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/jobs/delete_deployment.rb', line 20

def perform
  logger.info("Deleting: #{@deployment_name}")
  parent_id = add_event
  with_deployment_lock(@deployment_name) do
    deployment_model = @deployment_manager.find_by_name(@deployment_name)

    fail_if_ignored_instances_found(deployment_model)

    ip_provider = DeploymentPlan::IpProviderFactory.new(true, logger)

    dns_manager = DnsManagerProvider.create
    disk_manager = DiskManager.new(@cloud, logger)
    instance_deleter = InstanceDeleter.new(ip_provider, dns_manager, disk_manager, force: @force)
    deployment_deleter = DeploymentDeleter.new(Config.event_log, logger, dns_manager, Config.max_threads)

    vm_deleter = Bosh::Director::VmDeleter.new(@cloud, logger, @force, Config.enable_virtual_delete_vms)
    deployment_deleter.delete(deployment_model, instance_deleter, vm_deleter)
    add_event(parent_id)

    "/deployments/#{@deployment_name}"
  end
rescue Exception => e
  add_event(parent_id, e)
  raise e
end