Class: Bosh::Director::Jobs::RunErrand
- Inherits:
-
BaseJob
show all
- Defined in:
- lib/bosh/director/jobs/run_errand.rb
Instance Attribute Summary
Attributes inherited from BaseJob
#task_id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseJob
#begin_stage, #event_log, #logger, perform, #result_file, #single_step_stage, #task_cancelled?, #task_checkpoint, #track_and_log
Constructor Details
#initialize(deployment_name, errand_name) ⇒ RunErrand
11
12
13
14
15
16
17
|
# File 'lib/bosh/director/jobs/run_errand.rb', line 11
def initialize(deployment_name, errand_name)
@deployment_name = deployment_name
@errand_name = errand_name
@deployment_manager = Api::DeploymentManager.new
@instance_manager = Api::InstanceManager.new
@blobstore = App.instance.blobstores.blobstore
end
|
Class Method Details
7
8
9
|
# File 'lib/bosh/director/jobs/run_errand.rb', line 7
def self.job_type
:run_errand
end
|
Instance Method Details
19
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
45
46
|
# File 'lib/bosh/director/jobs/run_errand.rb', line 19
def perform
deployment_model = @deployment_manager.find_by_name(@deployment_name)
manifest = Psych.load(deployment_model.manifest)
deployment = DeploymentPlan::Planner.parse(manifest, event_log, {})
job = deployment.job(@errand_name)
if job.nil?
raise JobNotFound, "Errand `#{@errand_name}' doesn't exist"
end
unless job.can_run_as_errand?
raise RunErrandError,
"Job `#{job.name}' is not an errand. To mark a job as an errand " +
"set its lifecycle to 'errand' in the deployment manifest."
end
if job.instances.empty?
raise InstanceNotFound, "Instance `#{@deployment_name}/#{@errand_name}/0' doesn't exist"
end
runner = Errand::Runner.new(job, result_file, @instance_manager, event_log)
with_updated_instances(deployment, job) do
logger.info('Starting to run errand')
runner.run
end
end
|