Class: Bosh::Director::Jobs::BaseJob
- Inherits:
-
Object
- Object
- Bosh::Director::Jobs::BaseJob
show all
- Defined in:
- lib/bosh/director/jobs/base_job.rb
Direct Known Subclasses
Backup, CloudCheck::ApplyResolutions, CloudCheck::Scan, CloudCheck::ScanAndFix, CreateSnapshot, DeleteDeployment, DeleteDeploymentSnapshots, DeleteRelease, DeleteSnapshots, DeleteStemcell, FetchLogs, ImportCompiledPackages, ScheduledBackup, SnapshotDeployment, SnapshotDeployments, SnapshotSelf, Ssh, UpdateDeployment, UpdateRelease, UpdateStemcell, VmState
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
Returns the value of attribute task_id.
13
14
15
|
# File 'lib/bosh/director/jobs/base_job.rb', line 13
def task_id
@task_id
end
|
Class Method Details
5
6
7
|
# File 'lib/bosh/director/jobs/base_job.rb', line 5
def self.job_type
raise NotImplementedError.new('Subclasses must return a symbol representing type')
end
|
9
10
11
|
# File 'lib/bosh/director/jobs/base_job.rb', line 9
def self.perform(task_id, *args)
Bosh::Director::JobRunner.new(self, task_id).run(*args)
end
|
Instance Method Details
#begin_stage(stage_name, n_steps) ⇒ Object
40
41
42
43
|
# File 'lib/bosh/director/jobs/base_job.rb', line 40
def begin_stage(stage_name, n_steps)
event_log.begin_stage(stage_name, n_steps)
logger.info(stage_name)
end
|
#event_log ⇒ Object
19
20
21
|
# File 'lib/bosh/director/jobs/base_job.rb', line 19
def event_log
@event_log ||= Config.event_log
end
|
15
16
17
|
# File 'lib/bosh/director/jobs/base_job.rb', line 15
def logger
@logger ||= Config.logger
end
|
#result_file ⇒ Object
23
24
25
|
# File 'lib/bosh/director/jobs/base_job.rb', line 23
def result_file
@result_file ||= Config.result
end
|
#single_step_stage(stage_name) ⇒ Object
52
53
54
55
|
# File 'lib/bosh/director/jobs/base_job.rb', line 52
def single_step_stage(stage_name)
begin_stage(stage_name, 1)
track_and_log(stage_name, false) { yield }
end
|
#task_cancelled? ⇒ Boolean
Returns Has task been cancelled?.
28
29
30
31
32
|
# File 'lib/bosh/director/jobs/base_job.rb', line 28
def task_cancelled?
return false if task_id.nil?
task = task_manager.find_task(task_id)
task && (task.state == "cancelling" || task.state == "timeout")
end
|
#task_checkpoint ⇒ Object
34
35
36
37
38
|
# File 'lib/bosh/director/jobs/base_job.rb', line 34
def task_checkpoint
if task_cancelled?
raise TaskCancelled, "Task #{task_id} cancelled"
end
end
|
#track_and_log(task, log = true) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/bosh/director/jobs/base_job.rb', line 45
def track_and_log(task, log = true)
event_log.track(task) do |ticker|
logger.info(task) if log
yield ticker if block_given?
end
end
|