Class: Bosh::Director::Jobs::AttachDisk

Inherits:
BaseJob show all
Defined in:
lib/bosh/director/jobs/attach_disk.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(deployment_name, job_name, instance_id, disk_cid) ⇒ AttachDisk

Returns a new instance of AttachDisk.



15
16
17
18
19
20
21
22
# File 'lib/bosh/director/jobs/attach_disk.rb', line 15

def initialize(deployment_name, job_name, instance_id, disk_cid)
  @deployment_name = deployment_name
  @job_name = job_name
  @instance_id = instance_id
  @disk_cid = disk_cid
  @transactor = Transactor.new
  @disk_manager = DiskManager.new(Config.cloud, logger)
end

Class Method Details

.enqueue(username, deployment, job_name, instance_id, disk_cid, job_queue) ⇒ Object



11
12
13
# File 'lib/bosh/director/jobs/attach_disk.rb', line 11

def self.enqueue(username, deployment, job_name, instance_id, disk_cid, job_queue)
  job_queue.enqueue(username, Jobs::AttachDisk, "attach disk '#{disk_cid}' to '#{job_name}/#{instance_id}'", [deployment.name, job_name, instance_id, disk_cid], deployment)
end

.job_typeObject



7
8
9
# File 'lib/bosh/director/jobs/attach_disk.rb', line 7

def self.job_type
  :attach_disk
end

Instance Method Details

#performObject



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

def perform
  instance = query_instance_model
  validate_instance(instance)

  @transactor.retryable_transaction(instance.db) do
    handle_previous_disk(instance) if instance.persistent_disk
    handle_new_disk(instance)
  end

  "attached disk '#{@disk_cid}' to '#{@job_name}/#{@instance_id}' in deployment '#{@deployment_name}'"
end